Posts

Showing posts from September, 2013

php - how to use session_start() with ajax? -

basically, have dynamic php page loads content using ajax. content loads supposed stuff session variable, can't because don't have session_start() . do, it's processed when actual page loads, , can't add session_start() when content loads. there way? thanks session_start() resumes existing session if it's in progress, can call in ajax handler.

Linux python read output from a running python script -

i have python script running service in linux (also autorun), , plenty of output! how can read output when program running? maybe log output file have open , refresh file time when new output logged! it possible implement tail python side, continuous reading of it. code snippet make work can found here: http://code.activestate.com/recipes/157035-tail-f-in-python/ additionally, if use append mode of file writing instead of write method can continuously output. scrapy uses concept of pipelines allow lot of same functionality. here's example of scrapy code might use same thing: class jsonwriterpipeline(object): def __init__(self): self.file = (open(filepath, 'a')) def process_item(self, item, spider): self.file.write(json.dumps(dict(item)) + '\n') return item

r - merge data frames to eliminate missing observations -

i have 2 data frames. 1 ( df1 ) contains columns , rows of interest, includes missing observations. other ( df2 ) includes values used in place of missing observations, , includes columns , rows @ least 1 na present in df1 . merge 2 data sets somehow obtain desired.result . this seems simple problem solve, drawing blank. cannot merge work. maybe write nested for-loops , have not done yet. tried aggregate few time. little afraid post question, fearing r card might revoked. sorry if duplicate. did search here , google intensively. thank advice. solution in base r preferable. df1 = read.table(text = " county year1 year2 year3 aa 10 20 30 bb 1 na 3 cc 5 10 na dd 100 na 200 ", sep = "", header = true) df2 = read.table(text = " county year2 year3 bb 2 na cc na 15 dd 150 na ", sep = "", header = true) desired.result = read.table(text = "

html - search won't sit next to navigation -

i have horizontal menu , want place search form in line appears left aligned on new line.. new html learning basics (working on third site got hang of css). <div id="nav"> <span class="nav"> <a href="#" alt="$"><span id="jqfade"><img src="images/skydevuppernav.png"></span></a> <a href="#" alt="$"><span id="jqfade"><img src="images/goftbuppernav.png"></span></a> <a href="#" alt="$"><span id="jqfade"><img src="images/genuppernav.png"></span></a> <span id="searchbox"> <form action="#" method="get">search <input type="text" name="searchgoogle" size="12" maxlength="45" /> </form>

ember.js and nested templates/views -

i'm still trying learn ember.js please bear me. objective i'm creating 1 page web application. when application, application ajax call return list of numbers lets. application process these numbers , create div each of numbers , store div container. a click event associated each div, when user clicks on link pop dialoge come up. code index.html <script type="text/x-handlebars"> <h2>welcome ember.js</h2> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="payloads"> <div class="page"> <div id="desktopwrap"> <div id="theaterdialog" title="theater view" class="bibwindow1"> {{view.name}} {{#each item in model}} <div {{bindattr id="item"}} {{ac

Android - Images are not displayed even though it has been loaded -

i set imageview layout width fix value , my layout height wrapcontent . images imageview loaded via url. happened , time view drawn, since image not yet loaded, draw layout_width . time images loaded, height no longer drawn, no image displayed. displayed if scroll , forth because, guess time view redrawn. there way can solve problem? using invalidate() did not work. maybe did wrong way? i'll post snippets of code: getview of myadapter extends baseadapter: public view getview(int position, view convertview, viewgroup parent){ viewholder holder = null; layoutinflater inflater = (layoutinflater) context.getsystemservice(activity.layout_inflater_service); typeface typefacemyriadreg = typeface.createfromasset(context.getassets(), myriad_reg); if(convertview == null){ convertview = inflater.inflate(r.layout.shop_list_layout, null); holder = new viewholder(); holder.txtshopname = (textview) convertview.findviewbyid(r.id.name);

c# - Crystal Report Chart with Minimum Formula Field Issue -

i'm working on report , satisfied results returning, however, can't chart created how i'd it. in report i'm looking @ each promotion_content (id) can have 1 or more values in approval stage table (each time approved @ different level inserts line table). want return recent approval stage each promotion_content_id , display in chart percentage @ different stages (approved, unsubmitted etc.). i've set grouping on promotion_content_id brings 1 or more records each unique promotion_content_id. i've set formula field: minimum ({benn_promotion_approval_stage.approval_stage},{benn_promotion_content.promotion_content_id}) which brings recent approval stage - looking far. plan suppress details i'm concerned recent approval stage each entry. the trouble comes when try add field chart, won't allow me add in. explain why , offer solution? cheers

cpu usage - IntelliJ IDEA 12.1 eat 100% CPU from time to time -

Image
i've updated intellij idea latest 12.1 version , found laptop cpu usage become 100% time time, monitor progress manager found idea fork new java process regularly , runs several tens of seconds , shutdown. during time cpu usage close 100%: chances external build mentionned @crazycoder compiles project automatically when make changes source files. if annoys much, can disable automatic compilation in file > settings > compiler > make project automatically (uncheck box).

php - Returning false $this->form_validation->run() when there is an empty input type="file" -

every time update settings , leaving input type="file" empty. $this->form_validation->run() returning false. did not use setrules , required it. here code: public function update_settings() { $this->load->model('bus_owner_model'); $data = $this->bus_owner_model->get_business_data_id_by_row($this->session->userdata('id')); $this->load->library('form_validation'); $this->form_validation->set_rules('business_name', 'business name', 'required|trim|xss_clean'); $this->form_validation->set_rules('type_of_business', 'type of business', 'required|trim'); $this->form_validation->set_rules('country', 'country', 'required|trim'); $this->form_validation->set_rules('address', 'address', 'required|trim'); $this->form_validation->set_rules('city', 'city',

php - Nested option in select -

i'm making taxonomy system. created recursive function , function display categories in list ( <ul> ). works fine list, every child element move right...etc... but need same <select> . here i've done far : private function _tohtml(&$list, $parent=-1, $pass = 0){ $foundsome = false; for( $i=0,$c=count($list);$i<$c;$i++ ){ $delay = ''; if( $list[$i]['parent_id']==$parent ){ if( $foundsome==false ){ $delay .= str_repeat("--", $pass); $foundsome = true; } echo '<option value="'. $list[$i]['id'] .'">'. $delay . $list[$i]['name'] .'</option>'; $this->_tohtml($list,$list[$i]['id'],$pass+1); } } } the problem is, works on first child elment, others kind of not considering @ all. looks : cinema --english (sub cat cinema) french (also sub cat

lua - Animating labels in Corona SDK -

is possible create sort of animation label in corona sdk? want make text appear big then, position move after comes , shrinks? don't want use image because text on label changes. if possible, can please point me right direction? thank you. is looking..? local label = display.newtext("label_1",50,100,nil,20) local function transition_3() label.text = "label_3" transition.to(label,{time=1000,xscale=1,yscale=1}) end local function transition_2() label.text = "label_2" transition.to(label,{time=1000,x=label.x+50,y=label.y+50,oncomplete=transition_3}) end transition.to(label,{time=1000,xscale=1.5,yscale=1.5,oncomplete=transition_2}) keep coding........ :)

javascript - Google maps - get latlng of X% along a straight polyline -

i need latitude/longitude of position @ x percentage along straight polyline segment between 2 other lat/lng points. the closest have come far using following (for 40% along line): google.maps.geometry.spherical.interpolate(startlatlng, endlatlng, 0.4); this works short distances, long polyline segment latlng returned outside of polyline travels, since it's working out shortest distance along earth's surface instead of shortest distance across flat map. any on appreciated, i'm missing obvious. there must proven , tested method out there this, here way maps api: convert lat/lng coordinates pixels interpolate in pixel plane convert lat/lng this pretty straightforward; 1 hassle figuring out how deal lines cross 180 meridian or pole. here's semi-tested code may give place start: function mercatorinterpolate( map, latlngfrom, latlngto, fraction ) { // projected points var projection = map.getprojection(); var pointfrom = projectio

cors - FullCalendar Cross Domain Issue -

i'm trying set fullcalendar on localhost test out. here's code: $( '.calendar' ).fullcalendar( { header: { left: 'prev,next today', center: 'title', right: 'month,agendaweek,agendaday' }, eventsources: [ { url: "http://www.google.com/calendar/feeds/feed_one", classname: 'feed_one' }, { url: "http://www.google.com/calendar/feeds/feed_two", classname: 'feed_two' ] } ) i got error in console instead, , events not displayed: xmlhttprequest cannot load http://www.google.com/calendar/feeds/feed_one. origin http://localhost not allowed access-control-allow-origin. localhost:1 xmlhttprequest cannot load http://www.google.com/calendar/feeds/feed_two. origin http://localhost not allowed access-control-allow-origin. localhost:1 from research seems cross-origin-resource-sharing issue, don't kn

node.js - fs.exists() is both true and false -

fs.exists(controller_path, function (exists) { util.debug( exists ? 'here' : 'not here' ); }); this example documentation. file exists each request, recieve: debug: here debug: not here you have posted sample code not actual code have. don't expect much. however, he's shot-in-the-dark i'm willing bet right: you don't realize browser sending 2 requests: 1 "/" , second "/favicon.ico".

How to communicate with Node.js server from Android client -

i'm working on small project need communicate node.js server(it has rest services) android client...i referred link combining java , nodejs android app ... there way can communicate instead of web sockets. check out http://www.mkyong.com/webservices/jax-rs/restfull-java-client-with-java-net-url/ , includes simple server example well, think client code should useful you. there this question should have more useful information you.

cordova - Can we use Ad Mob for PhoneGap? -

can use ad mob phonegap app, there api ad mob implements phonegap android, windows phone , iphone ? finally finding ad-mob windows phone. code below presents default xaml created phonegap template wp7, modified display admob banner @ bottom of mobile app. <grid x:name="layoutroot" background="transparent" horizontalalignment="stretch"> <grid.rowdefinitions> <rowdefinition height="*"></rowdefinition> <rowdefinition height="75"></rowdefinition> <!-- grid row admob --> </grid.rowdefinitions> <!-- original container displaying html --> <my:cordovaview grid.row="0" horizontalalignment="stretch" margin="0,0,0,0" x:name="cordovaview" verticalalignment="stretch"> </my:cordovaview> <!-- our admob banner: --> <google:bannerad grid.row="1" adunitid="your_ad_unit_id" xmlns:google=&q

javascript - TypeScript: Creating an empty typed container array -

i creating simple logic game called "three of crime" in typescript. when trying pre-allocated typed array in typescript, tried this: var arr = criminal[]; which gave error "check format of expression term" . also tried doing this var arr : criminal = []; and produced "cannot convert any[] 'criminal' what 'typescript' way this? the issue of correctly pre-allocating typed array in typescript obscured due array literal syntax, wasn't intuitive first thought. the correct way be var arr : criminal[] = []; this give correctly typed, empty array stored in variable 'arr' hope helps others!

memory - variable becomes undeclared after some iteration in matlab -

this question has answer here: is possible have workspace variable persists across call clear? 2 answers does matlab keep variables after clearing? matlab: free memory lost after calling function my question related post changes there. i have use output (the outputs matrices generated, i.e. generating small matrices in every iteration) produced previous large program, in next iteration of large program, when using technique mentioned in post, getting error " reference cleared variable", need keep of variables , matrices generated. how that? sometimes error occurs after 1 iteration thanks you can clear specific variables in workspace with: clear myvarname you can clear functions might holding persistent variables with: clear myfunname so - should work out ones don't want (type whos see variables in workspace, or in breakpoint

javascript - How can I make an arrow on an instruction box on the right move to point to the field on the left that is in focus? -

i have web page form on it. page separated 2 columns, left , right. form on left , there box instructions on right. currently, box on right comprised of cssarrowplease #arrow_box div configured arrow pointing left. i arrow move points form field on left has focus. by playing css, can manually move arrow , down. however, unsure how make moves dynamically tab or click focus on each different form field. if understand correctly, can add classes each position , change class of #arrow_box div according style when focus on form fields. although lengthy method. css class 1: .arrow_box { position: relative; background: #88b7d5; border: 4px solid #c2e1f5; } .arrow_box:after, .arrow_box:before { left: 100%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .arrow_box:after { border-color: rgba(136, 183, 213, 0); border-left-color: #88b7

Create Custom Js file from Jquery Core file -

in project, 1 widget (embed site), there jquery conflict issue parent website. so need create own js core file jquery core file. there way create custom js jquery core file. i have used below script still same problem. $.noconflict(); jquery(document).ready(function($) { // code uses jquery's $ can follow here. }); i have used few methods jquery core. want create own js file jquery core file. use anonymous function so: (function($) { //insert jquery }(jquery)) what allows use $ passes jquery anonymous function. anonymous functions self-invoking, meaning automatically call when loaded. if wanted include own javascript file, can utilize .getscript() $.getscript(url, function() { //success stuff }) i don't believe work if script want on different domain hosted though. xss issues , not.

android - How to avoid reminder when adding an event to the calendar -

i add event calendar method: private void writetocalendar() { intent l_intent = new intent(intent.action_edit); l_intent.settype("vnd.android.cursor.item/event"); l_intent.putextra(events.title, "title"); l_intent.putextra(events.description, ""); // description l_intent.putextra(events.event_location, ""); //eventlocation l_intent.putextra(events.dtstart, system.currenttimemillis()); // begintime l_intent.putextra(events.dtend, system.currenttimemillis() + event_length); // endtime l_intent.putextra(events.all_day, 0); // allday l_intent.putextra(events.status, events.status_confirmed); // eventstatus l_intent.putextra("visibility", 0); // visibility l_intent.putextra("transparency", 1); l_intent.putextra(events.has_alarm, 0); // hasalarms l_intent.putextra(events.allowed_reminders, ""); //allowedreminders try { startactivity(l_intent); } catch (exc

view - Save ViewGroup state : Android -

note: here not talking saving state of activity through onsaveinstancestate(...) i using https://github.com/eskim/android_drag_sample code drag , drop views in application. user can create multiple scenes in application , each scene, user can add multiple views , drag , drop them wherever want. while switching scenes storing scene information number of children's added, properties etc in model object , working fine. user can save scenes , send through mail pdf. problem prepare pdf need images(am using itext library convert images pdf) how can convert other hidden scenes(which not visible) image? visible scene can convert image , store in sd card. tried saving current scene in model object , converting image while preparing pdf overwriting scenes current scene. dont know whether approach correct or not. so, or clue appreciated. code convert view bitmap : public static bitmap getbitmapfromview(final view view) { if(view.getwidth() <= 0 && view.getheight() &l

asp.net - Tinymce: Spellchecker is not working -

i using spellchecker tinymce in application. spellchecker internally using moxiecode.tinymce.dll . it working fine before our last live update. it's giving error saying you must write contentlength bytes request stream before calling [begin]getresponse . here stacktrace appearing error detail in popup system.net.httpwebrequest.getresponse() +6038604 moxiecode.tinymce.spellchecker.googlespellchecker.sendrequest(string lang, string data) +762 moxiecode.tinymce.spellchecker.googlespellchecker.checkwords(string lang, string[] words) +197 moxiecode.tinymce.spellchecker.spellcheckermodule.processrequest(httpcontext context) +500 moxiecode.tinymce.web.httphandler.processrequest(httpcontext context) +282 system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +100 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +75 version information:  microsoft .net framework version:4.0.30319; asp.net vers

shell - extract matched line with line number between two pattern -

Image
this question has answer here: copy lines data between 2 patterns in shell scripting 2 answers is possible copy line line number destinationphp file pattern match using sed, awk or grep? take example, copy lines line number between '<(single quot less than) , '>;(single quot greater comma) source.php file destination.php this source.php i have code sed -ne "/''\;/wdestination.php" source.php thats output in screenshot but want copy matched line number in begining of line line data in next screenshot sed -ne "/'</,/>'\;/{=;p}" source.php | sed 'n;s/\n/ /;wdestination.php' hope looking +

android - In Java, Why do element of my byte array contain 2 bytes? -

i programming little java based android app receives c based unsigned char[] byte array bluetooth chip , streams byte array. the fact android , bluetooth shouldn't matter though, background. but, using minimum api 8 if makes difference. the main code is: inputstream = socket.getinputstream(); datainputstream dis = new datainputstream(is); byte[] buffer = new byte[1024]; bytesread = dis.read(buffer, 0, 1024); however, when @ actual contents of buffer, see this: [0] 15 [0xf] [^o] [1] 15 [0xf] [^o] [2] 0 [0x0] [^@ (nul)] [3] -119 [137] [0x89] [^É] [4] 2 [0x2] [^b] [5] 6 [0x6] [^f] [6] 26 [0x1a] [^z] [7] -47 [209] [0xd1] [Ñ] [8] -1 [255] [0xff] [ÿ] [9] 104 [0x68] [h] [10] -1 [255] [0xff] [ÿ] [11] -46 [210] [0xd2] [Ò] [12] -1 [255] [0xff] [ÿ] [13] 104 [0x68] [h] [14] -19 [237] [0xed] [í] [15] -128 [128] [0x80] [^À] the above copy eclipse expression view set show element [#] signed int value if negative, unsi

c# - Bulk insert XML data into SQL Server database -

i working on backup , restore selective data sql server. using following solution: export multiple tables mssql xml and create xml data want. how can create function restore these data sql server database? use sqlbulkcopy , can load data in datatable , using sqlbulkcopy can insert in table. sqlbulkcopy lets efficiently bulk load sql server table data source. and the sqlbulkcopy class can used write data sql server tables. however, data source not limited sql server; data source can used, long data can loaded datatable instance or read idatareader instance.

javascript - play sound in PDF -

i'm using scribus (open source alternative adobe indesign) create pdf e-book , i'd add show wav files pages. there possibility add javascript make pdfs interactive, can't add sound. tried hundreds of javascripts , none of them worked. have experience adding sound pdf or scribus? i'm using adobe reader open pdfs , have enabled javascripts. other functions pop-up alert work sound doesn't. pdfs not intended interactive standard intended portable print format. being said, can attach files enough (pdftk useful this) auto-running scripts in pdf pretty major 'no-no' ever since 'outlook.pdfworm'. add in in files doc , instruct readers click link.

Cant open XML from server in ios app but works fine in browser -

hello working on web services related project.data can seen if use given url along key in browser,but not able data in program(not parsing want entire data seen).please ?i have tried url , without url in project .code im using given below. nsstring *url = @"http:my link"; nsurl* url = [nsurl urlwithstring:url]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; nshttpurlresponse * urlresponse =nil; nserror *error;// = [[nserror alloc] init]; nsdata *responsedata = [nsurlconnection sendsynchronousrequest:request returningresponse:&urlresponse error:&error]; nslog(@"data=%@",responsedata); nsstring *result = [[nsstring alloc] initwithdata:responsedata encoding:nsutf8stringencoding]; nslog(@"result %@",result);

Remove Number and Dot from a string using Ragex in Javascript -

i want remove numbers, decimal present after number (no after character) using regax. example: let have string name abc4.5,asdjh44400.555 , dasqw123123. then output should abc,asdjh , dasqw. it should remove numbers , replace empty string. i searched in google tried above requirement didn't succeed. i have tried var abc = "asp.net 4.5"; alert(abc.replace("[0-9]+(?:\.[0-9]*)?", ""));` please me find solution using java script. thanks in advance 'abc4.5,asdjh44400.555 , dasqw123123.'.replace(/\d+.\d+/g,'') // -> abc,asdjh , dasqw.

Dynamic class name in PHP -

i'm trying create system has generalobj. generalobj allows user initiate special objects database's tables string of table name. far, works perfect. class generalobj{ function __construct($tablename) { //... } } however, tired type new generalobj(xxx) every time. wondering possible simplify process new xxx(), running same new generalobj(xxx)? spot php provided __autoload method dynamic loading files in setting include_path requires definition file existing. don't want copy , copy same definition files changing little. for cause, eval not option. maybe can auto-create files in autoloader: function __autoload($class_name) { // check classes ending 'table' if (preg_match('/(.*?)table/', $class_name, $match)) { $classpath = path_to_tables . '/' . $match[1] . '.php'; // auto-create file if (!file_exists($classpath)) { $classcontent = " class $class_name extends g

javascript - Attaching library while compiling to 11g -

i have problem frmjdapi library. wrote script compiling oracle forms, menus , librarys 6i 11g. found attachedlibrary, attaches oracle librarys menus , forms. how attach library library using class or there exist else? method simple, when convert pll file pld librarys listed in top of pld format: .attach library some_library end noconfirm\r\n so before compiling pll convert pld , add library of list. convert pll , have attached library.

magento - Get custom Attribute -

i'm wonder how can custom attribute, custom attribute call "tim_color" try $_product->getattributetext('tim_color'); after execute fatal error call member function getattributetext() on non-object when i'm used $data['color'] = $product->gettim_color(); in result i'm id, need name of atrribute, how can resolve problem my code of script: $mage_csv = new varien_file_csv(); //mage csv $products_model = mage::getmodel('catalog/product')->getcollection();; //get products model $products_model ->addattributetoselect('*'); $products_row = array(); foreach ($products_model $prod) { #print_r($prod); $product = mage::getmodel('catalog/product')->load($prod->getid()); $data = array(); $data['id_product'] = $product->getid(); $data['color'] = $product->gettim_color(); $data['sku'] = $product->getsku(); $data['name'] = strip_tags($prod

java - How to work with Spring based form tag Date field? -

in spring application have jsp , form. demo.jsp have 1 field <form:input path="fromdate"/> and in demoform have field private date fromdate; , when store value null value storing... my question direct tag store date in spring supplied jsp tag. other wise give me other alternate way.. you need define custom editor date in controller. please try below code. @initbinder public void initbinder(httpservletrequest request, servletrequestdatabinder binder) { dateformat df = new simpledateformat("dd-mm-yyyy"); df.setlenient(false); customdateeditor editor = new customdateeditor(df, true); // second argument 'allowempty' set true allow null/empty values. binder.registercustomeditor(date.class, editor); }

sql - Query results in empty result -

i trying following query `select skillmgt.*, competences.competence_description skillmgt inner join competences on skillmgt.eid=competences.competence_id eid=121 , datename(yyyy,timestamp)=2013` the query runs successfully, returns no results although have eid's equal competence_id's , where clause true actually,even without where clause not work! edit: solved doing: select skillmgt.*,competences.* competences join skillmgt on competences.competence_id=skillmgt.cid skillmgt.eid=121 , datename(yyyy,skillmgt.timestamp)='2013' datename returns string. depending on sql flavor, should try select skillmgt.*, competences.competence_description skillmgt inner join competences on skillmgt.eid=competences.competence_id eid=121 , datename(yyyy,timestamp)="2013"

iphone - How to create viewController in PhoneGap to work with main view -

i want open file [uidocumentinteractioncontroller presentpreviewanimated] ; i've created view controller @interface fileviewcontroller : uiviewcontroller <uidocumentinteractioncontrollerdelegate> @end #import "fileviewcontroller.h" @interface fileviewcontroller () @end @implementation fileviewcontroller - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (uiviewcontroller *) documentinteractioncontrollerviewcontrollerforpreview:(uidocumentinteractioncontroller *)controller { return self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end and trying preview file uidocumentinteractioncontroller *c

ios - i want to create CustomCell But it give some error, How to Solve it?? error is describe below -

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"customcell"; customcell *cell = (customcell *) [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone) { cell.accessorytype = uitableviewcellaccessorydisclosureindicator; } } cell.celldate.text=@"date"; cell.celldescription.text =@"description"; cell.cellimageview.image = [uiimage imagenamed:@"sample.png"]; cell.celltitle.text = @"title"; nslog([cell description]); return cell; } nslog([cell description]); return null above method gives below error: here terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'uitableview datasource must return cell tableview:cellforrowatindexpath:' you not allocating ne

ruby on rails - Showing if someone is reading a post -

i want show list of people reading post. before attempting implement function, wanted ask advice. start checking users invoke show action in postscontroller ; every time person views post, recorded onto list of people reading post. however, not sure how remove person list when navigates away reading post. there way use cookies or sessions notice if user navigates away page? little bit of me started right away! i appreciate advice. thank you! to more accurate in routes.rb post "/posts/:id/being_read" => "posts#being_read", :defaults => { :format => "json"} in controller postscontroller < applicationcontroller def being_read current_user && @post.being_read_by current_user head :ok end end on show page function beingread(){ $.post("/posts/<%=@post.id%>/being_read", function(data) { settimeout(beingread,10000); }); } in post.rb def being_read_by user=nil # making us

java - OutOfMemoryError while using HtmlUnit for scrapping -

i using htmlunit login on site , download data table when run code is causing java.lang.outofmemoryerror , not run further. following code : webclient webclient = new webclient(browserversion.internet_explorer_6); webclient.getoptions().setjavascriptenabled(true); webclient.getoptions().setcssenabled(false); webclient.getoptions().setredirectenabled(true); webclient.getcookiemanager().setcookiesenabled(true); webclient.getoptions().setprintcontentonfailingstatuscode(false); webclient.setajaxcontroller(new nicelyresynchronizingajaxcontroller()); webclient.getoptions().settimeout(50000); webclient.getoptions().setuseinsecuressl(true); webclient.getoptions().setpopupblockerenabled(true); htmlpage htmlpage=webclient.getpage(url); thread.sleep(200); //~~~~~~~log-in htmltextinput uname=(htmltextinput)htmlpage.getfirstbyxpath("//*[@id=\"username\"]"); uname.setvalueattribute("xxx"); htmlpasswordi

php - stop mysql_fetch_array when reach username -

i have code list of users database , sort them score. $sql="select * users order score desc"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ what want do, stop loop proces, when proces reach decided username. use break if condition while($rows=mysql_fetch_array($result)){ if($rows['name'] == 'yourname') { break; }else { //your code } }

swing - Is there a premade java library that emulates the Office Ribbon Customizer? -

Image
i'm trying implement 'ribbon customizer' microsoft office suite swing product. refresh memory, or show first time, customizer i'm referring looks (with obligatory hand drawn circles): i spend few weeks of own time trying make robust class draw this, it's 2 scroll panes, , few buttons. don't want re-invent wheel, when wheel end @ least little wonky. for background, it's going in future allow users select sheets added output excel workbook. does sort of component exist in package somewhere can include in project? sort of element have standard name? i've tried googling images , java packages no avail, closest found swt 'widget' , emulates ribbon, not customizer.

php - CodeIgniter URL not found -

enter code here i got code in .htaccess file: rewriteengine on rewritebase /projfolder ### canonicalize codeigniter urls # if default controller other # "welcome" should change rewriterule ^(mycontrol(/index)?|index(\.php)?)/?$ / [l,r=301] rewriterule ^(.*)/index/?$ $1 [l,r=301] # removes trailing slashes (prevents seo duplicate content issues) rewritecond %{request_filename} !-d rewriterule ^(.+)/$ $1 [l,r=301] # enforce www # if have subdomains, can add them # list using "|" (or) regex operator rewritecond %{http_host} !^(www|subdomain) [nc] rewriterule ^(.*)$ http://www.domain.tld/$1 [l,r=301] # enforce no www #rewritecond %{http_host} ^www [nc] #rewriterule ^(.*)$ http://domain.tld/$1 [l,r=301] ### # removes access system folder users. # additionally allow create system.php controller, # not have been possible. # 'system' can replaced if have renamed system folder. rewritecond %{request_uri} ^system.* rewriterule ^(.*)$ /index.php/$1 [l]

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -

php newbie here, struggling crazy head around how go implementing http_referer-based security feature woefully inept downloads system. basically, have file download pages have specific string appended end of url, specific string being: ?thanks if visible in url, users able download file situated on it. works great, it's easy 'unlock' page adding '?thanks' part onto url themselves. allowing users bypass clumsy security , access premium files ease. if possible, i'd add security measure whereby attempting access page containing string '?thanks' did not arrive page containing '?pending' redirected homepage. make perfect solution me. just clarity, typical pre-download process goes this: user visits download page: [website]/download/page/123/ user completes recaptcha, gets redirected here: [website]/download/page/123/?pending user fills in details, gets redirected here: [website]/download/page/123/?thanks user receives file long-

data warehouse - Is my accumulating snapshot design correct for my DW and my need -

i discovered accumulating snapshot design dw. i need record bug info come bug tracker. bugs have info (a bug number, sentence ...). has status: created, canceled, affected, resolved a bug don't have go through status (it can go created cancel, or created affected resolved ...) here central fact table ft_bug_track idbug int bugsentence varhchar(100) createddate date resolveddate date affecteddate date canceleddate date fkstatus int the status foreign key link dimension tells me in status i'm in (created, canceled ...) (of course have others dimensions project, client, typeofbug ...) everytime bug changing of status, i'll put new date needed , update fkstatus one is design dw , system? i have no idea if it's design situation, depends on requirements are, i.e. need able show in reports. if don't understand how data used ,

Failure to open write channel after upgrading App Engine Java SDK -

i'm trying upgrade version of app engine sdk using our play! web application 1.6.0 1.7.6. after upgrade we're no longer able write files blobstore of local development server. use following code write file: image img = imagesservicefactory.makeimage(uploadeddata); fileservice fileservice = fileservicefactory.getfileservice(); appenginefile file = fileservice.createnewblobfile("image/png", "__initial_data/" + vf.getname()); filewritechannel writechannel = fileservice.openwritechannel(file, true); outputstream output = channels.newoutputstream(writechannel); the call fileservice.openwritechannel fails following stack trace: caused by: java.lang.nullpointerexception @ com.google.appengine.tools.development.requestendlistenerhelper.register(requestendlistenerhelper.java:39) @ com.google.appengine.api.files.dev.localfileservice.open(localfileservice.java:247) @ com.google.appengine.tools.development.apiproxylocalimpl$asyncapicall.callin

Conditional probability in PHP -

i want draw random numbers between 1 , 100 in php. want numbers drawn probability of 20%, odd numbers probability of 80%. how can implement this? function wtf_random() { $ret = 2 * rand(1, 50); if (rand(1, 5) !== 1) { --$ret; } return $ret; }

objective c - Core Data Predicate Date Comparison -

im trying fetch objects in entity matching user selecteddate (it's nsdate). core data code fine predicate keeps returning 0 results, dates same in database user selecting. how should selecteddate compared date entity using predicate? nspredicate *predicate = [nspredicate predicatewithformat:@"(edate = %@)", selecteddate]; your predicate looks fine. the reason you're finding 0 result returned may dates aren't entirely same. for example: 05/04/2012 13:37:00 not match 05/04/2012 13:37:01 these 2 values not same. do want check date (day, month, year) time? if want check date, should create start date , end date , compare them using user selected date frame of reference. something similar should create date , time 00:00:00. //gather current calendar nscalendar *calendar = [nscalendar currentcalendar]; //gather date components date nsdatecomponents *datecomponents = [calendar components:(nsyearcalendarunit | nsmonthcalendarunit | nsdayc

osx - How do I use the current folder name without a path as a variable in automator in Mac? -

Image
i using mac osx 10.8.3. i have workflow in automator set follows: ask finder items get folder contents make sequential move finder items the purpose of workflow automate renaming bunch of photos have saved in folders move them new folder. i want grab foldername , stick in variable , use variable in "new name box" in make sequential section of work flow (see attached) image. how grab folder name , assign variable. example has variable called "foldername" here screenshot this works in testing: ask finder items - set type folders. set value of variable - path folder taken action 1 . run shell script - set pass input : argument. , use /usr/bin/basename "$1" command line folder name set value of variable - foldername of folder taken action 3 . get value of variable - set variable obtains value of path 5a. set action 5 ignore input above action 4 - crtl + mouse click on action title contextual menu get folder

javascript - How to restrict characters during keypress event in h:inputText -

i need input component accept numbers in [0-9] . have achieved server side conversion/validation: <h:inputtext ... converter="javax.faces.integer" /> however, still allows other characters while entering in ui. how can prevent during keypress event? <h:inputtext ... converter="javax.faces.integer" onkeypress="...help?" /> try this <h:inputtext id="presentreading" styleclass="labelfont" label="present reading" converter="javax.faces.integer"value="#{fuelfilling1.presentreading}" maxlength="10"> <f:validatelongrange minimum="1" maximum="10"/> </h:inputtext> alternatively, can use jquery or javascript validate on client-side on keypress. okay use jquery?

android ndk - app crashed at avformat_find_stream_info -

i write native method codec id of video, app never pass line 'avformat_find_stream_info(pformatctx, null)' here native method: int get_video_info(jnienv *env, jobject thiz, jstring strinfile){ avformatcontext *pfmtctx; avcodeccontext *pcctx; avcodec *pcd; avframe *picture; int i, videostream = -1, error = 0; const char *in_file_name = (*env)->getstringutfchars(env, strinfile, null); av_register_all(); logi(1, "here 0 %s", in_file_name); // app passed here /*open video file*/ pfmtctx = avformat_alloc_context(); if((error=avformat_open_input(&pfmtctx, in_file_name, null, null)) < 0){ loge(1, "couldn't open file, error-code: %d file url: %s", error, in_file_name); return -1; } logi(1, "here 1 duration: %d", pfmtctx->duration); //app passed here /*retrieve stream information, app crash right here*/ if(avformat_find_stream_info(pformatctx, null)<0){ loge(1, "couldn't retrieve stream information")

php - !$variable = $variable inside if -

i gnawing on basics of php socket servers , client here . then stumbled upon these lines (excerpt above links first example, happens inside while ): if (false === ($buf = socket_read($msgsock, 2048, php_normal_read))) { echo "socket_read() failed: reason: " . socket_strerror(socket_last_error($msgsock)) . "\n"; break 2; } if (!$buf = trim($buf)) { continue; } i'm okay reading part, , closing connection in case there error reading. but next if driving me nuts. firstly, i'm confused how 1 may , need assign value boolean. secondly, have trouble understanding whole expression altogether. could please explain happens inside if, , how applies server context? p.s. please excuse me if question isn't asked. i'm confused happens there , have no idea ask for. with statement, there's no assignment boolean. we're comparing type of false , value of false (true false, not merely 0). can read here if (false === ($

output - VBA Excel Printing data into Immediate Window about a range data to test understanding -

i wanting series of small tests helps builds understand work around small business problem of generating data in correct manner. my first approach prove myself print (string data type) list of id's (using .value method) in immediate window of vbe can see list can build test afterwards. my vba code @ moment shows define "custtest" named range a1:a100 in sheet 1 sub testranges() dim custrng range each custrng in range("custtest") print custrng.value next end sub i thought of this sub testranges() dim custrng range each custrng in range("custtest") custrng print .value end next end sub this came error not sure has occured, compile error:- method not valid without suitable object. any suggestions? thanks, peter. use: debug.print .value instead of print .value additional information: print suitable use in immediate window. however, use ? (question mark) there instead of print

c++ - Threads disappeared on DLL ExitInstance -

i have windows dll functions initinstance , exitinstance. dll creates threads, worker threads _beginthreadex , threads message queue, derived cwinthread (mfc). the dll should useable application. i wrote small host application dll test , worked fine, except when close host application without calling freelibrary before. in case, exitinstance called well, threads disappeard, quite unusual , leads deadlock routines waiting thread finished not exist longer - finished or killed. need go way (skip call freelibrary) in order simulate hapen when other applications use dll. exitinstance called, threads still running disappeared - because dll handled somehow differently when unloaded host process if not call freelibrary before. they disappear silently, instance, if thread implements loop waitforsingleobject within loop, thread not finish normally. thread() { while(running == true) { waitforsingleobject(...); } threadfinished=true; /// 1 } if calling freel

c# - Inputting a number beyond a range set by an array, index out of range error -

i want make program wherein user inputs number, in case number of items. number of items compared value in array, , corresponding discount displayed. using system; using system.collections.generic; using system.linq; using system.text; namespace consoleapplication11 { class program { const int size = 4; static void main(string[] args) { int itemsbought = 0; int discountitem = 0; int[] items = new int[size] { 0, 10, 26, 61 }; int[] discount = new int[size] { 0, 5, 10,15 }; inputitems(ref itemsbought); getdiscount(items, discount, ref itemsbought, ref discountitem); console.writeline("your discount {0}", discountitem); } private static void getdiscount(int[] items, int[] discount, ref int itemsbought, ref int discountitem) { int idx = 0; (idx = 0; itemsbought > items[idx] || idx > items.length; idx++

html - custom css don't render on jquery mobile page -

can enlighten why css dont show. have custom css in file line: my_own_stylesheet: .test { color: #f00; /* red */ } and simple page this: <!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="widdiv=device-widdiv, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <title> </title> <link rel="stylesheet" href="css/jquery.mobile-1.3.0.min.css" /> <link rel="stylesheet" href="css/my_own_stylesheet.css" /> <script src="js/jquery-1.9.1.min.js"> </script> <script src="js/jquery.mobile-1.3.0.min.js"> </script> <script type="text/

excel 2003 vba.. writing arraylist -

i trying create arraylist of class in java, in visual basic excel 2003. java list<employee> employees = new arraylist<employee>(); employee employee = new employee(); employee.setname("tom"); employees.add(employee); vb dim resultlist new collection dim manager employee manager.name = "df" resultlist.add ("rr") 'correct resultlist.add (manager) 'error but gives following error: only user-define types defined in public object modules can coerced or variant or passed late-bound functions there no type information associated udt can't added collection there no way reliably convert to/from variant number & types of members unknown. you can either replace employee type class or don't appear using key, typed array: arr() employee

Compiling CSS on OSX Lion in CodeKit - File to import not found or unreadable: compass -

having issue codekit compiling scss files. works via terminal compass compile or compass watch within codekit throws error: syntax error: file import not found or unreadable: compass. load path: / the line it's complaining is: @import "compass"; i've installed compass standard way , put project codekit have no idea why it's dying here... i've had google around people complaining 'zurb-foundation' , issue commonly being didn't import in compass.rb file. here it's compass. i've tried sudo gem update nothing seems codekit compile properly. i'm using zend framework , adding root directory codekit. seems had add public folder work recognised project compass project , worked sass in root directory.