Posts

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);