Posts

Showing posts from May, 2013

c# - Explicitly load related entities in many-to-many relationship with Entity Framework over WCF -

i'm using ef 4.1 self-tracking entities in layered application uses wcf hand entities , forth client server. a portion of database contains 3 tables: customer contact customercontacts customercontacts contains 2 primary keys of customer , contact , edm represents navigation properties - customer.contacts , contacts.customers . customercontacts table not represented otherwise in model, meaning there no customercontacts entity, understand , expect feature of edm designer when representing many-to-many relationships of form. the situation have list of customer s bound combobox , wish load related contact s of customer @ point when selected in combobox . put way, wish explicilty load customer.contacts when customer selected in combobox . can't use customer.id in where fetch list of contacts , since there no join entity in model relates them. currently, loading copy of customer , using include("contacts") contact s , setting via selectedcustomer.contacts ...

android - Handle NFC intents only when preference is set -

i've seen several different apps (like nfc taginfo , nfc taginfo nxp ) have option autostart (or show in "select app" list) when tag touched only if option set in preferences, , otherwise seems intent filter totally ignored system. how can done in android application? full answer use <activity-alias> in app's manifest, this: <activity-alias android:name=".activityalias" android:targetactivity=".youractualactivity" android:enabled="false" > <intent-filter> <action android:name="android.nfc.action.ndef_discovered" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity-alias> youractualactivity class want able turn on or off intent filter. not want disable complete activity, use activity-alias in put intent filter want enable (here it's disabled default). in preferenceactivity set listener called when particular setting changed....

confused about Redis and how it will work -

i following article here , think want go hash route confused if have multiple taxi_car <?php $redis->hset("taxi_car", "brand", "toyota"); $redis->hset("taxi_car", "model", "yaris"); $redis->hset("taxi_car", "license number", "ro-01-php"); $redis->hset("taxi_car", "year of fabrication", 2010); $redis->hset("taxi_car", "nr_starts", 0); /* $redis->hmset("taxi_car", array( "brand" => "toyota", "model" => "yaris", "license number" => "ro-01-php", "year of fabrication" => 2010, "nr_stats" => 0) ); */ echo "license number: " . $redis->hget("taxi_car", "license number") . "<br>"; // remove license number $redis->hdel("taxi_car", "license number"); // increment number of...

What happens when an application (desktop/game) hangs or it is forced to be closed, or when electricity fails? -

i've been coding years time ago asked myself question. never saw solved in university. i'm curious this. so, happens talking code, cpu? i'm curious code. for example, if running desktop program , inserting data in data base, happens in scenarios tha mentioned above? mydbconnection cn = new mydbconnection(); cn.start(); cn.begintransaction(); cn.insertdata("insert t_table vavlues(1,2,'white lies')"); cn.insertdata("insert t_table vavlues(1,3,'black lies')"); ------------------------------------------------------------------- enery power off, application hang whatever reason. ------------------------------------------------------------------- cn.insertdata("insert t_table vavlues(1,4,'void lies')"); cn.commit(); cn.close(); what happens after that? nothing? data gets corrupted(according guy know)? there rollback or ram gets free or hanged? os tries restore process? anyone knows procedures endure these accidents? ...

c# - New to programming how to make this code more concise -

hi first question apologies if basic - new programming!!! using c# in mvc trying select object has date property entitymodel context. date selects relevant weight object , on list of "set" objects. the code works , want general guidance on how make code more concise. here code: public actionresult showdiary(string datein) { localtestentities1 dblists = new localtestentities1(); datetime date = convert.todatetime(datein); ienumerable<exercisediary> diary = o in dblists.exercisediaries o.date == date select o; var mydiary = diary.tolist(); exercisediary thediary = mydiary[0]; iqueryable<weight> weights = o in dblists.weights o.diaryid == thediary.id select o; var selectedweight = weights.tolist(); weight weight = selectedweight[0]; ienumerable<set> sets = x in dblists.sets x.weightid == weight.weightid select x; return view(sets); } it seems taking many steps here. know returning 1 object diary. there way object dblists without sending ienumerable? th...

c++ - Windows notifications when hibernation fails -

i'm coding using c++ winapis, , hibernate computer use following call: setsuspendstate(true, null, false); but happens if computer has larger ram array installed hibernation fails. so wondering, windows send notifications if hibernation fails? , if not, how tell if request hibernate failed? looks there's no direct way detect hibernation [ correction: wrong this. see fowl's answer.] until windows 8 (see powerregistersuspendresumenotification ). suppose idle-loop , watch system time. if time jumps forwards, you've hibernated (and resumed!) , if hasn't happened within minute or request failed. think can use gettickcount64 function, insensitive system time changes apparently includes bias time spent sleeping. if doesn't work, use getsystemtimeasfiletime watch wm_timechange messages. you check on system in question whether windows writes event log when hibernation fails. if so, application monitor event log relevant entry. more reliable approach.

rotation - How do you rotate SVG images in processing.js -

i staring processing.js , have been having trouble because every time rotate image changes location on screen. processing seems is, rotate image around point told place it, instead of rotating first around own axis , placing told (which figured cannot done in way/order). this code pshape s; float angle = 0.1; //rads s = loadshape("sensor.svg"); s.rotate(angle); //i change angle manually or clickmouse function isnt shown. void setup(){ size(400,350); framerate(30); //30 frames per seconds } void draw(){ //shape( shape, x, y, width, height); smooth(); fill(153); ellipse(200, 350/2, 100, 100); shape(s, 200, 350/2, 20, 20); ellipse(200, 350/2, 2, 2); } what trying make "sensor" image rotate in correct orientation around circle (ellipse) drew. thats idea. doing neither. maybe having click function rotates svg image around circle. instead rotates around coordinates of shape(image, x_coord, y_coord, width, height) function. if has suggestions, happy! hope question make...

php - action="" not working in WordPress -

i'm trying make custom contact form using custom page template in wordpress. when use <?php echo $_server['php_self']; ?> it goes contact page index page. when leave action empty like action="" it gives me error. can give me insight on this? can post whole page if you'd like. read similar post didn't find solid answer. in advance. use $_server['request_uri'] instead of php_self. wordpress rewrites it's index.php, need post current url , not index.php.

wifi - Is is possible to broadcast a packet with an android phone while not connected to an AP? -

Image
hello have need distress call (packet) needs sent android phone via wifi receiver in promiscuous mode not wifi connected receiving device. have working in traditional fashion connecting access point , making network connection range limited. thoughts more range sending many distress packets , hope receiving end pickup on 1 of them. need 1 way communication. problem current setup once maximum distance reached, wifi disconnects , won't reconnect until half way receiving end. app need work many phones need working solution. ok making work want know if may waisting time due not being possible. thanks, steve wifi - is possible broadcast packet android phone while not connected ap? - stack overflow stack overflow questions developer jobs documentation beta tags users current community help chat stack overflow meta stack overflow communities sign up or log in customize list. more stack exchange communities company ...

c++ - Integer casting in big-endian -

in big-endian machine, if have long variable , cast char , language specification guarantees least significant bits after cast? in other words: long = 50; char b = (char)a; assert(b == 50); /* true? */ i know true little-endian machines, big-endian? ...the value unchanged if can represented in destination type (and bit-field width); otherwise, value implementation-defined. (§4.7/3). since char must able accommodate values @ least 127, result in case must 50.

javascript - call iframe function from parent window -

how call javascript function in ifram parent window. have jsp page contains iframe. jsp page served "a.yenama.net" server , iframe served "b.yenama.net" server. <iframe width="1200" height="640" name="data" id="dataid" > </iframe> <br/> <input type="button" name="data" value="save data" onclick="callsavedata();" /> tried below code parent jsp page , recieved permission denied error in ie window.frames['data'].calldata(); also tried document.getelementbyid('dataid').contentwindow.calldata(); //didn't work function in iframe window.calldata = function(){ alert('iframe function'); } your appreciated. you can declaring function in common .js file therefore, can access function wherever want. have nice day

c# - Crystal Report Is Displaying only one row from datatable which has 10 rows -

i have developed windows application generates report without database using c#. i have added dataset , datatable datasource crystal report. datatable gets minimum of 1 row. when datatable has multiple(like 4,5,10) rows crystal report still displays first row of datatable. i have used breakpoints , validated datatable has multiple rows. i using windows xp service pack 3 (64-bit) os visual studio 2010 professional .net framework 4 crystal report(downloaded sap website last month) thank you please me out maybe put table fields in "page header" or in "report header" section of report. if case, should put fields in "details" section. "detail" section of report repeated each rows in data source.

mysql - ""Duplicate Entry" while inserting in a Composite primary keyed table -

create table if not exists `mytable` ( `machine_no` varchar(50) character set ascii not null, `date` datetime not null, `nature` int(11) default null, `start` time not null, primary key (`machine_no`,`date`), unique key `date` (`date`), unique key `start` (`start`), unique key `start_2` (`start`), unique key `nature` (`nature`) ) engine=innodb default charset=latin1; this table has composite key. when try insert 2 records same date/time different value of machine_no. says duplicate entry date. dont understand reason it. composite key, should duplicate entry in both attributes. your primary key works fine: primary key (`machine_no`,`date`), what causes issue unique key have: unique key `date` (`date`), this not allow 2 rows same datetime inserted. similarly other 3 unique keys cause torubles well: unique key `start` (`start`), unique key `start_2` (`start`), unique key `nature` (`nature`) so, make keys simple (not unique). and there no reason have 2 identical keys diff...

objective c - Quartz Core. Solid colored rectangle and gradient colored circle on the same path -

i believe subj possible. if yes, how it? if not, how set specific color on specific path? thanks. edit: ok. deleted confusing part of message. a gradient coloured circle not drawn path, path used clip context , gradient drawn separately. think of path drawn in single action, single colour - answer question no.

ssl - Java - is it possible to verify a particular "hardcoded" self-signed certificate by fingerprint, and ignore hostname matches? -

this continuation of this question (decided make separate in case in future looking similar problem) basically, set applet , servlet communicating. servlet's cert self-signed , hardcoded applet. now, let's go "make truststore in memory, import hardcoded cert it" route. problem: servlet's ip/hostname subject change without warning how 1 go making applet doesn't verify hostname particular cert, still checks other things, such fingerprint , such? additional considerations: i'd rather avoid having applet loose ability verify hostnames other certificates. i'd avoid browser popups , pleads user input when dealing "hardcoded" cert (we put there ourselves, of course trust ^_^) thank kind help. hostname checking happens on https. if you're using ssl directly, don't have problem.

iphone - Unknown class CPTGraphHostingView in Interface Builder file -

i'm using new core plot version. i'm stuck in error. googled , went through many same question on stackoverflow, didn't find solution. want draw bar chart, have done necessary setting , coding require display bar chart, got stuck in error. have checked cptgraphhostingview on view on xib side. did other linker flag seting , wrote barchartview.hostedgraph = barchart. target memembership option checked. please let me know if i'm missing anything. provided have setup right core plot header files , core-plot library included in project. here did fix problem. in target build settings , set linker flags to: -objc -force_load "core plot library name" -all_load not needed if using 4.2+ version. the reason -force_load -all_loa d trying compile other libraries had in project.