Posts

Showing posts from February, 2010

security - SaaS - How to prove users/client that they are using the same code always in the server? -

let's suppose have open source project running in server. is there common way prove users we're using same code 1 published? there never implicit guarantee remote service what's described in manifest, though reputation of service what's directly considered. what's more, saas delivery model, , doesn't define set of protocols or contracts between client , service. merely defines approach building , serving public platform. it's term more relevant describing building process of service , it's intended market describing nitty-gritty operational details. if such thing needed implemented part of contract between client , server, 1 @ implementing native hashing solution using hmacs. identity mechanism implemented using salted access tokens similar oauth, using files of codebase generate checksum. guarantee if code executed once, same code running long hash generated did not change (though there's once again no guarantee hash being pub...

Do arrays within C# struct defeat the performance benefits? -

supposedly c# structs have performance benefits on classes lightweight data objects because they're stored entirely on stack instead of allocating heap memory. if 1 of members of struct int[] or array of structs, effect have on allocation , other performance benefits might out of it? example: struct { int foo; int bar; } struct b { int[] foos; a[] bars; } how struct differ struct b in performance, memory usage, etc? since size not part of type, arrays must dynamically allocated. struct contains pointer array. the struct stack allocated* array contents still on heap. *usually. there cases value types heap allocated, such being outer variable used in anonymous method. , of course, if it's part of object heap allocated, struct allocated inline on heap. there other corner cases, isn't important.

php - Doctrine2 Getting a Proxy when I want an entity -

when log system, the user record , save session. however, when want become else, instead of entity, proxy of entity. work fine, however, when save in session, errors out because partial class. is there way regain entity? doctrine returns proxy when query doesnt contain want , it's named lazy loading . if want take entity, please write queries want or use getrepository() function.

ruby - Customizing IRB output -

i've created class called specialarray , i'd customize sort of output irb shows. currently, when create new instance of class, irb returns entire object. see: 1.9.3p194 :022 > specialarray.new([1,2,0,6,2,11]) => #<uniquearray:0x007ff05b026ec8 @input=[1, 2, 0, 6, 2, 11], @output=[1, 2, 0, 6, 11]> but i'd show i've defined output. in other words, i'd see this. 1.9.3p194 :022 > specialarray.new([1,2,0,6,2,11]) => [1, 2, 0, 6, 11] what need specify irb should display output? solution: this method ended creating. def inspect output.inspect end irb calls object#inspect method string representation of object. need override method that: class foo def inspect "foo:#{object_id}" end end then in irb you'll get: >> foo.new => foo:70250368430260 in particular case make specialarray#inspect return string representation of underlying array, e.g.: specialarray def inspect @output....

iphone - Can't Capture AVCaptureVideoPreviewLayer -

in app opening video preview layer code: avcapturedeviceinput *captureinput = [avcapturedeviceinput deviceinputwithdevice:[avcapturedevice defaultdevicewithmediatype:avmediatypevideo] error:nil]; /*we setupt output*/ avcapturevideodataoutput *captureoutput = [[avcapturevideodataoutput alloc] init]; captureoutput.alwaysdiscardslatevideoframes = yes; dispatch_queue_t queue; queue = dispatch_queue_create("cameraqueue", null); [captureoutput setsamplebufferdelegate:self queue:queue]; dispatch_release(queue); nsstring* key = (nsstring*)kcvpixelbufferpixelformattypekey; nsnumber* value = [nsnumber numberwithunsignedint:kcvpixelformattype_32bgra]; nsdictionary* videosettings = [nsdictionary dictionarywithobject:value forkey:key]; [captureoutput setvideosettings:videosettings]; self.capturesession = [[avcapturesession alloc] init]; [self.capturesession addinput:captureinput]; [self.captur...

sql - how to understand "can't connect" mysql error messages? -

i have following error message: sqlstate[hy000] [2003] can't connect mysql server on '192.168.50.45' (4) how parse (i have hy000, have 2003 , have (4). hy000 general odbc-level error code, , 2003 mysql-specific error code means initial server connection failed. 4 error code failed os-level call mysql driver tried make. (for example, on linux see "(111)" when connection refused, because connect() call failed econnrefused error code, has value of 111.)

ios - about the glkview -

the thing this: -(void)glkview:(glkview *)view drawinrect:(cgrect)rect { glfloat firstbar=[self.myfirstbar.text floatvalue]; glfloat secondbar=[self.mysecondbar.text floatvalue]; glfloat thirdbar=[self.mythirdbar.text floatvalue]; glfloat fourthbar=[self.myfourthbar.text floatvalue]; glclearcolor(1.0f, 1.0f, 1.0f, 1.0f); glclear(gl_color_buffer_bit | gl_depth_buffer_bit); glint situationnum=_situationbar.selectedsegmentindex; [m_fourbar draw:firstbar secondbar:secondbar thirdbar:thirdbar fourthbar:fourthbar situation:situationnum]; } this glkview in viewcontroller. because firstbar, secondbar, thirdbar , fourthbar numbers want pass method of draw:firstbar secondbar:secondbar thirdbar:thirdbar fourthbar:fourthbar situation:situationnum . works if set 4 bars numbers instead of variables. want use user can type numbers textfields. , push button activate it. here uibutton in viewcontroller: -(ibaction)startbutton:(uibutton *)sender { g...

visual studio 2010 - Is there any VS Add-in to autoupdate XML Doc-Tags with the editing date/version? -

when change code (methods, properties, class) write manually date , assembly/file version in xml tags documentation comments in order remember when edited last time (and in version) piece of code. in own projects use tag "version", in other projects put edit date , assembly version in tag "remarks". functions, classes, methods of solution: of course when have more functions in same file , edit function1, have notice date/version when edited function , if edit function2, tag of function1 has not updated. i wondering if there vs 2010 add-in automate (partially too) process.

codeigniter - How to read images from a remote sftp file server -

so i'm using codeigniter php framework website. have few servers, live, dev, , file server. we've been able upload files our dev server, , secure copy them our file server storage. our problem way read/display images on our dev website file server. our file server uses sftp it's security. we've been looking different ways pass image object file server, not actual file. suggestions on how this? thanks. codeigniter php framework linux servers sftp on file server thanks... well, have not dealed sftp @ lest try give steps begin. you need install apache/php module ssh2 , enable extension=php_ssh2.dll . you make own sftp library, this: class sftp{ protected $connection; public function __construct($params) { } public function connect() { $server = "you-server.com"; $port = "1234"; $username = "admin"; $password = "blabla"; //connect $ssh2 = ssh2_connect($server, $port...

c# - Unsigned operator in Java -

as know, java doesn't have unsigned types. have convert snippet in c# (uses uint) java. code here: private const int rolling_window = 7; private const int hash_prime = 0x01000193; private unit h1, h2, h3, n; private byte[] window; //... private uint roll_hash(byte c) { h2 -= h1; h2 += (uint)rolling_window * c; h1 += c; h1 -= window[n % rolling_window]; window[n % rolling_window] = c; n++; h3 = (h3 << 5); h3 ^= c; return h1 + h2 + h3; } private static uint sum_hash(byte c, uint h) { h *= hash_prime; h ^= c; return h; } in java use long instead of uint result gives negative values. solution using unsigned operators. searching show me 0xffffffffl quite complicate while deadline coming. wish me in problem. thanks the code same. % operation different. window[(int)((n & 0xffffffffl) % rolling_window)] or write window[n] and if(++n == rolling_window) n = 0; in more detail privat...

xml - How to have the same attribute name reference two different types in the same namespace? -

all xml attributes in different namespace, xsd references them other xsd. have 2 different elements attribute same name, different types. <integer ons:name="10" /> <string ons:name="string"/> so integer element has ons:name attribute integer while string element has ons:name attribute string . how define in xsd? have: <xs:element name="integer"> <xs:complextype> <xs:attribute ref="ons:name" use="required"/> </xs:complextype> </xs:element> then in second xsd ons namespace have following: then problem second element's attribute there no way specify type ref , , if ref references different attribute gets different name. in schema document namespace ons , define 2 singleton attribute groups: <xs:attributegroup name="name-int"> <xs:attribute name="name" type="xs:integer" use="required" form=...

scrolling in uitableview with uitextview -

Image
i have uitableview custom uitableviewcell. hide keyboard user should scroll or down. reach implementing method - (void)scrollviewwillbegindragging:(uiscrollview *)scrollview { if (_isenablehide) { [self resignfirstresponderforvisiblecells]; } } but when cell selected , keyboard on, try scroll strange behavior begins. begins scroll after keyboard disappears , scrollings stops . i want uitableview down keyboard. i try manually animation .... tableview.contentinset = uiedgeinsetszero; tableview.scrollindicatorinsets = uiedgeinsetszero; ..... but after scrolling on tableview stops tableview down , tableview's insets negative keyboarheight. how scroll down tableview , keyboard or cancel auto moving down after scrolls stop make manually. i've solved problem setting self.tableview.scrollenabled no , change after keyboard disappear yes. proper scrolling don't occur after that. solve manually scrolling tableview cgrect rect = self.f...

java - Spring, Hibernate, C3P0 and Jetty -

i inherited project , trying run via jetty:run no avail. works fine using run-war or run-exploded, cant seem nail down issue plain old run. giving me following stack: 2012-06-28 15:02:32.247:info:/:initializing spring root webapplicationcontext warn [main] jdbcexceptionreporter.logexceptions(233) | sql error: 0, sqlstate: null error [main] jdbcexceptionreporter.logexceptions(234) | cannot create poolableconnectionfactory (access denied user 'root'@'localhost' (using password: no)) warn [main] settingsfactory.buildsettings(147) | not obtain connection query metadata org.apache.commons.dbcp.sqlnestedexception: cannot create poolableconnectionfactory (access denied user 'root'@'localhost' (using password: no)) @ org.apache.commons.dbcp.basicdatasource.createdatasource(basicdatasource.java:855) @ org.apache.commons.dbcp.basicdatasource.getconnection(basicdatasource.java:540) @ org.springframework.orm.hibernate3.localdatasourceconnectionpr...

jquery json with arrays with numerical keys -

if have php file outputs json data numerical keys, like <?php $array[1] = "abcd"; $array[2] = "efgh"; $array[3] = "1234"; $array[4] = "5678"; echo json_encode($array); ?> how access value key 4? integer in "data.4" below breaking code. appreciated. thanks! $.ajax({      type: "get",      url: "http://localhost:8888/myapp/json/json_data",      async: false,      beforesend: function(x) {       if(x && x.overridemimetype) {        x.overridemimetype("application/j-son;charset=utf-8");       }  },  datatype: "json",  success: function(data){ //$("#box").html(json.stringify(data, null, 4)); $("#box").append("<br/>" + data.4)  } }); use brackets access property: data['4'] . note: php not returning array, object: {"1":"abcd","2...

iis 7 - Register SSL Bindings with BAT File for IIS7 -

what correct way run bat file following lines? executed them cmd.exe 1 one , worked fine. need run administrator. double click bat file have run instead. appcmd set site /site.name:"assets.test.com" /+bindings.[protocol='https',bindinginformation='*:443:assets.test.com'] appcmd set site /site.name:"api.test.com" /+bindings.[protocol='https',bindinginformation='*:443:api.test.com'] @echo on runas /env /user:<username> <path appcmd> appcmd set site /site.name:"assets.test.com" /+bindings.[protocol='https',bindinginformation='*:443:assets.test.com'] appcmd set site /site.name:"api.test.com" /+bindings.[protocol='https',bindinginformation='*:443:api.test.com'] pause this should work perhaps after insert correct information.

objective c - from within a static function how to place info into iVars? -

and note can not pass in viewcontroller pointer due function being passed function. static int callback(void *notused, int argc, char **argv, char **azcolname) { nsstring *str = @""; int i; for(i=0; i<argc; i++) { printf("%s = %s\n", azcolname[i], argv[i] ? argv[i] : "null"); str = [nsstring stringwithformat:@"%@\n%s = %s\n", str, azcolname[i], argv[i] ? argv[i] : "null"]; } printf("\n"); //tvdisplay uitextview [tvdisplay settext:str]; // <---- ??? how ivar return 0; } the call: rc = sqlite3_exec(db, psql[i], callback, 0, &zerrmsg); callback functions typically have argument allows pass along arbitrary data (it's void * called context or similar). can pass in object need access when set callback function, , retrieve within callback function: static void mycallback(int someresult, void *context) { someclass *someobject = (someclass...

c# - How to calculate the time complexity of this odd method -

the method is: list<book> books = new list<book>(); public list<book> shoot() { foreach(var b in books) { bool find = true; foreach(var otherb in books) { if(otherb != b && otherb.author == b.author) { find = false; } } if(find) { yield return b; } } } normally, time complexity o(books.count^2), there if(find) statement in outer loop , may change loop times. so questions are: what time complexity of method? how did calculate it? i'm waiting online answer. thank in advance. you go through each book in outer loop (n) , each outer book go through each otherb in inner loop (n times) the time complexity o(n^2). the yield return not change complexity of algorithm, creates iterator pattern if traverse whole list calling function, go through iterations in algo. what yield keyword used in c#? to optimize algorithm...

ajax - Play! 2.0 easy fix to OPTIONS response for router catch-all? -

having annoying issues making ajax calls because every browser these days making options call server before actual ajax call. since using play! 2.0, there easy way make wildcard response route using options method? for instance, in routes like: options /* controllers.options.responsedef yes aware new play! doesn't have wildcard built-in, there needs solution since browsers increasingly calling options before ajax calls. not quite wildcard, can use route spans several slash-segments: options /*wholepath controllers.options.responsedef(wholepath) options / controllers.options.responsedef it should match requests: options /a options /a/b options /a/b/c note: that's top of head, maybe you'll need polish it. can't check myself. check section dynamic parts spanning several / of manual.

What is the maximum number of keyspaces in Cassandra? -

what maximum number of keyspaces allowed in cassandra cluster? wiki page on limitations doesn't mention one. there such limit? a keyspace map entry cassandra... can have many have memory for. millions, easily. columnfamilies more expensive, since cassandra reserve minimum of 1mb each cf's memtable: http://www.datastax.com/dev/blog/whats-new-in-cassandra-1-0-performance

windows phone 7 - Binding image based on database id -

i'm using sqlite , have table contains table fields: id , name in project have folder graphics/pictures , there pictures named like: 1.png, 2.png etc. i save records observablecollection , set source listbox. is there chance bind photos each item on list based on id table , name of picture in folder? i have tried smth source="graphic/pictures/{binding id}.png seems bad way. i not sure if works (and not able try right now) use stringformat ( http://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.stringformat.aspx ) or converter ( http://msdn.microsoft.com/en-us/library/system.windows.data.binding.converter.aspx ) returns full path

apache - No ErrorDocument 500 redirect when using with mod_rewrite -

i'm trying make own errordocument 500 page while using web.py framework. the problem errordocument directive not working. have builtin error message instead of custom one. , have "additionally, 500 internal server error error encountered while trying use errordocument handle request" if change errordocument 500 /cgi-bin/error500.py to errordocument 500 "blast! it's 500 error it works fine. also if set rewriteengine off errordocument redirect works correctly. thank suggestions. .htaccess: <files code.py> sethandler wsgi-script options execcgi followsymlinks </files> <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{request_uri} !^(/.*)+code.py/ rewriterule ^(.*)$ code.py/$1 [pt] </ifmodule> errordocument 500 /cgi-bin/error500.py

writing to a file using php ftp -

i'm exporting data, making file , writing data file... my file appears on ftp server, it's empty... here code. //connect ftp server $ftpstream = @ftp_connect('localhost'); //login ftp server $login = @ftp_login($ftpstream, 'some_login', 'some_password'); if($login) { //we connected ftp server. //create temporary file $temp = tmpfile(); //upload temporary file server @ftp_fput($ftpstream, '/httpdocs/itineraryschedule.txt', $temp, ftp_ascii); //make file writable ftp_site($ftpstream,"chmod 0777 /httpdocs/itineraryschedule.txt"); //write file $fp = fopen('var/www/vhosts/cruiseandmaritime.com/httpdocs/itineraryschedule.txt', 'w'); fputs($fp, 'some data'); fclose($fp); //make file writable owner ftp_site($ftpstream,"chmod 0644 /httpdocs/itineraryschedule.txt"); } i'm puzzled ! rich :) get rid of @ see if errors occur also path $fp = fopen('var/www/vhosts/cruiseandmarit...

c# - 3-layer architecture - passing data between layers -

trying implement 3-layer (not: tier, want separate project logically, on 1 machine) architecture i've found many different approaches i'm confused, what's best way (if there's any) make in winforms app. now have no doubts 3 layers should present in project: ui (presentation layer) bll (business logic layer) dal (data acces layer) in ui put winforms. there must logic fill object data controls , pass bll layer. in dal want put classes , methods data manipulations using ado.net, like: public class orderdal { public orderdal() { } public int add(order order) { //...add order database } public int update(order order) { //...update order in database } //...etc. } the problem bll , question - should use data transfer objects pass data between layers, or should pass whole class? if choose use dto , i've create additional common class, order , reference ui, bll , dal: public class or...

iphone - Setting up RestKit in Xcode -

my name marco , trying use restkit in project. im brand new restkit , ios in general, experienced .net programmer. could folks me? the problem can't setup xcode use restkit. says when try compile it: undefined symbols architecture i386: _cgrectisempty", referenced from: -[rkabstracttablecontroller addtooverlayview:modally:] in librestkit.a(rkabstracttablecontroller.o) "_cgrectcontainspoint", referenced from: -[rkabstracttablecontroller resizetableviewforkeyboard:] in librestkit.a(rkabstracttablecontroller.o) "_cgrectzero", referenced from: -[rkabstracttablecontroller initwithtableview:viewcontroller:] in librestkit.a(rkabstracttablecontroller.o) -[rkabstracttablecontroller showimageinoverlay:] in librestkit.a(rkabstracttablecontroller.o) -[rkrefreshgesturerecognizer initwithtarget:action:] in librestkit.a(rkrefreshgesturerecognizer.o) -[rkrefreshtriggerview initwithframe:] in librestkit.a(rkrefreshtriggerview.o) -[rka...

foreach - For each loop in ExpressionEngine template? -

i've created ee plugin function returns array. e.g. function things(){ return array( array( 'name'=>'bob', 'age'=>40 ), array( 'name'=>'mary', 'age'=>50 ) ); } i cannot find way loop through array vanilla ee template tags. can plugins return strings? not possible or overlooking simple? i'd like: {foreach {things} } name: {name} age: {age} {/foreach} your array structured correctly, need use template class' parse variables method . great thing method allows nest many levels deep if (allowing tag pairs within tag pairs within tag pairs), , {count} , {total_results} automatically. so in plugin: function things() { $things = array( array( 'name'=>'bob', 'age'=> '40' ), array( 'name'=>'...

php - Saving multiple rows to database -

i have table unknown number of rows. i'm trying save edits checkbox field, select field , text field. here's sample of table row looks (generalized): <tr onmouseover="this.bgcolor='#eeeeee'"onmouseout="this.bgcolor='#ffffff'"> <input type="hidden" name="batchupdate[][item1]" value="118"> <td><a target="blank" href="www.link.com">link</a></td> <td>name</td> <td><input value="" type="text" name="batchupdate[][item2]" size=35></td> <td> <select name="batchupdate[][item3]"> <optgroup label="group 1"> <option >1</option> <option >2</option> <option >3</option> <option >4</option> <option >5</option> ...

standards - Which is better — hex escaping or octal escaping? -

i writing program outputs arbitrary binary in utf-8 stream. avoid having invalid utf-8, escaping invalid characters. should use hex or octal escaping? that is, should hex ffff escaped this: \xff\xff or this: \377\377 the first python does, second c does. can't decide. [edit] need able handle potentially long strings, this: something something\377\377\377\377\377\377\377\377something vs. something something\xff\xff\xff\xff\xff\xff\xff\xffsomething many times in life, when chosing between equals, getting past choice of more benefit value inherent in options themselves. or, former boss of mine say, "that's non-problem."

c# - ASP.net CheckboxList Inserting to DB -

i have page several checkboxlist controls 4 checkboxes in each of them , i'm trying run insert statement each of checkboxes checked in checkboxlist controls after user hits on submit button. guide how can this? using oledb. you can loop through them this: (int = 0; < checkboxlist1.items.count; i++) { if (checkboxlist1.items[i].selected) { // if item checked } }

jquery - Getting Error #2060 on localhost (jPlayer.swf) -

my problem is: this fiddle working me. but when copy-paste same code (includeing correct paths jquery, jplayer , jplayer.swf) getting error: actionscript error #2060 securityerror: error #2060: naruszenie obszaru izolowanego: element wywołujący externalinterface http://www.jplayer.org/latest/js/jplayer.swf nie może uzyskać dostępu null. @ flash.external::externalinterface$/_evaljs() @ flash.external::externalinterface$/call() @ jplayer/init() @ flash.utils::timer/_timerdispatch() @ flash.utils::timer/tick() why same code work on remote server (like jsfiddle) local file throws error? how can run code on local machine? this how test.html looks like: <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>play shoutcast stream - jsfiddle demo</title> <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs...

javascript - Asian-language characters being messed up through transfer -

ok, have web app uses php, mysql , javascript. in input box, type , if user types in words using korean/chinese/japanese messed up. it appears this: ヘビーローテーション . it uses ajax call , passes through javascript wrapped around in encodeuricomponent() , maybe that's it? don't know. in mysql database shows messed up, too! my charset encoding on webpage iso-8859-1 . help? my charset encoding on webpage iso-8859-1 that won't work. need upgrade utf-8 non-european languages.

algorithm - What is the fastest (realistic) storage implementation to retrieve similar entries? -

i read bk-trees (burkhard-keller-trees) months ago , said method saving stuff want read out again distance-metrics . in each case want retrieve similarity. however, these bk-trees do not seem fast me. when tried implementation , did output, had travel around through tree lot allowed longer distances (i trued levenshtein , allowed 6 edits). the fastest implementation (if it’s speed) of course store distances from each each entry in table , them directly, overhead. thus added realistic in title. okay require more memory , implementation should still realistic , usable (i not know enough such techniques realistic is, guess there border). is there faster bk-trees available or bk top of mountain (yet)? scenario i not have real use-case, scenario follows: have 1 mio entries of , have distance each other (defined distance function). 1 entry , want know either: which 5 entries best match given entry which other entries (independant of number) lower or equal same given t...

c++ - Return value of overloaded << -

#include <iostream> using namespace std; struct info { info(int x, int y) : x(x), y(y) {} int x; int y; }; ostream& operator<<(ostream& out, const info &myinfo){ out << myinfo.x << " " << myinfo.y; return cout; } int main() { info a(1,2); info b(3,4); cout << << " " << b << endl; } the output of above program seems fine incorrect overload of operator << . can tell me effect of overloading problem? know overloading function should return out instead of cout , how above version behave? in case, since passing in std::cout overloaded operator<< , there no difference in behavior. generally, though, cause " " << b << std::endl sent std:cout , while a go whatever passed in. for example: info a(1,2); info b(3,4); std::ostringstream ss; ss << << " " << b << std::endl; would cause ...

php - How do I capture events from multiple dropdown-menus in Twitter Bootstrap? -

i have table contains multiple dropdown menus list of profile images. i've tagged list element db id of photo can perform associated action. i've coded table this: <table class="table table-bordered"> <tbody> <tr> <td><img src="/photos/files/5/m/131309a4fb918110ed1061e90a715eca.jpeg"/></td><td><div class="btn-group"> <a class="btn btn-primary" href="#"><i class="icon-user icon-white"></i> user</a> <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="caret"></span></a> <ul class="dropdown-menu"> <li id="5"><a href="#"><i class="icon-pencil"></i> edit</a></li> <li id="5"><a href="#"><i class="icon-trash"...

iphone - UIImageView animation - using perform selector after delay to display last image in the array -

basically, have uiimageview loop through 8 pngs on 0.5 seconds. @ same time start animation, performselector afterdelay of 0.5 seconds. after uiimageview has finished animating call animationtickdone set last image hidden no. here's code anyway: .h @interface viewcontroller : uiviewcontroller{ iboutlet uiview *scannedview; iboutlet uiimageview *animatedticklast; } @property (nonatomic, retain) iboutlet uiview *scannedview; @property (nonatomic, retain) iboutlet uiimageview *animatedticklast; .m -(void)found{ [self.view addsubview:scannedview]; [animatedticklast sethidden:yes]; //place animated tick images array nsmutablearray *animatedtickimages; animatedtickimages = [[nsmutablearray alloc] init]; nsuinteger nimages = 0; (nimages=0; nimages<8; nimages++){ nsstring *tickimagename = [nsstring stringwithformat:@"tick_%d.png", (nimages + 1)]; [animatedtickimages addobject:[uiim...

c# - APM, EAP and TPL on Socket Programming -

i found difference between […]async , begin[…] .net asynchronous apis question this answer confused me little bit. talking these patterns, stephen said: most *async methods (with corresponding *completed events) using event-based asynchronous pattern. older (but still valid) begin* , end* pattern called asynchronous programming model. the socket class exception rule; *async methods not have corresponding events; it's apm done in way avoid excessive memory allocations. i using *async methods more efficient, @ least when comes sockets. mentioned task parallel library: however, both apm , ebap being replaced more flexible approach based on task parallel library. since tpl can wrap apms easily, older classes not updated directly; extension methods used provide task equivalents old apm methods. i found tpl , traditional .net asynchronous programming on msdn, know basics of tpl, creating tasks, cancellations, continuations, etc still fail understand these: ...

f# - Generalizing a new operator over many types -

i using unquote , did not see approximate comprison. decided write one. let inline (=~=) x y = abs x-y < 1.e-10 however operator not mapped onto, lists let test = [1;2] =~= [1;2] //---> error is possible declare operator flow (=) ? or require define new traits 'structuralequality-ishness"? is better define new operator with, say, http://code.google.com/p/fsharp-typeclasses/ ? i don't know unquote, regarding approximate function/operator i'm not sure if there way implement structural comparison. if want "by hand", using technique (or trick) similar 1 used f# typeclasses project, here example: type approximate = approximate static member inline ($) (approximate, x:^n ) = fun (y:^n) -> float (abs (x-y)) < 1.e-10 static member inline ($) (approximate, x:list< ^n>) = fun (y:list< ^n>) -> x.length = y.length && (list.zip x y |> list.forall ( fun (a,b) -> ...

iis 7 - Access website running in IIS server from Remote machine -

please me out regarding this. running website in iis 7 server, able access local. not able access remote machine. have gone through forums , set permission in windows firewall also. using public ip. same thing working tomcat server, not working iis server. please me.

jquery - koGrid empties our grid instead of updating with KnockoutJS with Asp.Net MVC 3 -

Image
we're working on asp.net mvc 3 + knockout-2.1.0 , we're trying render kogrid have ajax issue (we think) emptying kogrid instead of updating it. in initial state, datasource kogrid array 2 rows, viewmodel (vm): var viewmodel = function() { var self = this; self.radioselectedoptionvalue = ko.observable('-1'); self.availableactiveproducts = ko.mapping.fromjs(availableactiveproductsobject); }; ko.applybindings(new viewmodel()); availableactiveproducts datasource grid. html: <div data-bind="kogrid: { data: availableactiveproducts }" /> and grid renders fine initially: the problem starts here, when radioselectedoptionvalue changes (it radiobutton control change), grid should updated, emptied. we expect radiobutton update/change knockout subscribe function call: self.radioselectedoptionvalue.subscribe(function() { $.get('/salesordermanagement/getproductsbyselection', { typecriteria: "g", id: 1,...

java - Using JAXB with signatures, encryption and encoding -

recently we've been tasked coming xml communication specification our products. few of coworkers have high opinions of jaxb marshalling , unmarshalling xml docs. i've spent time playing around , understand coming from. makes life simple simple xml docs. now take notch. 1 of things see in our communication model "built in" signature validation people use after me. 1 of problems i'm running validate signature need treat corresponding xml bytes. let's take example... <toplevel> <sensitivedata encoding="utf8"> <creditcard> <number>1234-1234-1234-1234</number> <expdate>oct 2020</expdate> </creditcard> </sensitivedata> <signatureofsensitivedata algorithm="sha1withrsa">vghpc0lzqvnpz25hdhvyzq==</signatureofsensitivedata> </toplevel> edit: not passing credit card data. example here. what great if byte[] (determined...

ios - Plugins for Chrome on iPhone -

can tell me if or possible create plugins chrome iphone app. suspect not brilliant if could. i'm sorry don't think there way create plugins chrome ios application. because ... the user has no way organize these plugins in application. the mobile app different full computer application, smaller, , doesn't need have capabilities of full computer application. there isn't way adjust browser settings. you can't download file types mobile browser. i think downloading these plugins device against apples policies, because there not approved apple if ever work, google have offer them in 1 application or have in app purchases unless jail-brake , download full version chrome won't able receive plugins on ios device a developer outside of google can't communicate googles apps there free web browser tutorials out there, instead of creating plugin mobile application, why not create own browser. allow make awesome "plugin-type" too...

Install OpenCV with Cuda support in Macports? -

i tried use macports install opencv 2.4.1 cuda support no luck. the current version of port opencv 2.4.1. can install opencv , compile in xcode, when tried use gpu library, says no gpu support. according thread https://trac.macports.org/ticket/34753 , version 2.4.1 in macports should support cuda somehow, don't it. is there way configure it? thanks in advance. you need osx 10.7.3 , cuda 4.1 (or above).

r - 2 conditions for creating a boolean vector -

i have 2 vectors , single number. a <- rnorm(40,10,4) d <- rep(0,length(a) filling_limit <- 8 now, want 40*1 boolean vector ( has.room ) giving me info if 2 conditions satisfied: has.room <- > 0 && d < filling_limit instead of returning vector 40 times true single true . what's reason this? if wondering 0 vector: thing part of loop , d change within time. thanks! has.room <- > 0 & d < filling_limit from page logical operators: & , && indicate logical , and | , || indicate logical or. the shorter form performs elementwise comparisons in same way arithmetic operators. longer form evaluates left right examining first element of each vector. evaluation proceeds until result determined.

objective c - Using Core Data as a local cache for data retrieved from remote web services -

my project has need cache on ios device data retrieved remote web service. idea view controller ask cache document objects has, example, , in background request refresh web service, returning view controller new document objects received. i'm wondering whether it's possible view controllers use nsfetchedresultscontroller retrieves whatever objects matching criteria can find locally in database, , asynchronously asks data refreshes web service in background. in doing so, nsfetchedresultscontroller update database , of course trigger didchangeobject method of fetchedresultscontroller delegate views can update accordingly. sound reasonable? have suggestions implementing such thing? for our project, ended being able simplify problem quite bit. however, on journey of discovery, came across nsincrementalstore, ticket problem posed in question. gives control on how , cd persists data. here's a nice post it , , an easy-to-understand example . admittedly there's not...

git - Can I generate patch off private commit and send it to maintainer? -

in progit says: if want git try bit more intelligently resolve conflict, can pass -3 option it, makes git attempt three-way merge. option isn’t on default because doesn’t work if commit patch says based on isn’t in repository. if have commit — if patch based on public commit — -3 option smarter applying conflicting patch: and the other advantage of approach history of commits well. although may have legitimate merge issues, know in history work based; proper three-way merge default rather having supply -3 , hope patch generated off public commit have access. so mean can base patch on private commit? wonder sense make lead obvious conflicts while merging because files in commit patch based on on contributor's side differ how files now, how can incorporate them? these things described in progit project maintainer's point of view it's not case contributor base patch on development secret branch. a change can based off private ...

sh - How can I assign command output to a variable in GNU make target rule? -

at bash prompt, can following: ~/repo$ history_log=$(git log $(get_old_version)..$(get_new_version)); [[ ! -z ${histor_log} ]] && ( echo "some header"; echo "${history_log}" ) where git log demonstrably simplified version of have. in make file have following command part of target: $(output): $(input) ... echo "some header" > $(log_file) git log $(shell get_old_version)..$(shell get_new_version) >> $(log_file) how can rewrite make target behave bash command? if following line-feeds being stripped: $(output): $(input) ... history_log="$(shell git log $(shell get_old_version)..$(shell get_new_version))" ; \ [ -z "$${history_log}" ] && \ true || \ (echo "some header" ; echo "$${history_log}" ) when run looks like: ~/repo $ make commit 2b4d87b0e64d129028c1a7a0b46ccde2f42c5e93 author: jamie ...

math - What is the name for this, and how to calculate in Java? -

i'm not mathematical terminology. what called? say have number 48, need find 2 factors make 48. in 48 8,6 in 72 9,8 i don't want 12,4 48, or 12,6 there no particular name pair of factors smallest distance. it's easy calculate if that's want. (at least easy factoring in general goes small numbers it's trivial.) here's 1 way (which fastest when 2 factors close together.) it's based on fermat's factoring algorithm. static int sqrroot(int n){ //find largest square <= n int sqr = 0; (int i=15; >= 0; --i){ int newsqr = sqr + (1<<i); if (newsqr * newsqr <= n) {sqr = newsqr;} } return sqr; } static int[] closestfactors(int n){ if (n <= 0) {throw new illegalargumentexception();} int s = sqrroot(n); if (s*s == n){ int[] ans = {s,s}; return ans; } int = s * s - n; while(s < n){ if (a > 0){ //may not true on first iteration ...

javascript - decodeURI not fully working -

i'm trying remove uri encoding link, decodeuri doesn't seem working. my example link this: /linkout?remoteurl=http%253a%252f%252fsandbox.yoyogames.com%252fgames%252f171985-h-a-m-heroic-armies-marching after running javascript script, looks this: http%3a%2f%2fsandbox.yoyogames.com%2fgames%2f171985-h-a-m-heroic-armies-marching how can rid of remaining not correct codes in uri? my decoding code: var href = $(this).attr('href'); // href var href = decodeuri(href.substring(19)); // remove outgoing part , remove escaping $(this).attr('href', 'http://'+href) // change link on page the url looks encoded twice, suggest use decodeuricomponent decodeuricomponent(decodeuricomponent("http%253a%252f%252fsandbox.yoyogames.com%252fgames%252f171985-h-a-m-heroic-armies-marching")) results in: "http://sandbox.yoyogames.com/games/171985-h-a-m-heroic-armies-marching" but should check why have url encoded ...

asp.net mvc - Interface in Mvc Project, Implementing in Data Project - circular reference? -

i'm developing mvc application practice best practices (trying 'correct' way). more precise, thought of building mvc application ajax endpoints chat service. i wanted have 1 little more flexible, thought of using interfaces define structure of used objects. interfaces should implemented datalayer project. now wanted define interfaces in mvc-project , put datalayer stuff in separate project. lead circular reference though, thought of bad practice. what 'correct' way solve issue? approach reasonable? some code show want archive: mvc project: public interface ichatuser { guid userid { get; } string name { get; } } datalayer project (part of class): public class user : ichatuser { private guid _userid; public guid userid { { return _userid; } } public string name { { return this.lastname + " ," + this.firstname; } } } ...

Include text-editor in rails -

i want use text editor in form on rails 3. best test editor rails. how can use this? please me. a nice , full featured text editor ckeditor . nice , up-to-date gem exists aid integration (it works popular gems asset uploading, paperclip , carrierwave). can have integration info here . hope helps.

sql - Identify open cases for each week during a year -

i trying produce report identifies client cases open during each week of year. have following sql returns clients indicator on whether case open during week 1 of our calendar. client has 2 aspects identifies if case open - mov_start_date , esu_start date should greater end date of period, , mov_end_date/esu_start date should either null or greater start date of period. the below code works, thought copy left join wk1 , rename wk2 return information week 2 i'm getting error relating ambiguously named columns. additionally, i'm guessing having 52 (one each week) left joins on report isn't particularly advisable, again i'm wondering if there better way of achieving this? select a.esu_per_gro_id, a.esu_id, a.status, b.mov_id, b.mov_start_date, b.mov_end_date, a.esu_start_date, a.esu_end_date, ls.cls_desc, nvl2(wk1.prd_period_num,'y','n') "week1" left join b on b.mov_per_gro_id = a.esu_per_gro_id left join ls on ls.cls_code = a.sta...

c# - Timer Skipping ElapsedEvents -

so i'm trying run event every 5 seconds. seems work using system.timers.timer extend seems skipping sometimes, not responding late, plain skipping it. anything this? internal void determinescreencapping() { system.timers.timer screencaptimer = new system.timers.timer(); /// initialize screencapper (doesn't enable yet) // tell timer top when elapses screencaptimer.elapsed += new elapsedeventhandler(executecode); // set go off every 5 seconds screencaptimer.interval = 5000; // , start screencaptimer.enabled = true; } private void executecode(object source, elapsedeventargs e) { if (iscurrentlyworking == true) { execute code } } the problem indeed wasn't timer not doing it's job. code being executed had problems couldn't seen debugging reason. i changed code , timer works ^^ ...

java - Sorting objects by fields subsequently -

the issue sort huge collection of pojo objects class entity{ string key1; string key2; string key3; string key4; } in alphabetical order of fields subsequently. means first sorting key1, key2 , etc. of key can null. question simplest way that. a way append keys together , use comparator<entity> - // keys of entity appended , compared other entity int compare(entity e1, entity e2){ return appendandhandlenull(e1.key1, e1.key2, e1.key3).compareto(appendandhandlenull(e2.key1, e2.key2, e2.key3)); } /** * method keys of entity in appended form */ private static final string appendandhandlenull(string list...){ stringbuilder result = new stringbuilder (); for(string s : list){ result.append(s!=null?s:"").append(" ");//note: space appended after each key } return result.tostring(); } what doing here is..... keys of entity appended in order in comparison need done, , compared other entity. you might nee...

sql server - Query runs in less than a millisecond in SQL, but times out in Entity Framework -

the following linq-to-entities query throws entity framework timeout expired. timeout period elapsed prior completion of operation or server not responding. after tolist()ing it. var q = (from contact in cdb.contacts.where(x => x.templategroepen.any(z => z.autonummer == templategroep.autonummer) && !x.uitschrijvings.any(t => t.templategroep.autonummer == templategroep.autonummer)) select contact.taal).distinct(); ((system.data.objects.objectquery)q).totracestring() gives me: select [distinct1].[taal] [taal] ( select distinct [extent1].[taal] [taal] [dbo].[contactset] [extent1] ( exists (select 1 [c1] [dbo].[templategroepcontact] [extent2] ([extent1].[autonummer] = [extent2].[contacts_autonummer]) , ([extent2].[templategroepen_autonummer] = @p__linq__0) )) , ( not exists (select 1 [c1] [dbo].[uitschrijvingenset] [extent3] ([extent1].[autonummer] = [extent3].[contact_autonummer]) , ([ext...