Posts

Showing posts from June, 2010

algorithm - Find Shortest Path -

Image
there’s m*n grid, filled black , white color. given start point , end point. white points passed, how find shortest path between start , end? any thoughts appreciated. there multiple algorithm matter, of important algorithms : dijkstra bellman ford floyd warshall even bfs algorithms choice.

asp.net mvc - Design | maintainable | conditionals view | MVC -

have view need show address details in view name street state , city, washington now sequence of address needs differ each country china want below format name state , city, washington street so have done written if else statement in view , have format , earlier have no issues 1 or 2 countries but seeing same kind of different request each countries, make view heavy , not maintainable can provide pattern have more maintainable 1 have different partial view each country , load partial view etc ok best option have different views different countries , return them controller based on identifier.this keep code maintainable.for sure dont use if - else. can create multiple partial views each country if not fields dynamically sequenced.keep static ones on main view , dynamic in partial view. now if have far many countries , don't want maintain individual views option create htmlhelper extension , use create view dynamically in code , return mvchtmlstring can use...

Custom json response for internal exception in spring -

while implementing global exception handler in spring, noticed in case of not recognized accept header, spring throw it's own internal error. need return custom json error structure instead. works fine application specific exceptions , totally fails spring httpmediatypenotacceptableexception. this code tells me "failed invoke @exceptionhandler method: public java.util.map restexceptionhandler.springmalformedacceptheaderexception()" when try request page incorrect accept header. other way return custom json spring internal exceptions? @controlleradvice public class restexceptionhandler { @exceptionhandler(value = httpmediatypenotacceptableexception.class) @responsebody public map<string, string> springmalformedacceptheaderexception() { map<string, string> test = new hashmap<string, string>(); test.put("test", "test"); return test; } } eventually figured way json mapping ma...

objective c - Set NSButton enabled based on NSArrayController selection -

Image
ok, i've set nstableview bound nsarraycontroller . now, have nsbutton want make "enabled" when there is selection, , disabled when there nothing selected. so, i'm bind nsbutton 's enabled array controller's selection value transformer of nsisnotnil . however, doesn't seem working. am missing anything? regardless of whether or not selected, selection property of nsarraycontroller returns object ( _nscontrollerproxyobject ). why binding isn't working way expect, because selection never nil . instead, bind selectionindexes , rather selection , , have value transformer called selectionindexescountiszero implemented so: @interface selectionindexescountiszero : nsvaluetransformer @end @implementation selectionindexescountiszero + (class)transformedvalueclass { return [nsnumber class]; } + (bool)allowsreversetransformation { return no; } - (id)transformedvalue:(nsindexset *)value { return [nsnumber numberwithbool:[value co...

javascript - how to use svgz file in html5 and jboss server -

i using html5,jquery , jboss server developing spring j2ee project. using svg file in website.this files big size did compress svg svgz type. have problem loading svgz file in browser. my html code is: <embed width="100%" height="100%" style="opacity: 0.6;" src="${context}/resources/svg/valentines_day_heart_card_vector.svgz" type="image/svg+xml" /> the error is: this page contains following errors: error on line 1 @ column 1: document empty below rendering of page first error. how can solve it? check svg resource url available (that it's not 404) check it's sent correct mediatype, image/svg+xml check it's served content-encoding: gzip http header you might want consider using transfer-encoding: gzip instead, that's you. see e.g https://stackapps.com/questions/916/why-content-encoding-gzip-rather-than-transfer-encoding-gzip .

ruby on rails - Set activerecord model defaults before mass assignment initialize -

i need defaults (from remote service) in modela set before object passed view modelacontroller#new . have used after_initialize this. however, in #create have problem. if use model_b.create_model_a(some_attributes) , attributes passed in during initialization , overwritten after_initialize call: class modela < activerecord::base after_initialize :set_defaults, if: :new_record? def set_defaults self.c = "default" #actually remote call, not can set database default end end class modelb < activerecord::base belongs_to :model_a end class modelacontroller < applicationcontroller #modela nested under modelb in routes.rb #get /model_bs/:model_b_id/model_as/new def new model_b = modelb.find(params[:model_b_id]) #no problem respond_with model_b.build_model_a end #post /model_bs/:model_b_id/model_as def create model_b = modelb.find(params[:id]) #problem: respond_with model_b.create_model_a({c: "not default...

c# - edit in detailsview with dropdownlist -

i new @ asp.net c#. edit detailsview dropdown list. have followed instructions on link -- this link -- , orrigionally thought of. flawed however, because although can see items on dropdown list, not update database. @ loss. have been trying find answer couple of days , unsure of need do. there need in backend? attach code @ end well. have nothing going on in backend. <asp:sqldatasource id="sqldatasource1" runat="server" connectionstring="<%$ connectionstrings:it_supportconnectionstring %>" deletecommand="delete [issues] [issue_id] = @issue_id" insertcommand="insert [issues] ([requestor], [email], [urgency], [issue_type], [details], [priority], [issue_manager], [status], [date_reported]) values (@requestor, @email, @urgency, @issue_type, @details, @priority, @issue_manager, @status, @date_reported)" selectcommand="select issues.issue_id, issues.requestor, issues.email, issues.phone, issues.urgency, i...

c - Debugging Janus using NetBeans -

i'm trying debug new janus plugin using netbeans ide 8.0.1. hits breakpoints ok when trying step through code it's jumping on place , i'm seeing 'optimized out' when trying inspect variables. i'm sure because code has been built optimization enabled. assuming problem, how rebuild optimizations disabled please? i've tried running configure 'cflag=-o0 -g' followed clean & build, i'm still getting same problem. janus configure file has couple of promising looking environment variables, janus_cflags , plugins_cflags. however, when try set these '-o0 -g', clean , make compilation error: fatal error glib.h: no such file or directory any suggestions appreciated. if change compilation make file(not command line), should work make non-optimamized. specifically, line cflags = -g -o2 should changed cflags = -g -o0 . know works gdb(and consequently eclipse) , should work other debugger.

Input on executable file from Python file -

my problem this: working on trying use python interface program (already made fortran) user can introduce input opening program , sending input, never works reason. i import following: import simpleguitk,os subprocess import popen,pipe,stdout using different answers have found around here, have written following: p = popen(['potscat2.exe'],stdin=pipe)#,stdout=pipe,stderr=stdout) p.communicate(str(opmenu[0])+"\n"+str(opmenu[1])+"\n"+str(opmenu[2])+"\n"+str(opmenu[3][0]*pow(10,opmenu[3][1]))+"\n","utf-8") alternatively, there following: p = popen(['potscat2.exe'],stdin=pipe)#,stdout=pipe,stderr=stdout) p.stdin.write(str(opmenu[0])) p.stdin.write(str(opmenu[1])) p.stdin.write(str(opmenu[2])) p.stdin.write(str(opmenu[3][0]*pow(10,opmenu[3][1]))) neither of alternatives works, though. the former gives error: exception in tkinter callback traceback (most recent call last): file "c:\python34\lib\tkint...

sql - SYBASE Nested query not running -

i have procedure writing , contains nested insert nested insert never runs. nested insert's data filled out select statements insert never ran. create procedure search_string #invalue varchar(255) begin set nocount on create table #results (table_name sysname, column_name sysname) select "insert #results select distinct '" + object_name(c.id) + "' table_name, '" + c.name + "' column_name " + object_name(c.id) + " " + c.name + " '%" + @invalue + "%'" syscolumns c, sysobjects o c.usertype in ( 1 ,2 ,18 ,19 ,24 ,25 ,42 ) , o.type ='u' , o.id = o.id , c.length >= datalength(@invalue) select * #results end this yields bunch of insert statements never run. try below code : create procedure search_string #invalue varchar(255) begin ...

javascript - Attaching Parsley.js Validation Library to Form Takes Very Long -

i'm trying out parsley.js validation library, however, when attaching form (which has several thousand input fields ... has multiple lists checkboxes) parsley javascript runs minute goes through fields (even though i've excluded checkboxes): <form id="form" data-parsley-validate data-parsley-excluded="input[type=checkbox]"> is there setting use fix problem since excluding checkboxes doesn't seem help. attach validation individual fields , not whole form? if though i'd have oversee form submission, etc. , manually trigger validation, correct? what's best approach take in situation? the issue parsley iterates through elements match input selector, wraps them in parsley object (which takes bit of time), , only then checks if should excluded. you've seen, quite slow when dealing many elements. to outright ignore checkboxes, can manually override inputs configuration option (either directly in javascript, or via data...

java - Hibernate @ManyToOne @JoinColumn is always null -

i'm trying implement one-to-many relation between 2 tables using hibernate. here code: @entity public class board { @id @column(name = "board_id") @generatedvalue private long id; @column private string owner; @column private string title; @column private string refresh; @column private timestamp createdate; @column private timestamp modifydate; @onetomany(mappedby="board", cascade=cascadetype.all) private list<item> items; public long getid() { return id; } public void setid(long id) { this.id = id; } public string getowner() { return owner; } public void setowner(string owner) { this.owner = owner; } public string gettitle() { return title; } public void settitle(string title) { this.title = title; } public string getrefresh() { return refresh; } public void setrefresh(string refresh) { this.refresh = refresh; } public timestamp getcreatedate() { return createdate; } public void setcreatedate(timestam...

c++ cli - How to convert a handle string to a std::string -

i trying convert handle string normal string. though method using working, when in debugger appears half of string has been chopped off on line creates chars variable. idea why , proper way convert handle string normal string woudl be? std::string convert(string^ s) { const char* chars = (const char*)(system::runtime::interopservices::marshal:: stringtohglobalansi(s)).topointer(); string mynewstring = std::string(chars); return mynewstring; } it's debugger that's cutting off display of string. didn't mention how long string you're using, debugger can't display infinite length, has cut off @ point. to verify this, try printing mynewstring console, or debugger via debug::writeline or outputdebugstring . however, there significant issue in code: after allocating memory stringtohglobalansi , must free using freehglobal . if want continue using stringtohglobalansi , i'd fix this: std::string convert(string^ s) { intpt...

python - OverflowError occurs when using cython with a large int -

python 3.4, windows 10, cython 0.21.1 i'm compiling function c cython def weakchecksum(data): """ generates weak checksum iterable set of bytes. """ cdef long a, b, l = b = 0 l = len(data) in range(l): += data[i] b += (l - i)*data[i] return (b << 16) | a, a, b which produces error: "overflowerror: python int large convert c long" i've tried declaring them unsigned longs. type use work large numbers? if it's large c long there workarounds? if make sure calculations in c (for instance, declare long, , put data element cdefed variable or cast before calculation), won't error. actual results, though, vary depending on platform, depending (potentially) on exact assembly code generated , resulting treatment of overflows. there better algorithms this, @cod3monk3y has noted (look @ "simple checksums" link).

c# - Simple solution to create tree-like structure in html -

i trying create tree-like structure webpage. in case user has set of projects, each project has set of tasks, tasks can have sub-tasks, , sub-tasks can have own sub-tasks. so, looking elegant solution display tree-like structure using html elements in aesthetically pleasing manor. tips or ideas appreciated. follow link - here very explanation. can customize according need.

javascript - How to get value js cookie from vb.net -

i have 1 js cookie: document.cookie = "205_45_single_premium_=; 206_55_single_superior_="; i want value cookie vb.net. try set value js cookie hidden field not success. receive value "undefined". $("input[id$='_txttest']").val(document.cookie); console.log($("input[id$='_txttest']").val()); // receive "undefined" how value js cookie vb.net ?

Clojure : merging two vectors into one map with new keys and values -

i have 2 vectors [:v1 :v2 :v3] [:v1 :v2 :v3], wish create vector in format : [ [:key "v1" :value "v1"] [:key "v2" :value "v2"] [:key "v3" :value "v3"] ] (mapv (fn [k v] [:key (name k) :value (name v)]) [:v1 :v2 :v3] [:v1 :v2 :v3])

excel - Retail decimal rounding conditions using custom rounding rules -

in ms excel trying create retail price according these conditions: if retail price ends between .11 , .36, retail price end in .31 ex: $5.15 = $5.31 if retail price ends between .95 , .00, retail price end in .96 ex: $5.00 = $4.96 , $5.98 = $5.96 how can apply these conditions in excel set of retail prices, looking @ decimal places , having output defined custom/random conditions? you can use formula achieve same: =if(and(mod(c3,1)>=0.11,mod(c3,1)<=0.36),0.31+int(c3),if(and(mod(c3,1)>=0.95,mod(c3,1)<=0.99),0.96+int(c3),if(mod(c3,1)=0,int(c3)-1+0.96,mod(c3,1)+int(c3)))) where, c3 contains retail price.

c# - Why are my datagrid crashing my browser when sorting them -

i have silverlight application , use datagrids in it. my problem (crash) happens whenever i'm sorting datagrid using left click on coloumn header. i've tried debug debugger doesn't stop when crash happens if select exceptions in vs exception options. i tried remove columns one, without format. nothing better. and don't know problem comes (the datagrid, datasource...). so show code think responsible this, i'm not sure if there missing. xmlns:my="clr-namespace:system.windows.controls;assembly=system.windows.controls.data" <riacontrols:domaindatasource x:name="datasource" queryname="getlistcriteres" autoload="false"> <riacontrols:domaindatasource.domaincontext> <domain:domainserviceglobal /> </riacontrols:domaindatasource.domaincontext> </riacontrols:domaindatasource> <my:data...

android - No subscribers registered for event class error - Greenrobot -

Image
i getting warning , code written in event subscriber not triggered always.. random. can me this. thanks. i have class posts event... eventlistadapter : protected void updatedbtohandle(context context, cursor cursor) { //something here.... toggleevent.setcontext(context); eventbus.getdefault().post(toggleevent); } protected void updatedbtoignore(context context, cursor cursor) { //something here.... toggleevent.setcontext(context); eventbus.getdefault().post(toggleevent); } event class : public class toggleevent { private string name; private context context; public string getname() { return name; } public void setname(string name) { this.name = name; } public context getcontext() { return context; } public void setcontext(context context) { this.context = context; } } and the subscriber : public class toggleeventlistener { public toggleeventlistener() { super(); eventbus.getdefault().register(this); ...

validation - Xpages multiple file attachment conflict with partial/full update -

i using multiple file attachment openntf seems it's problem when on same page validation on field (a required field). when click button upload files, error message on validation field. question: how can have kind of "process data without validation" on file uploader? how can javascript? you have 2 possibilities upload files without getting validation error: don't include fields validation partial refresh area set xc:ynuploadfileshtml5 's parameter refreshid select "process data without validation" in custom control ynuploadfileshtml5 's button "refresh"

visual c# express 2010 - XNA Class library -

seems simple task despite google , looking @ menus cannot find how @ documentation of classes or objects in xna. in unity press ctrl , ' is in visual c#/xna? looking information on created classes/objects not online documentation/help. you can search msdn required information. example, here link spritebatch class. the msdn not limited xna, useful tool microsoft based languages. please note of xna documentation not informative. i've come across pages on xna functionality contain 1 or 2 lines - no example code either! what classes people have created , documented? the author of code need provide documentation in code. here example: /// <summary> /// example of xml documentation class. /// </summary> class program { /// <summary> /// example of xml documentation public method. /// </summary> /// <param name="name">the name validating.</param> /// <returns>true if valid, otherwise fa...

android - Changing setConetentView with setOnClickListener causes program to crash (NullPointerException) -

so program worked fine until wanted added "mainmenu". want press button on mainmenu , make go "start_board", basicly made new. if don't give enough information please inform me, i'm new programming. @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.mainmenu); button splaybutton = (button) findviewbyid(r.id.splay); splaybutton.setbackgroundcolor(color.transparent); splaybutton.setonclicklistener(new view.onclicklistener(){ public void onclick(view v) { setcontentview(r.layout.start_board); //code, code , more code } }); } mainmenu xml <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mainmenu" android:layout_width="match_parent" android:layout_height="match_parent" androi...

Why Android Studio rebuilds project so slow even when no changes in sources? -

Image
when make changes in source code, android studio (actually gradle) has rebuild project. it's clear. why second build takes same amount of time first build, if didn't make any changes in project? when gradleconsole waits on "assembledubug" task. think gradle should aware there's no changes , shouldn't waste time on it. finally, found solution: turn on offline work gradle. or using cli: ./gradlew --offline assembledebugorwhatever

performance - How can I make this big nasty query more efficient? -

this postgresql database. have view joining table 15 times create call levels, there doing coalesce function on 'levels'- little manipulation on field, well. pulling description field each of 15 levels. query became sluggishly slow. joining setheadert table multiple levels description field each level. can see have 3 description fields , taking long run. when had 2 took little bit wasn't bad. hope makes sense. code below. on how make more efficient appreciated. select subset_cls, prctr1, case when prctr1 'pc%' split_part( overlay(prctr1 placing '00000' 1 2 ),'.',1) else prctr1 end pctrl2, lvl01, desc01, lvl02, desc02 ( select src.sap_setnode.subset_cls subset_cls, src.sap_setheadert.description desc01, desc_02.description desc02, desc_03.description desc03, src.sap_setnode.set_name lvl01, src.sap_setnode.subset_name lvl02, setnode_1.subset_name lvl03, setnode_2.subset_name lvl04, setnode_3.subset_name lvl05, setnode_4.subset_name l...

cordova - Intel xdk, record a video from the camera in background -

i made search around couldn't find answer that. capture video using intel xdk don't want launch video recording app on foreground, want to: run in background start recording immediately stop recording after given amount of time or function call i tried use https://github.com/apache/cordova-plugin-media-capture navigator.device.capture.capturevideo(capturesuccess, captureerror, {limit:1, duration:10}); opens camera app , user start recording (tried moto g) any suggestion/code sample welcome :)

php - Create a pattern to replace all script sources -

how can create pattern replaces scripts sources in php document string? for example have $haystack = '<script src="oldscript.js"></script>'; and should $haystack = preg_replace('/src="[a-za-z0-9]{1,250}"/', 'myscript.js', $haystack); but not work. doing wrong ? or there way this? you need include dot in regex , add src="..." in replacement: $haystack = preg_replace('/src="[\w.]{1,250}"/', 'src="myscript.js"', $haystack);

Determine who is opening an Excel file on Sharepoint -

i understand "environ" can identify opens file, not know how write code it. i found 1 answer emails via outlook when file opened, ideally logged person's name , time stamped in hidden tab in worksheet or other file. since user not making edits file and/or saving don't know if option. here's code can use. open vbe (alt+f11) double click on "thisworkbook" on in project window spreadsheet , paste in. public declare function getusername lib "advapi32.dll" _ alias "getusernamea" (byval lpbuffer string, nsize long) long private sub workbook_open() 'when worksheet opens, write computer username ' , date , time worksheet of choice ' change "yourhiddensheetnamehere" name of ' hidden tab dim lastrow integer dim hiddensheet worksheet set hiddensheet = sheets("yourhiddensheetnamehere") lastrow = hiddensheet.range("a999999").end(xlup).row ...

c++ - boost::is_nothrow_move_constructible implementation -

i'm giving new vs 2015 preview go, , i'm having trouble boost. after tracing problem, don't understand how ever worked on any compiler. i have unordered_map<k, boost::variant<std::unordered_map<int, std::unique_ptr<t>>>> . fails compile because boost::variant apparently tries copy-construct unordered_map inside it- based on result of boost::is_nothrow_move_constructible trait, indeed boost::false_type . this reveals definition of boost::is_nothrow_move_constructible template <class t> struct is_nothrow_move_constructible_imp{ boost_static_constant(bool, value =( ::boost::type_traits::ice_and< ::boost::type_traits::ice_or< ::boost::has_trivial_move_constructor<t>::value, ::boost::has_nothrow_copy<t>::value >::value, ::boost::type_traits::ice_not< ::boost::is_array<t>::value >::value >::value)); }; er, non-...

How to return an alternate representation of an image in a REST API? -

consider contrived scenario. have resource, foo . when user requests representation of foo resource, return json representation of said resource: get: /foo/1 accept: application/json response: { 'id' : 'foo1', 'datecreated' : '11-12-2014', ... other metadata ... } additionally, can request foo resource accept type of image/png image representation of said resource: get: /foo/1 accept: image/png response: image data what's going on here server side image library reading necessary data construct image , returning response. here question comes in ... i'm needing return data used construct image on server side client. example, let's consider d3.js exists on server side, , i'm building json being fed d3: d3.json('/path/to/my/json', function() { ... }); and renders static image (e.g., pie chart) , returned. return data used construct image d3, if clients want plug json own instance of d3 on client side, can so. ...

linux - Perl 5.8: possible to get any return code from backticks when SIGCHLD in use -

when chld signal handler used in perl, uses of system , backticks send chld signal. system , backticks sub-processes, neither wait nor waitpid seem set $? within signal handler on suse 11 linux. there any way determine return code of backtick command when chld signal handler active? why want this? because want fork(?) , start medium length command , call perl package takes long time produce answer (and executes external commands backticks , checks return code in $?), , know when command finished can take action, such starting second command. (suggestions how accomplish without using sigchld welcome.) since signal handler destroys backtick $? value, package fails. example: use warnings; use strict; use posix ":sys_wait_h"; sub reaper { $signame = shift @_; while (1) { $pid = waitpid(-1, wnohang); last if $pid <= 0; $rc = $?; print "wait()=$pid, rc=$rc\n"; } } $sig{chld} = \&reaper; # system can made work no...

Using Lua libraries from within tup -

i'm using tup replace complicated makefile , i'd call out other lua libraries tup code. in particular. i'd use luafilesystem , yaml generate build rules. however, can't find way load these libraries within tup. in particular, if do local lfs = require "luafilesystem" (or of other traditional variants importing lua scripts), invariably error: attempt call global ' require ' (a nil value) this suggests me tup not support usual lua mechanisms invoking exernal libraries. missing something? i'm using tup v0.7.3-4-g1a8d07e according documentation require not available: "the base functions defined, excluding dofile, loadfile, load, , require." it seems may able implement own "require" based on tup.include , "parses , runs lua file @ path".

python - List index out of range and random number to choose an item in list -

i need make list of iphone models string using .split() . that's not problem, have use random number 0-9 pick word, display 3 random words using while/for loop. in code, when enter: import random iphone = 'original 3g 3gs 4 4s 5 5c 5s 6 6plus'.split() z = 0 while z < 4: y in range (1,3): x in iphone: x = random.randint(0,9) print (iphone[x]) it says: traceback (most recent call last): file "c:\users\zteusa\documents\az_wordlist2.py", line 15, in <module> print (iphone[x]) indexerror: list index out of range i'm not sure whats causing this. both arguments random.randint inclusive: >>> import random >>> random.randint(0, 1) 1 >>> random.randint(0, 1) 0 >>> so, when x = random.randint(0,10) , x equal 10 . list iphone has ten items, means maximum index 9 : >>> iphone = 'original 3g 3gs 4 4s 5 5c 5s 6 6plus'.split...

volume - How to detect android phone ring and vibrate programmatically? -

audiomanager = (audiomanager)getsystemservice(context.audio_service); switch (am.getringermode()) { case audiomanager.ringer_mode_silent: log.i("myapp","silent mode"); break; case audiomanager.ringer_mode_vibrate: log.i("myapp","vibrate mode"); break; case audiomanager.ringer_mode_normal: log.i("myapp","normal mode"); break; } from above code detect 1 mode. want check 2 mode either ring+vibrate or silent+vibrate. how possible? there no method ring+vibrate , silent+vibrate. know have 3 method ringer mode. audiomanager.ringer_mode_normal audiomanager.ringer_mode_silent audiomanager.ringer_mode_vibrate so , have create method check condition both ring , vibrate like ring+vibrate. public boolean statusringvibrate(){ boolean status = false; audiomanager = (audiomanager)getsystemservice(context.audio_service); if(am.getringe...

locationmanager - Android pragmatically get vehicle status -

in application need find vehicle status, can speed of vehicle using location manager many article told getting speed location manager not accurate, can suggest me which method best find vehicle status can use geofence method identify vehicle status all suggestion welcome thanks what mean vehicle status? if mean speed, can following: detect when user in vehicle using activityrecognition detectactivity as detect user moving in vehicle, keep track of location , time . whenever find new location, calculate distance between last location , new 1 using distanceto(location) . calculate time difference. speed @ point distance / time . you can keep repeating every new location find , have speed of vehicle. can read more android locationstrategies .

objective c - Add location to EKEvent IOS Calendar -

Image
how add location not nsstring latitude , longitude ,so shows map in calendar? <ekcalendaritem> https://developer.apple.com/library/ios/documentation/eventkit/reference/ekcalendaritemclassref/index.html#//apple_ref/occ/instp/ekcalendaritem/location @property(nonatomic, copy) nsstring *location; code : ekeventstore *store = [[ekeventstore alloc] init]; [store requestaccesstoentitytype:ekentitytypeevent completion:^(bool granted, nserror *error) { if (!granted) { return; } ekevent *event = [ekevent eventwitheventstore:store]; event.title = @"event title"; event.startdate = [nsdate date]; //today event.enddate = [event.startdate datebyaddingtimeinterval:60*60]; //set 1 hour meeting event.notes=@"note"; event.location=@"eiffel tower,paris"; //how add lat & long / cllocation? event.url=[nsurl urlwithstring:shareurl]; [event setcalendar:[store defaultcalendarfornewevents]]; nserror *err = nil; ...

Cognos displays Text prompt instead of value prompt -

i have list report built using simple sql , not using package, displays 10 records , columns , 'username' 1 of columns (query item). added filter in detailed query expression window [username] = ?user_name? . when report run, should display value prompt (a drop down select value) but, interestingly, cognos shows text prompt. why behavior? please advise how make drop down. what happened here did not explicitly create prompt element filter criterion on prompt page. before cognos executes report checks whether parameters (e.g. ?filtername? ) declared in filters have matching prompt on prompt page. parameters without prompt elements create default 1 (on fly) , apparently chooses easiest possible variant text attribute text box prompt . if want have drop down box have create prompt element dragging value prompt prompt page , follow wizard pop up. make sure choose parameter name have used in filter.

javascript - THREE.js : 2xMeshes using same vector as position -

just did update r67 - r69 in threejs , ends having problems referring positions 1 (same) vector. before did worked: var vector = new three.vector3(50, 50, 50); _mesh1.position = vector; _mesh2.position = vector; which made possible when moved 1 of meshes moved other 1 well. in r69 position vector remains same (aka 0, 0, 0) means have manually set x, y , z coords each mesh whenever mode one. am missing change here? or should fix this? object3d 's position , rotation , quaternion , scale properties immutable. see source code file object3d.js . you can no longer use following pattern: object.position = vector; instead, must use either object.position.set( x, y, z ); or object.position.copy( vector ); three.js r.69

php - How to check data from mysql realtime using ajax post requests? -

how check data mysql realtime using ajax post requests ? i use code check in mysql , if user have new message it's echo you have new message text on realtime. and code post get_data.php every 1 sec , think it's work hard server , client , when try it's not work, how can ? <script type="text/javascript" src="js/jquery-1.4.1.min.js"></script> <form id="idform"/> <input name="uid" value="1234"/> </form> <div id="result_data"></div> <script type="text/javascript"> $(function(){ setinterval(function(){ $.ajax({ type: "post", url: get_data.php, data: $("#idform").serialize(), // serializes form's elements. success: function(data) { $('#result_data').show(); } }); },1000); }); </script> your best...

java - Using custom ObjectFactory with JAXB: is there an established "go to" pattern? -

i understand objectfactory automatically generated when working jaxb 1 might define schema , xml first. however, not way can approach project. i have existing code needs annotated , extended use jaxb use in conjunction rest service. have handful of classes , annotated them already. far understood documentation (i new jaxb), need implementation of objectfactory either package automatic invocation on package level, or multitude of implementations when referred directly rather referred package context. i bit unsure best approach be. if use 1 implementation per package manager rather abstract, instantiating many classes. however, not sure "right" way it. opt separate concerns instantiation separate instances of objectfactory , i.e., have 1 factory per class. hence, implement similar data access object pattern. my engineering background tells me separation of concerns , opting extension on modification better choice. hence, intuition tells me monolithic objectfactory ...

java - NullPointer Exception when getting array size on some devices -

i nullpointer exception when getting size of array. nullpointer exception on device. i have class called exercisestartactivity. here call randomize method. public class exercisestartactivity extends activity{ private exercise currentexercise; private fitnessexercise myexercises; private int exercisenbr; private int maxexercises; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //.. .... .... // initexercise(); } private void initexercise() { exercisenbr = 0; exercise[] exercises = loadexercises(savingdata.getdifficulty()); myexercises = new fitnessexercise(exercises); myexercises.randomize(); maxexercises = myexercises.nbrofexercises(); nextexercise(); } private exercise[] loadexercises(int difficulty) { exercise[] exercise = null; switch(difficulty){ case r.id.radio_easy: exercise = difficultyeasy(); break; case r.i...

opencv - Best Facial Landmark that can be easily extracted from NIR Image? -

Image
i'm playing eye gaze estimation using ir camera. far have detected 2 pupil center points follows: detect face using haar face cascade & set roi face. detect eyes using haar eye cascade & name left & right eye respectively. detect pupil center thresholding eye region & found pupil center. so far i've tried find gaze direction using haar eye boundary region. haar eye rect not showing eye corner points. results poor. then i've tried tried detect eye corner points using gftt, harriscorners & fast since i'm using nir camera eye corner points not visible & cant able exact corner positions.so i'm stuck here! what else best feature can tracked face? heard flandmark think not work in ir captured images. is there feature can extracted face images? here i've attached sample output image. i suggest flandmark, if intuition opposite - i've used in master thesis (which head pose estimation, related topic). , if questio...

asp.net mvc - PagedList in MVC3 showing Error Object reference not set to an instance of an object -

this view @using(@html.beginform("crmbloggrouptype","knowledge",formmethod.get)){ @html.textbox("search") @html.hidden("type", (string)viewbag.type) @html.dropdownlist("pagesize", new list<selectlistitem>() { new selectlistitem () { text="--select page size--" ,value="10",selected=true }, new selectlistitem () { text="view 20 records" ,value="20" }, new selectlistitem () { text="view 50 records" ,value="50" }, new selectlistitem () { text="view 100 records" ,value="100" }, }) <input type="submit" value="search" id="searchbtn" /> <br /> @html.checkbox("name")<text>author name...

regex - how to do "or" in substring matching for bash -

echo `expr "hello" : '\(hi|hello\)'` echo `expr "hi" : '\(hi|hello\)'` obviously i'm trying match "hello" , "hi" regex hello , hi, neither matches. how express properly?? alternately, plain globs case $str in *hi* | *hello*) echo "pleased meet you" esac

java - neo4j ExecutionResult: Extract multiple columns (since javaColumnAs only works once) -

i doing cyper query this: stringbuilderstringlogger logger = new stringbuilderstringlogger(new stringbuilder()); graphdatabaseservice neo4jdb = database.getdatabase(); executionresult result = engine.execute("match (n:person{name:'test'}) match n-[r]->m return n,r,m;"); so want out n, r , m. tried following: node node = iteratorutil.single(result.javacolumnas("n")); relationship relationship = iteratorutil.single(result.javacolumnas("r")); node othernode = iteratorutil.single(result.javacolumnas("m")); now not seem work. fhe first request works, second 1 return empty iterator , therefore null relationship or object. reason is, executionresul lazy iterator. if go through once (like javacolumnas, iterates on it), can not out of afterwards. find explanation: https://groups.google.com/forum/#!searchin/neo4j/javacolumnas/neo4j/oup_2b8maly/sp39sfym9_4j now if way, works correctly. node node = null; relationship relationship =...

c++ - QT5 JSON parsing from QByteArray -

i have qbytearray,contains json {"response": {"count":2, "items":[ {"name":"somename","key":1"}, {"name":"somename","key":1"} ]}} need parse , required data: qjsondocument itemdoc = qjsondocument::fromjson(answer); qjsonobject itemobject = itemdoc.object(); qdebug()<<itemobject; qjsonarray itemarray = itemobject["response"].toarray(); qdebug()<<itemarray; first debug displays contents of qbytearray, recorded in itemobject, second debug not display anything. must parse otherwise,or why method not work? you either need know format, or work out asking object type. why qjsonvalue has functions such isarray, toarray, isbool, tobool, etc. if know format, can this: - // root object qjsondocument itemdoc = qjsondocument::fromjson(answer); qjsonobject rootobject = itemdoc.object(); // response ob...

svn - Recommendations for visual studio package management in the Enterprise -

our development team uses nuget , svn currently. have problems unwanted package restores silently , uncontrolably replaces references in our shared projects. (we have automated build process) can recommend add-ons, tools or proven best-practices or strategies secure management of external references, versioning (and possbly visualization of dependency graphs.) ? we have problems unwanted package restores silently , uncontrolably replaces references in our shared projects i may misunderstand point sounds if saying package restore changes references in project file. seems bug. nuget shouldn't upgrade packages nor touch project files when doing package restore -- should restore exact versions described in packages.config . as far enterprise environments go, don't want build talking on internet nuget.org. can achieve providing nuget.config file removes ambient package sources , provide specific package source points to, say, internal network share. have shar...

windows phone 8 - Disable action center WinJS -

Image
i'm developping winjs application on windows phone 8 , want "disable" action bar. want when touch top of screen doesn't show action bar. saw several games doing : how can html or winjs ? you need 2 things: hide status bar via statusbar.hideasync method disable system overlays via applicationview.suppresssystemoverlays property. you need both things minimize action center popup thing.

Azure Queue, AddMessage then UpdateMessage -

is possible add message azure queue then, in same flow, update or delete message? the idea use queue ensure work gets done - there's worker role monitoring queue. but, web role added message may able make progress toward (and complete) transaction. the worker designed handle double-delivery , reprocessing partially handled messages (from previous, failed worker attempts) - there isn't technical problem here, time inefficiency , superfluous storage transactions. so far seems adding message allows delivery delay, giving web role time, doesn't give pop-receipt seems we'd need update/delete message. missing something? i suggest follow these steps worked me how to: create queue cloudqueueclient object lets reference objects queues. following code creates cloudqueueclient object. code in guide uses storage connection string stored in azure application's service configuration. there other ways create cloudstorageaccount object. see cloudstorageaccoun...