Posts

Showing posts from February, 2013

svg - Raphael - Transform after Serialization -

i using raphael draw paths. each path has associated rectangle [container] size , position of bounding box. using container dragging both shapes. in move callback, update both positions both move together. this works great until serialize. serializing path, creating container on fly after deserialization. immediately after converting json , back, things fine. can print out current transform of path , looks correct. doing transform on path after results in path being reset , moved 0,0. here fiddle shows problem. if move rect, can see both objects move together. if click 'save/load', things fine, , path prints same. if drag, path gets reset 0,0. printing shows transform has been reset 0,0. i trying find out how make path move did before serialization. getting lost in process? or there internal state needs updated? raphael.json serialises data stored in elements. not preserve temporary data stored in paper object indeed lost in process when ...

How to copy data from .bin file to .pdf or .jpg in C++? -

i'm having problems reading binary data .bin file , writing pdf file. main goal receive file data on network, save data, files magic number , save , open file appropriate program. have data, save them binary file , right magic number. when try write binary data new pdf file, can't open resulting file. i'm using ifstream/ofstream , opening files in binary mode. if .txt file, works , can open file in end , everything's fine (i know, there no magic number involved in .txt files...) opening broken pdf textedit shows first few lines of data written file should, after lines stops (but new pdf has same size original file!) i hope understand problem , might have hints on problem is! thank you! roboneko edit: here code problem has be. hope, helps... long size; char * buffer; std::ifstream in(filenames[i].c_str(),std::ios::in | std::ios::binary); //filenames include filename in .bin format std::filebuf *pbuf; pbuf=in.rdbuf...

objective c - How to properly init RestKit's objectStore to use directory other than Documents -

so see there init method in restkit's reference: objectstorewithstorefilename:indirectory:usingseeddatabasename:managedobjectmodel:delegate suppose initialize objectstore in specified directory. "indirectory" parameter accepts nsstring. i've tried @"library/caches" , [self.applicationcachesdirectory absoluteurl] self.applicationcachesdirectory returns url of caches directory i'm getting exceptions. please tell me how can specify "library/caches" in method in order save sqlite db in caches directory instead of documents? got working. i've created helper method caches folder path nsstring - (nsstring *)applicationcachesdirectorystring { nsarray *paths = nssearchpathfordirectoriesindomains(nscachesdirectory, nsuserdomainmask, yes); nsstring *cachepath = [paths objectatindex:0]; bool isdir = no; nserror *error; if (! [[nsfilemanager defaultmanager] fileexistsatpath:cachepath isdirectory:&isdir] ...

c# - Does DataInputStream receives only 2048 bytes of data in Android? -

from pc (server side) c#.net application has sent 22000 bytes of data android device (client side) via wi-fi. datainputstream in android device showing 2048 bytes of it. datainputstream = new datainputstream(workersocket.getinputstream()); byte[] rvdmsgbyte = new byte[datainputstream.available()]; (int = 0; < rvdmsgbyte.length; i++) rvdmsgbyte[i] = datainputstream.readbyte(); string rvdmsgstr = new string(rvdmsgbyte); i confused following: is pc can send 2048 bytes of data? or, android device has 2048 bytes of capacity receive data? or, datainputstream shows 2048 bytes after device received bytes? if (data_received <= 2048 bytes) above code works perfect; you shouldn't using inputstream.available() . tells how data available right now - may not whole message, if it's still coming on network. if stream end @ end of message, should keep looping, reading block @ time until you're done (preferrably not reading byte @ time!). example: b...

printf in C doesn't occupy memory? -

does printf occupy memory in stack? printf("hello world"); does "hello world" have constant address? please me understand. edit: is argument passing printf stored in local pointer variable. if use array store 50 string literals takes stack memory if ii use printf doesn't take memory - heard. don't know how printf doesn't take memory array declared. please me understand! it depends on platform's calling convention , how standard library implemented. for example, take following program: #include <stdio.h> int main(void) { printf("hello, world\n"); return 0; } and following command line compile it: gcc -s -std=c99 -pedantic -wall -werror syscall.c on 32-bit red hat box (i686) using gcc 2.96, following machine code: 1 .file "syscall.c" 2 .version "01.01" 3 gcc2_compiled.: 4 .section .rodata 5 .l...

c++ - remove any element of vector<std::function<...>> that bound to member function -

how remove function bound member function of this object : std::vector<std::function<void(int)>> callbacks; class myclass { public: myclass() { callbacks.push_back( std::bind(&myclass::myfunc,this,std::placeholders::_1) ); } ~myclass() { auto = std::remove_if( std::begin(callbacks), std::end(callbacks), [&](std::function<void(int)>& f) { return // <-- question // true (remove) if f bound member function // of }); callbacks.erase(it,std::end(callbacks)); } void myfunc(int param){...} }; you can't in general case without buttload of work. type erasure clears information object, , std::function not expose information directly. your specific example may have 1 member function candidate remove, class 5 members stored callbacks?...

excel - Remove picture in EPPlus -

using eplus, how remove exiting picture worksheet? don't see "remove" method on drawings collection. exceldrawings has remove method: example: sheet.drawings.remove("image1"); // // summary: // removes drawing. // // parameters: // drawing: // drawing public void remove(exceldrawing drawing); // // summary: // removes drawing. // // parameters: // index: // index of drawing public void remove(int index); // // summary: // removes drawing. // // parameters: // name: // name of drawing public void remove(string name);

combobox - mouseover on Combo box in javascript not working -

i have static combo box in html default value selected , other values can select drop down. want call javascript function onmouseover. not working. can associate events combo box ? here's html: <select id="sel"> <option>foo</option> <select> and js: document.getelementbyid('sel').onmouseover = function() { alert('bar') } works fine. can see here - http://jsfiddle.net/tszuk/

ruby - get the ASIN number from amazon URL -

given amazon product url, can either http://amazon.com/gp/product/asin/* http://amazon.com/*/dp/asin/* http://amazon.com/dp/asin/* how scrap asin number url in ruby ? not @ writing regular expressions. use should find match by: scan(/https?:\/\/(?:www\.|)amazon\.com\/(?:gp\/product|[^\/]+\/dp|dp)\/([^\/]+)/)

Java Inheritance and Wrapping -

i have generated object want to: preserve existing functionality of without injecting constructor , rewriting every method call injectedobject.samemethod() . add additional functionality generated object without modifying generated object. add additional functionality to. for example: public class generatedobject { public string getthis() { ... } public string getthat() { ... } } public interface objectwrapper { string dothiswiththat(); } public class objectwrapperimpl extends generatedobject implements objectwrapper { string dothiswiththat() { ... } } however, downcasting not allowed, proper implementation without rewriting bunch of redundant code wrap object? i think decorator pattern may you: "the decorator pattern can used extend (decorate) functionality of object @ run-time, independently of other instances of same class"

gcc - Fatal Error while Running c++ object file -

i have compiled c++ project using cmake utility on red hat linux 4.1.2. gcc version: 4.1 when try run object file using following command got exception: ./gcvmp ../../dat/settlingsunix/mpsettings.xml exception : fatal error: 湥åsä i not able understand root cause. please me in regard. i suspect "fatal error:" portion printed code. it's supposed followed message explaining error, message passed corrupted, , junk printed. have tried compiling program -ggdb running under gdb? here's starter on how use debugger: http://www.ibm.com/developerworks/library/l-gdb/

oracle - ORA:00900 - Invalid SQL Statement -

i new vast world of oracle. trying is, creating stored procedure , retrieve result. procedure goes as create or replace procedure usp_rotaplateproductie_select( afdelingid in varchar2, producttypeid in varchar2, productiedata out sys_refcursor) begin open productiedata select rotaplateproductie.batchnummer, cpiplusproductieorder.productnummer, product.omschrijving, productieresultaatrtplrol.bruto_in_meters rotaplateproductie inner join productieresultaatrtplrol on rotaplateproductie.batchnummer = productieresultaatrtplrol.batchnummer inner join cpiplusproductieorder on productieresultaatrtplrol.productienummer = cpiplusproductieorder.productnummer inner join product on cpiplusproductieorder.productnummer = product.productnummer rotaplateproductie.afdelingid = '3144' , rotaplateproductie.producttype = 'pt005' end; and using below code trying execute it. var rc refcursor exec usp_rotaplateproductie_select('3144',...

Loop and if Statement in php -

i have following code. <?php if ( $showdata['venue'] == "brean sands" ) {echo "<div class=\"gigpress-related-park\">"; echo $showdata['date_long']; echo $showdata['venue']; echo "</div>"; } ?> <?php if ( $showdata['venue'] == "camber sands" ) {echo "<div class=\"gigpress-related-park\">"; echo $showdata['date_long']; echo $showdata['venue']; echo "</div>"; } ?> <?php if ( $showdata['venue'] == "pakefield" ) {echo "<div class=\"gigpress-related-park\">"; echo $showdata['date_long']; echo $showdata['venue']; echo "</div>"; } ?> <?php if ( $showdata['venue'] == "prestatyn sands" ) {echo "<div class=\"gigpress-related-park\">"; echo $showdata['date_long']; echo $showdata['venue'];...

asp.net mvc - Mapp with automappaer -

i have model named word. this word model public class word : basefieldstables { int id { get; set; } string name { get; set; } guid uniqid { get; set; } datetime createddate { get; set; } byte[] rowversion { set; get; } public string text { get; set; } public virtual category category { get; set; } public int categoryid { get; set; } public virtual language language { get; set; } public int languageid { get; set; } public virtual icollection<picture> pictures { get; set; } [inverseproperty("mainword")] public virtual icollection<relationshipbetweenwords> mainwords { get; set; } [inverseproperty("relatedword")] public virtual icollection<relationshipbetweenwords> relatedwords { get; set; } } word has category , language and... for example language model public class language : basefieldstables { int id { get; set; } string name { get; set; } g...

Using MinGW to compile C code, but error liblto_plugin-0.dll not found? -

i'm using mingw compile c code. when give command "make", appear error : gcc.exe : fatal error: -fuse-linker-plugin, liblto_plugin-0.dll not found compilation terminated. make: * [all] error 1. know how solve it? though long time since asked, faced same issue , found fine workaround when compiling. gcc -fno-use-linker-plugin test.cpp -o test

linux - How to automate telnet session using Expect? -

i'm trying write expect script automate telnet. have far. #!/usr/bin/expect # test expect script telnet. spawn telnet 10.62.136.252 expect "foobox login:" send "foo1\r" expect "password:" send "foo2\r" send "echo hello world\r" # end of expect script. basically, want telnet following ip address , echo hello world. however, seems script fails after attempting telnet...i'm not sure if it's able accept login , password input, not echoing hello world. instead, output: cheungj@sfgpws30:~/justin> ./hpuxrama spawn telnet 10.62.136.252 trying 10.62.136.252... connected 10.62.136.252. escape character '^]'. welcome opensuse 11.1 - kernel 2.6.27.7-9-pae (7). foobox login: foo1 password: foo2~/justin> you're sending echo command without first expecting prompt. try: # after sending password expect -re "> ?$" send "echo hello world\r" expect eof

c++ - Do C++11 regular expressions work with UTF-8 strings? -

if want use c++11's regular expressions unicode strings, work char* utf-8 or have convert them wchar_t* string? you need test compiler , system using, in theory, supported if system has utf-8 locale. following test returned true me on clang/os x. bool test_unicode() { std::locale old; std::locale::global(std::locale("en_us.utf-8")); std::regex pattern("[[:alpha:]]+", std::regex_constants::extended); bool result = std::regex_match(std::string("abcdéfg"), pattern); std::locale::global(old); return result; } note: compiled in file utf-8 encoded. just safe used string explicit hex versions. worked also. bool test_unicode2() { std::locale old; std::locale::global(std::locale("en_us.utf-8")); std::regex pattern("[[:alpha:]]+", std::regex_constants::extended); bool result = std::regex_match(std::string("abcd\xc3\xa9""fg"), pattern); std::locale::glo...

undo jquery animation -

i made animation 4 divs slide "behind" div. need have reset button shows divs again thought undo animation. so, example, if animated left -100px, thought animate right +100px. animation nothing though. made js fiddle. let me know if code. http://jsfiddle.net/r2arv/3/ thanks in advance help. if want reverse left: -100px, left: +100px or right: -100px. left: -100px equal right: +100px.

google docs tampering -

note: sorry not programming question not aware site post query. thought of me out this. query: have created excel sheet using google docs users fill details online. problem every user has access sheet. users tampered sheet , deleted data. there mechanism provided google docs prevent tampering of data? should do? should use else store user's data no user can tamper data? use google form function , set google spreadsheet private

android - Margin/Padding in percentage in XML -

i new in android development. want set margin & padding in xml,not in dp or px in percentage. there way this? it not possible, though better taking width , height of screen below in java code, , display display = getwindowmanager().getdefaultdisplay(); int width = display.getwidth(); int height = display.getheight(); then calculate margin screen size, , set by setmargin(int x) //method of view/layout. this way can set margin depending on screen size not fixed screen, , setting in percentage java code.

windows - Capturing web data sent and received by a desktop application -

i have mp3-tagging application auto fetches lyrics unknown source. how figure out kind of request sending, , source? get sniffer. wireshark , example. show network communication gets out of computer , comes back, should easy figure out rest.

windows - How to make and apply changes to Jan Berkel's android-plugin? -

as title says, i'm wondering how apply changes jan berkel's sbt android plugin . i know says there... $ git clone git://github.com/jberkel/android-plugin.git $ cd android-plugin $ sbt publish-local ... , did , got in /target/scala-2.9.1/sbt-0.11.3/ /api/ /cache/ /classes/ /resource_managed/ /ivy-0.6.2-snapshot.xml /sbt-android-plugin-0.6.2-snapshot.jar /sbt-android-plugin-0.6.2-snapshot-javadoc.jar /sbt-android-plugin-0.6.2-snapshot-sources.jar my question is, how apply changes current sbt. btw, i'm using windows 7 (i know, know... :d) after publish-local should have in local ivy cache , can use it. have checked if in there?

java me - playing youtube videos in J2me Lwuit form -

in project need show , play youtube videos in j2me lwuit based form through rss feeds? not find such example on internet? how can show , play youtube videos on j2me bases lwuit form? as far know option might possibly work cases use display.getinstance().execute(url) open youtube video itself.

linux - How to delete everything in a string after a specific character? -

example: before: text_before_specific_character(specific_character)text_to_be_deleted after: text_before_specific_character i know can done 'sed'. i'm stuck. can me out? there's no reason use external tool such sed this; bash can internally, using parameter expansion : if character want trim after : , instance: $ str=foo_bar:baz $ echo "${str%%:*}" foo_bar you can in both greedy , non-greedy ways: $ str=foo_bar:baz:qux $ echo "${str%:*}" foo_bar:baz $ echo "${str%%:*}" foo_bar especially if you're calling inside tight loop, starting new sed process, writing process, reading output, , waiting exit (to reap pid) can substantial overhead doing processing internal bash won't have. now -- often, when wanting this, might really want split variable fields, better done read . for instance, let's you're reading line /etc/passwd : line=root:x:0:0:root:/root:/bin/bash ifs=: read -r name passw...

How to name and retrieve a stash by name in git? -

i under impression give stash name doing git stash save stashname , later on apply doing git stash apply stashname . seems in case happens stashname used stash description. is there no way name stash? if not, recommend achieve equivalent functionality? have small stash periodically apply, don't want have hunt in git stash list actual stash number is. you can find stash name using git's regular expression syntax addressing objects: stash^{/<regex>} :/<regex> for example, when saving stash save name: git stash save "guacamole sauce wip" ... can use regular expression address stash: git stash apply stash^{/guacamo} this apply youngest stash matches regular expression guacamo . way, don't have know number stash @ in stack, have know name. there no terser syntax this, can create alias in .gitconfig file: [alias] sshow = "!f() { git stash show stash^{/$*} -p; }; f" sapply = "!f() { git stash apply stash^{/$*}; }...

Basic questions about uploading files in JSF -

i have never used uploading feature in jsf, have to. have couple of questions , "for dummies" series questions. so: 1) logged in users' pictures db or filesystem of server? 2) if server relative or fixed path or root url db/properties , relative part db too? 3) if db, how performance when using jpa2 + mysql? cons otherwise? 4) if using server, secure add new context images server.xml , use images address www.examble.com/imagesfolder/images.jpg? how avoid situation can see pictures? 5) best way handle uploading? using primefaces, purpose or else? 6) tutorial or examples how pro :)? 7) how avoid situation there might files same name? hashing names or? 8) if (really big if) decide share application 2 physical servers, problems paths pictures? 9) in case, have pictures, common , pictures "owned logged in users. how implement , why if know using primefaces, jpa2 , mysql , have unlimited space in server? 10) nice , hot summer everyone!! sami ...

How to add space between Textview and Tabbedview in android -

i have got relative layout, in have placed 2 textviews, 1 image view & tabbed view. have got tabbed view @ bottom. add space between tabview imageview. how achieve it?. here source code <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="6dip"> <imageview android:id="@+id/icon" android:layout_width="100dip" android:layout_height="100dip" android:layout_alignparentleft="true" android:layout_alignparenttop="true" android:layout_marginright="6dip" android:scaletype="center" android:src="@drawable/ic_launcher"/> <textview android:text="hello world" ...

ios - Custom PhoneGap slash screen -

is possible replace splash screen ios , android custom one? as far know there 2 splash screens in ios phonegap: the "normal" ios splash screen the phonegap splash screen (same image spinner) would possible to: replace "normal" ios splash on runtime possible normal xcode projects replace "spinner" splash screen (i couldn´t figure out if that´s phonegap-plugins / iphone / splashscreen code or not) it seems normal xcode ways of doing things overwritten. i´m bit confused i´m new phonegap. yeah,you can that. make custom image in 640×960px(name:default@2x~iphone.png) , 320×480px(name:default~iphone.png) go to[name project]/resources/splash replace them..

css - Sublime Text 2 remove all Class items from entire project folder -

we have taken on designed website. going rewrite css scratch. current website project has several 'class="stuff foo"' , tons of other classes. is there way in sublime text 2 remove item within class elements? example: <div id="basiclogin" class="login 50per wide homepage"> cleaned to: <div id="basiclogin" class=""> or <div id="basiclogin"> create project in sublime text , add folders need work with. use "find > find in files" find/search in open files , folders (they folders added project, , shown in sidebar) mark "regular expression" option (icon .*). use search pattern: \s+class="[^"]*" and empty replace string.

Create iOS Home Screen Shortcuts on Chrome for iOS -

i have web app allows user add web page home screen on iphone. that functionality exists safari. now released chrome browser iphone too. question how can instruct user add web page ios home screen. chrome browser doesnt seem have functionality..? can add shortcut chrome options appear on iphone home page? for completeness: https://developer.chrome.com/multidevice/android/installtohomescreen does add homescreen work on chrome ios? no.

create all possible triplet (three at time) combinations in r -

the following example data of case: mark <- c(paste("m", 1:6, sep = "")); set.seed(123); ind1 <- c(sample (c("a", "b", "h"), 6, replace = t)); set.seed(1234); ind2 <- c(sample (c("a", "b", "h"), 6, replace = t)); set.seed(12345); ind3 <- c(sample (c("a", "b", "h"), 6, replace = t)); set.seed (12344); ind4 <- c(sample (c("a", "b", "h"), 6, replace = t)); set.seed(1234567); ind5 <- c(sample (c("a", "b", "h"), 6, replace = t)); myd <- data.frame (mark, ind1, ind2, ind3, ind4, ind5) the data myd mark ind1 ind2 ind3 ind4 ind5 1 m1 h b 2 m2 h b h h h 3 m3 b b h h 4 m4 h b h 5 m5 h h b h 6 m6 b h b i want compare possible (triplet - 3 @ time) co...

sql - ORDER BY separately positive & negative numbers in MySQL statement -

i have mysql table , return rows based on column value in order: first ascending order if column >=0 then descending order if column <0 e.g. 0,2,4,7,-2,-3,-5 can use sign sort positive numbers top, take absolute value abs desired asc/desc. select * thetable order sign(col) desc, abs(col) edit as nahuel pointed out, above sort 0's middle between positive , negative. instead group them positives, can use case instead (or, if column integers, magical sign(col + 1) ) select * thetable order case when col >= 0 1 else 2 end, abs(col)

android - Inserted row missing after application restarts -

i using ormlite insertion using code below: protected void registeruser(edittext fullname, edittext email, edittext mobile, edittext username, edittext password) { //perform db call insert records user user = new user(); user.setfullname(fullname.gettext().tostring()); user.setemail(email.gettext().tostring()); user.setmobile(mobile.gettext().tostring()); user.setusername(username.gettext().tostring()); user.setpassword(password.gettext().tostring()); dbmanager.getinstance().adduser(user); } but after restarting application, above record missing , login fails. use following code authenticate , works existing records. public boolean login(string username, string password) { boolean validlogin = false; try { querybuilder<user, integer> qb = gethelper().getuserdao().querybuilder(); qb.where().eq("username", username).and().eq("p...

networking - Why is listening on port with Netcat not working -

i running following command on ubuntu: nc -l -p 5004 -v >> /home/anders/dropbox/netcatfiles/test which includes command make listen @ 5004. i sending rtp-stream port 5004 using vlc. when observing loopback-interface in wireshark notice icmp-packets message 'destination unreachable'. opening vlc , telling play incoming data @ port 5004, works, , stream played. what should in order netcat listen @ port 5004? i think need add " -u " parameter make listen on udp. by default, netcat works in tcp mode, rtp protocol udp based. "the transmission control protocol (tcp), although standardized rtp use,[5] not used in rtp application because tcp favors reliability on timeliness. instead majority of rtp implementations built on user datagram protocol (udp)" http://en.wikipedia.org/wiki/real-time_transport_protocol

java - A pattern for stack of urls -

i have following question. have application set of jsps , action classes control interaction user. actions set parameters required page display properly. urls in system contain name of event defines page should go next. now, every page has cancel button should lead previous page. start each cancel button url strictly defined, eventually, system grew larger , larger, turned out quite hard program logic button lead previous page. for example, suppose have 3 pages, a, b , c. page has link leading page b, , b has link leading c. therefore c has url leading b (and contains key of entity display on b). however, suppose page modified , has link on c. need check on c page there came , set url appropriately, , logic becomes pretty mixed. so, proposed team following solution. user session should contain special object called cancelstack. every action, leads page, should push it's url inside stack (containing event , additional data required). on every page cancel button should have...

c# - Can IE execute 2 JavaScript functions concurrently -

we using watin c# interact browser (currently ie). some of watin's methods simple wrapper sends "onchanged()" , "onclick()" web elements. watin provides fire-and-forget version this, provides non blocking version. my question is, browser 2 js functions execute @ same time? for example, assume following code: // uses fireeventasync("onchanged") selectlist.selectnowait() selectlist.fireeventasync("onclick") can both js functions onclick , onchanged execute @ once? i believe experiencing similar issue, onchanged() function still executing while fire event, wondering if technically possible. in short: no. javascript execution single-threaded. however, asynchronous operations (ajax, timers, workers, etc.), parts of function can setup executed later when thread free. a contrived example be: function foo() { settimeout(function () { console.log('three'); }, 10); console.log('one'...

ios - unable to receive push message for production apns -

i can receive push message using development cert, when change use production cert, no message can received, , there no error occurred. the apns address used is: ssl://gateway.push.apple.com:2195 , test ad-hoc deployment as app not yet uploaded app store, may know if affect app receive push message? thanks~ i got answer now, when archiving project, need use production distribution cert. production device token generated push notification. using device token can send push device production apns.

javascript - Google Apps Script - getRowIndex not functioning -

i had 2 similar applications stopped functioning correctly. both use method, 'getrowindex' , no longer populate variable position of cursor active row positions. has experienced this? looks google changed way getrowindex function works within google apps script. appreciated. below copy of code problem occurring. var sheet1 = spreadsheetapp.getactivesheet(); var row1 = sheet1.getactiverange().getrowindex(); in above example row1 takes value of 1 if cursor on first row not case. thank in advace time this. jeff there has been an issue this time ago fixed... can try this test sheet , see if works (see 2 test functions in menu). if not (which unlikely happen) can raise issue in issue tracker .

list file and send over a socket C -

this snippet of "list" function of ftp server variabels use. school project , has one requirement: it has work. no matter if code looks bad...this 5th program (and harder i've ever done) xd here's problem: /* here variabels */ int sockd, newsockd, socket_len, rc, rc_list, fd, fpl, i; int numporta = atoi(argv[1]); struct sockaddr_in serv_addr, cli_addr; off_t offset = 0, offset_list = 0; struct stat stat_buf; struct hostent *local_ip; static char filename[1024], buffer[256], saved_user[256]; char *user_string = null, *username = null, *pass_string = null, *password = null, *other = null; size_t fsize; char **files; file *fp_list; size_t count; /* , here snippet of list */ if(recv(newsockd, buffer, sizeof(buffer), 0) < 0){ perror("errore nella ricezione del nome utente"); onexit(newsockd, sockd, 0, 2); } other = strtok(buffer, "\n"); if(strcmp(other, "list") == 0){ print...

memory management - Cocos2D: What needs to be allocated? -

i should know can´t decide when allocate game objects when when don´t need to. example: have pause button in game. button not allocated in way, put in input layer this: pausebutton = [ccsprite spritewithspriteframename:@"pause.png"]; i´ve done labels. however, added character object game tutorial, this: [[[self alloc]initwithimage] autorelease]; (this line part of method) well, how 1 decide if allocate game object or not? there practice or should allocate->autorelease add game? actually 2 lines identical. spritewithspriteframename static function of ccsprite class. returns autorelease object. initwithimage non-static need allocate first, since it's marked autorelease, behaves in same way. my rule of thumb if there static functions available return auto-release objects, use them convenience sake. if remove autorelease second example, have manually call "release" on object destroy it. cannot call release on autorelease object, th...

c++ - Avoiding redefinition of a macro-defined class -

is there mechanism in c++ use implement macro such macro defines class , @ same time multiple invocations of macro not result in class redefinition error? thanks! since macro cannot generate c++ preprocessor directives, there isn't way definition of macro generate #define protects if being re-generated. you'd have handle separate preprocessor controls, somehow: #define class_generator_macro(x, y, z) ...defines class x attributes y, z... #ifndef generated_class_a #define generated_class_a class_generator_macro(a, int, vector<std::string>); #endif /* generated_class_a */ however, there nothing automatically enforces 1 use of class_generator_macro create class a . is, file can contain: class_generator_macro(a, double, double); and compiler complain redefinition of class (if both appear in same scope). a macro can generate invocation of _pragma . there's outside chance system provides pragma can help. there isn't portable solution using p...

wpf - Grey out image on button when element is disabled (simple and beautiful way) -

Image
i want grey out images (on buttons) when buttons disabled. when have text (no images) on button, text greyed out (with images button content not grey out). there simple , beautiful way that? this xaml file: <window x:class="wpfapplication2.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525"> <grid> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="*"/> </grid.rowdefinitions> <toolbartray verticalalignment="top" background="{dynamicresource {x:static systemcolors.controlbrushkey}}" islocked="true" grid.row="0"> <toolbar background="{dynamicresource {x:static systemcolo...

iphone - UiDocumentInteraction returns generic icons for images in iPad -

i need make simple file viewer , method returns icon images files. + (uiimage *)imageforfile:(nsstring *)filepath { nsurl *url = [nsurl fileurlwithpath:filepath]; uidocumentinteractioncontroller *c = [uidocumentinteractioncontroller interactioncontrollerwithurl:url]; uiimage *thumbnail = nil; nsarray *icons = c.icons; if([icons count] > 0) { thumbnail = [icons objectatindex:0]; } return thumbnail; } on ipod icons correct, on ipad 1g returns generic file icon images (jpg/png/gif). both have ios 5.0. how can proper icons images? thank you!

timer - Android Debugging ScheduledThreadPoolExecutor using DDMS -

for android application, use scheduledthreadpoolexecutor instead of timer because not affected time changes. with timer, can create giving name. ex: timer mytimer = new timer("timera"); this convenient because when debugging using ddms in threads view, can see threads running... , use name trace code. however, using scheduledthreadpoolexecutor, can't seem give name. , when debugging using threads view in ddms, see like: "pool-4-thread-1" isn't meaningful , can't trace code name that. can me this? the standard java api doesn't support naming threadpoolexecutor, however, naming thread created threadpoolexecutor supported via threadfactory, check out here : creating new threads new threads created using threadfactory. if not otherwise specified, defaultthreadfactory() used, creates threads in same threadgroup , same norm_priority priority , non-daemon status. supplying different threadfactory, can alter thread's name,...

powershell - Get Lun numbers and corresponding names - windows -

i have list of names of luns including mountpoints. looking find corresponding lun numbers/ disk numbers (the same see on disk management) programming disk 0 c: disk 1 d: any hints please - looking through powershell i using wmi information. place in win32_diskdrive. $drives = gwmi win32_diskdrive

1130 Host 'amazon-ec2-ip' is not allowed to connect to this MySQL server -

i facing problem in accessing mysql db on 1 of amazon ec2 servers ec2 server. read through various articles regarding providing appropriate permissions mysql accessed external ip addresses, , here steps followed: opened port 3306 on host ec2 instance allow external mysql connection. in file /etc/mysql/my.cnf, changed "bind-address" "127.0.0.1" "0.0.0.0". opened mysql using root, , executed following command: grant privileges on . worker@'ec2-ip-address' identified 'password'; as per blogs/articles read, should have solved issue, keep getting following error: 1130 host 'amazon-ec2-ip' not allowed connect mysql server the ip address providing ec2 instance elastic ip gets generated when create instance. verify whether issue specific ec2, tried executing command "3" different "static ip address". now, worked me (i.e. able login mysql host remote server), sure above steps correct. why amazon ec2 ip...

jquery - CakePHP Submit Search Field during entry threw Ajax -

in cakephp app have search field set , working properly: /* title search */ if (!empty($this->data)) { $title = $this->data['post']['title']; $conditions = array( 'conditions' => array( 'and' => array( 'post.title like' => "%$title%", 'post.status_id =' => '1' ) ) ); $this->set('posts', $this->post->find('all', $conditions)); } what trying achieve adding jquery/ajax submit form automatically during text entry , load search results "on fly". either on every other character, or on time intervals ... most, if not all, information find on topic meant cake 1.x , doesn't work here. feature looking should similar autocomplete search field of cakes documentation. can point me in right direction? (i new of this) well, first off, there 2 parts it: - server side (in controllers , or models) - client side (in views / js lib...

ruby on rails - Nested Form, "Can't mass-assign protected attributes" -

this relevant part of nested form: <div class="field"> <%= f.fields_for "@partcode" |p|%> <%= p.label "partcode"%><br /> <%= p.text_field :partcode %> <% end %> </div> and have in model: attr_accessible :partcode, :description yet when enter in form, error: can't mass-assign protected attributes: @partcode here partcode model: class partcode < activerecord::base attr_accessible :partcode, :description validates :partcode, :description, :presence => true belongs_to "goods_ins" accepts_nested_attributes_for "goods_ins" end and here code goods in model: class goodsin < activerecord::base attr_accessible :c4lpono, :courier, :deliverydate, :deliverynoteno, :description, :destination, :notes, ...

java - program works in eclipse but not after exported into a jar file -

i wrote program gets input device , displays on jpanel numbers according input when export file wouldnt show -as if doesnt start here sample code: main: public class main1 { static commportidentifier portid; static enumeration portlist; public static void main(string[] args) { portlist=commportidentifier.getportidentifiers(); while (portlist.hasmoreelements()){ portid=(commportidentifier) portlist.nextelement(); if (portid.getporttype()==commportidentifier.port_serial){ if (portid.getname().equalsignorecase("com4")){ sensor sensor1= new sensor(portid,portlist); try { thread.sleep(3000); } catch (exception e) {} jframe myframe = new jframe ("mouse controller"); myframe.setvisible(true); myframe.setsize(400, 400); ...

google maps - D7 - Is there a module to detect User LOCATION? -

is there contributed / core module detect physical location of user (based on ip may be?). what want is: 1. detect user location 2. calculate distance user's current location location data attached nodes (my nodes have location data) 3. filter results (i.e. show selective nodes) based on distance any direction helpful. i'm using d7. the module looking ip geolocation views https://drupal.org/project/ip_geoloc might want check out question , answer: https://drupal.stackexchange.com/questions/54873/geofield-proximity-in-views

c# - Is it better to have a public readonly object, identical local readonly objects per class, or to directly reference a library object? -

i'm building game using c# in xna , i'm not sure of these 4 ways best refer "viewport" reading access only: have public static variable every class can access calling game.viewport (game main class: public static readonly viewport viewport = graphicsdevice.viewport; in use: rectangle = new rectangle (game.viewport/2, ... have local variable refers viewport each class needs viewport: private readonly viewport viewport = graphicsdevice.viewport; in use: rectangle = new rectangle (viewport/2, ... use local variable passed down constructor of each class needs viewport (this 1 didn't require imported microsoft.xna.framework.graphics): private readonly viewport viewport; then in constructor: viewport = pviewport; in use: rectangle = new rectangle (viewport/2, ... directly reference viewport class library everywhere it's needed (in use): rectangle = new rectangle (graphicsdevice.viewport.width/2, ... i wondering 1 best in...

design - C# TableLayoutPanel fill -

in tablelayoutpanel, default, last element in row or column takes remaining space. how can achieve layout penultimate or other element takes space possible, , among others, last element takes space necessary? it depends on how other rows set. assuming other rows auto-sized or of fixed size, setting penultimate row's size 100% want. designers generated code looks this: this.tablelayoutpanel1.rowstyles.add(new system.windows.forms.rowstyle()); this.tablelayoutpanel1.rowstyles.add(new system.windows.forms.rowstyle(system.windows.forms.sizetype.percent, 100f)); this.tablelayoutpanel1.rowstyles.add(new system.windows.forms.rowstyle());

java - How to make a Person keep a reference to a Player in this code? -

problem: when skeleton enters place, want players screens updated using method in world object: /** * `text' in place `place'. text become visible @ * bottom of text window of players watching `place'. * * @param place * place string displayed. * @param text * string diplayed. */ public void sayatplace(place place, string text) { synchronized (players) { iterator<player> ls = players.iterator(); while (ls.hasnext()) { player p = ls.next(); if (p.currentplace() == place) { p.say(text); } } } } i've got 2 classes, person , player , want person write textarea when method goto called can't make person object have proper reference player has textarea: package adventure; import java.awt.*; import java.util.*; /** * adt persons completed subclasses creating actors * specific properties */ public class person { public player player = ...

javascript - Change background using a link's class -

first, sorry english, i'm french, so.. here problem. have menu, class="selected" active item. , have custom css class. works, so, it's ok this. but, i'd have different body's background pages. exemple, page1 must gray, page2 black, etc.. but, can't add class body (and then, change background css), because load pages same index.php file. i thought solve problem bit of javascript? item has "selected" class, , apply custom body's background thanks there can lot of other different ways that. here 1 idea. on page load using jquery's $(document).get ready, can selected menu. here rough idea whole. <ul> <li bodybgcolor="red" class="selected"></li> <li bodybgcolor="green"></li> <li bodybgcolor="yell"></li> <ul> $(document).ready(function() { bodybgcolor = $(.selected).attr("bodybgcolor"); $("body").css('...