Posts

Showing posts from January, 2012

c++ - luabind: cannot access global variable -

i have c++ class want give access in lua script through global variable, when try use following error: terminate called after throwing instance of 'luabind::error' what(): lua runtime error baz.lua:3: attempt index global 'foo' (a nil value)aborted (core dumped) my lua script (baz.lua) looks this: -- baz.lua frames = 0 bar = foo:createbar() function baz() frames = frames + 1 bar:settext("frame: " .. frames) end and i'm made simple , short (as could) main.cpp recreates problem: #include <memory> #include <iostream> extern "c" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } #include <boost/ref.hpp> #include <luabind/luabind.hpp> class bar { public: static void init(lua_state *l) { using luabind::module; using luabind::class_; module(l) [ class_<bar>("bar") .def("settext", &bar::settext)

excel - Converting the VBA script into .exe file -

is there way or tool convert vba script .exe file. ex: click on .exe file. macro should run automatically , should work in similar way run manually excel macros. your inputs helpful. just create vbs file. it same language (vbs , vba) 'translation' should easy. you can easier creating vbs file opens workbook , runs macro inside workbook. the file : dim xlapp dim wb dim ws set xlapp = createobject("excel.application") xlapp.visible = true path = "mypath" set wb = xlapp.workbooks.open(path & "myworkbookname") set ws = wb.sheets("mysheetname") wb.application.run "module1.macro1" wb.close

Executing Dynamic Sql query in Oracle -

i have select query in have a dynamic where condition. thing when try concatenate where condition parameter sql query not allowing me save procedure . eg: create procedure usp_mysearchquery ( qtype in int, out_cur out sys_refcursor ) dyn_query varchar2; begin if qtype=1 dyn_query :=' between 1 , 2'; else dyn_query :='=10'; end if; open out_cur select * mytable type=qtype , id || dyn_query; end; this how procedure looks like. tried execute immediete in documentation itself, written wont work multiple row query. in mssql have exec (not sure) command can execute text sent command. in same way have commands can run dynamic query in oracle update: answer i tried this. open out_cur ' select * mytable type=:qtype , id ' || dyn_query using qtype; and worked the dynamic string has enclosed within 'single quotes' open out_cur 'select * mytable id

java - Granting URL Permission in policy file in JAAS -

i have made rest application working fine on own. import javax.ws.rs.get; import javax.ws.rs.path; @path("/helloworld") public class helloworldresource { @get public string getmessage() { return "hello world!"; } } i want invoke client using jaas.there 2 principals namely userprincipal , systemadminprincipal.i want invoke web service when principal systemadminprincipal.i using urlpermission grant permission , apache httpclient execute method. policy file is grant principal userprincipal "user" { }; grant principal sysadminprincipal "sysadmin" { permission java.net.urlpermission "http://localhost:8080/helloworldrest/helloworld","get"; }; but encountering security exception systemadminprincipal.probably usage of urlpermission faulty case.could point how use urlpermission.thanks in advance. the policy file should grant socket permission prior granting urlpermission .the pol

jquery - How to get the previous text value of a div by clicking a html item? -

Image
in image below html code: and js code: $(".salveazatransasuma").click(function(){ var payment_name = $(this).siblings().previous(".transacontentedit").text(); alert(payment_name); }); so want text value transacontentedit class, when click on salveazatransa class. don't worry white spaces before , after text value ("servicii programare transa 1"). appearantly code doesn't work. gives me error in firebug "typeerror: $(...).siblings(...).previous not function". idea how hande ? based on image, can use: $(".salveazatransasuma").click(function(){ var payment_name = $(this).closest('.litransa').prev().find(".transacontentedit").text(); alert(payment_name); });

android - Which one is better in _ID and LOOKUP_KEY and the reason -

i want search contact list particular contact using _id or lookup_key. 1 of these 2 better , reason. helpful if give main differences of both. android doc says- _id - row id. consider using lookup_key instead. lookup_key - opaque value contains hints on how find contact if row id changed result of sync or aggregation. so when in case contacts rowid change reason lookup_key our way go. check this link on how find not there on docs guess.

c# - Linq date to weeks: google visualisation line chart JSON format -

i have data returned in format: | name | weeklytotal | weekend | name1 | 2 | 2014-03-07 name2 | 4 | 2014-01-03 name1 | 3 | 2014-02-28 name3 | 3 | 2014-03-07 etc. trying project data on chart, using google visualization. need linq statement group data object like: week1 => { name1 = 2, name2 = 0, name3 = 3} basically, each week, return object weekly totals each name on list. have not idea of how going approach this.

database - Set Witness server on Principal got error -

i setting database mirroring, here model: pricipal database instance in server1 mirror database instance in server2 witness database instance in server2 i setting mirroring certificate, ok when set principal , mirror see together. but when add witness principal, got error: "the alter database command not sent remote server instance 'tcp://xxx:5024'. database mirroring configuration not changed. verify server connected, , try again." notice setting correct certificate principal, mirror , witness , principal can telnet witness via 5024 port. i have been searching on internet 2 weeks seems there no complete answer. i spent 1 day figure out issue , thread trouble setting witness in sql server mirroring scheme w/ error saved me. my problem witness server not see principal server. went through windows event in witness server , see this: the mirroring connection "tcp://xx:6022" has timed out database "xxx" after 10 secon

jboss - @PreUpdate never fired in Wildfly 8 / JPA 2.1 -

i experiencing strange effect, @preupdate hook never fires. code: @prepersist @preupdate public void prepersist() { if (getcreated() == null) { setcreated(new date()); setcreatedby(loginholder.getuser()); } setlastmodified(new date()); setmodifiedby(loginholder.getuser()); } although hibernate logs update (existing) entity, @prepersist fires on new items. have missed something?

c# - How can I know required data for later steps in SpecFlow? -

my problem following: some of scenarios need save state of model after loaded compare later. serializing objects , compare them later in test. not want serialize state in every test - have negative impact on performance of tests. how can know if data necessary? i thought of using tags, information should hidden feature file. not want forced write @saveinitialstate on every test need it. edit here 1 sample test needs information given have loaded model when action , undo last action loaded model unchanged serialization here chosen way because model has no possibility cloned , not want introduce new production code tests. serialization can done in tests only. you might trying wrong kind of testing here or @ least use wrong tool kind of testing. specflow tool designed in commonly known bdd more accurately called specification example . basic idea of provide concrete examples of interesting cases test functionality of application. these examples need explic

ios - Search Controller issue -

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath** { static nsstring *cellidentifier = @"tablecell"; tablecell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];** // configure cell... int row = [indexpath row]; cell.titlelabel.text = _title[row]; cell.descriptionlabel.text = _description[row]; cell.feeschedule.text = _fschedule[row]; cell.nonfs.text = _nonfeeschedule[row]; cell.thumbimage.image = [uiimage imagenamed:_images[row]]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } cell.textlabel.text = [medicalcodes objectatindex:indexpath.row]; return cell; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } if (tableview == self.searchdi

Tracking global definitions in LLVM -

i trying manually build list of instructions particular variable getting assigned value in llvm ir. for local variables in function, can right set of instructions using instruction iterator , checking operands of particular instruction. approach doesn't seem work global variables since there's no store instruction associated them. is there way keep track of global variable being defined without looking @ metadata field? if not, there way create dummy instruction can treated special marker initial definition of global variables? for local variables in function, can right set of instructions using instruction iterator , checking operands of particular instruction. that's not entirely accurate. it's true long variable in memory (and assignment done via store ), if promoted registers you'll need rely on llvm.dbg.value calls track assignments it. this approach doesn't seem work global variables since there's no store instruction asso

date - Puts Hash in Ruby -

i have hash, , want print it: {:date=>#<date: 2013-03-29 ((2456381j,0s,0n),+0s,2299161j)>, :name=>"karfreitag", :regions=>[:de]} {:date=>#<date: 2013-04-01 ((2456384j,0s,0n),+0s,2299161j)>, :name=>"ostermontag", :regions=>[:de]} {:date=>#<date: 2013-05-01 ((2456414j,0s,0n),+0s,2299161j)>, :name=>"tag der arbeit", :regions=>[:de]} i tried with: def print_holiday(a) a.each |date| puts date["name"] + " " + date["date"] end end but empty lines. got ideas? i'm using holidays gem. a string not symbol. keys in hash symbols, you're trying access values through strings. try this: puts date[:name] + " " + date[:date] the difference between ruby symbols , strings

jquery - Javascript have to click button twice which is outside the form -

Image
hi facing problem on button click. have button outside form due reason. on click have validate form , proceed next tab. right have click twice button if form valid. what's issue right now? script.js <script> $(document).ready(function () { $('#step-2-form').submit(function(e) { var $as = $(this); if($as.valid()){ e.preventdefault(); $('#dgstonevariable').edatagrid('reload'); return document.getelementbyid('n.3').click(); } if(!$as.valid()){ } }); $('#step-2-form').validate({ rules: { contactname2field: { required: true }, jobtitle2field: { required: true }, telephone2field: { required: true }, email2field: { email: true, required: true }, cityfield: { required: true } }

Getting all combinations which sum up to 100 using R -

i need combinations sum equal 100 using 8 variables take value 0 100 incremental step of 10. (i.e. 0, 10, 20 ... 100) the following script inefficient creates huge dataset , wondering if had better way of doing this. x <- expand.grid("on" = seq (0,100,10), "3m" = seq(0,100,10), "6m" = seq(0,100,10), "1y" = seq(0,100,10), "2y" = seq(0,100,10), "5y" = seq(0,100,10), "10y" = seq(0,100,10), "15y" = seq(0,100,10)) x <- x[rowsums(x)==100,] edit -- to answer question stéphane laurent the result should like on 3m 6m 1y 2y 5y 10y 15y 100 0 0 0 0 0 0 0 90 10 0 0 0 0 0 0 80 20 0 0 0 0 0 0 70 30 0 0 0 0 0 0 60 40 0 0 0 0 0 0 50 50 0 0 0 0 0 0 (...) 0 0 0 0 0 0 10 90 0 0 0 0 0 0 0 100 followed stéphane laurent's answer, able super fast

Alfresco CMIS parents query returning unexpected empty result -

context the cmis parent operation allows 1 full path(s) of object id. instance, give /alfresco/service/cmis/s/versionstore:version2store/i/2f4cbf7a-0f8e-4fa1-81e5-8be69eb0532e , /sites/swsdp/documentlibrary/presentations . i have alfresco community 4.2.e server. not sure if relevant purely out-of-the-box except enabled changelog : audit.enabled=true audit.alfresco-access.enabled=true audit.cmischangelog.enabled=true what occurs when run "parent" cmis request below, response below contains 0 atom entries: get /alfresco/service/cmis/s/versionstore:version2store/i/2f4cbf7a-0f8e-4fa1-81e5-8be69eb0532e/parents?includeallowableactions=false&includerelationships=none&includerelativepathsegment=true http/1.1 user-agent: apache chemistry dotcmis authorization: basic ywrtaw46ywrtaw4= host: 192.168.0.66:8080 connection: keep-alive http/1.1 200 ok server: apache-coyote/1.1 cache-control: no-cache expires: thu, 01 jan 1970 00:00:00 gmt pragma: no-cache conten

Performance and efficiency comparing between dump tools: tcpdump, tshark, dumpcap -

i'm capturing tcp/udp packets through network adapter , trying analyze packets statistical indicator such bandwidth rate or protocol efficiency. anyway need monitor network traffic on specific link (src, dst, port, overall traffic) using cli tools. my desired capturing tool can be: ran long time monitor large file transferring; ran several instances @ same time monitor different links; (don't want complex filter rules); able write data on disk, , don't want io operation affect capturing , other process much, binary file ok, long can dumped tshark. now i'm aware of tshark, tcpdump(currently use it) , dumpcap, don't know performance difference among these tools. can help? some experiments done while working on tpacket_v3 support in libpcap found that, currently, tcpdump drops fewer packets dumpcap. (we'd fix dumpcap better.) tshark runs dumpcap, it's not going better dumpcap.

c# - WCF Json serialization with service reference not updated -

we facing serious issue, before saying it's bug in .net, i'd know if understand what's happening , why. that's our configuration : 1 project dal 1 project proxy many others project use dal wcf services well. communicate wcf services. we have added properties in 1 object in dal havn't updated service references in proxy project. (1)in proxy breakpoint, can see retrieved except of course new properties (service reference not updated => nothing abnormal) the proxy returning json webmessageformat.json ( using default provided serialization) the response of method called in proxy call (1) 1 in dal empty. so it's problem in json serialization ? no ? worst, decided changed webmessageformat.json webmessageformat.xml see if same happened, ==> didn't last thing, no problem other projects hadn't been updated (they not using json ser) does have faced same issue, or know why happening ? any nice :) thanks in advance , sorry english.

php - Rewrite rule with exception -

here directory structure main site:- www.magentosite.com wordpress site:- www.magentosite.com/wordpresssite and here htaccess rule redirect. if user goes wordpress site redirect magentosite. rewritecond %{request_uri} !^wordpressite/ rewriterule .? http://www.magentosite.com/ [l] problem above should work want put if user goes admin side of wordpress yes should not redirect. in short www.magentosite.com/wordpresssite/wp-admin/... should not redirect. the below code should go inside .htaccess on wordpress folder: options +followsymlinks -multiviews rewriteengine on rewritecond %{request_uri} !^/wordpresssite/(wp-login\.php|wp-admin) [nc] rewriterule ^ http://www.magentosite.com/ [r=302,l] basically doing if url start with: www.magentosite.com/wordpresssite/wp-login.php or starts with: www.magentosite.com/wordpresssite/wp-admin it should not redirect , if doesn't redirects .

Is it possible to run rails console commands in ruby controller/view and display the output -

example want create dropdown of commands in admin section. when user selects one, such purchase.all user.where(:active => 1) basically common commands run in console before functional backend created. know bit unconventional im looking rapid way make common admin queries available. once command has been run i'd display exact output displayed in rails console. i've installed hirb gem formats results in console , formatting show when output in view. @ achievable? of course possible, run command in action, render hirb , pass output view: def action result = run_command(params[:command]) hirb::view.load_config hirb::view.render_method = lambda { |output| @hirb_output = output } hirb::view.render_output(result) end private def run_command(command) case command when 'purchase_all' purchase.all when 'active_users' user.where(:active => 1) end end and in view: <pre> <%= @hirb_output %> </pre>

javascript - Display file name from input type file - console.log(fileName) return null -

i'm trying display file name input type file. this code: <input id="id_file_field" name="file_field" type="file" style="display:none" /> here jquery: $(document).ready(function () { $("#upload_file").click(function () { $("#id_file_field").trigger('click'); var path = $("#id_file_field").val(); var filename = path.match(/[^\/\\]+$/); console.log(filename); }); }); why console.log(filename) return null ? you need wait change event $(document).ready(function () { $("#upload_file").click(function () { $("#id_file_field").trigger('click'); }); $('#id_file_field').change(function () { var value = this.value; var filename = typeof value == 'string' ? value.match(/[^\/\\]+$/)[0] : value[0] console.log(filename); }) }); demo: fiddle

javascript - Getting an input's current value in a keypress event in angularjs -

i'm trying add dirty class input while user typing. i'v created directive binds keydown event , checks value against last saved one. elm.bind('keydown', function(event) { if (event.which === 13) scope.update(); else if ( scope.last_saved_value !== elm.val() ) elm.addclass('dirty-input'); }); jsbin full example to see problem, change value in input , press enter. works fine. now, add number , you'll see field not become dirty , event capturing previous value , not current. guess elm.val() \ model.$viewvalue being updated after event taken care of (to allow manipulation on value). so how can capture current value on keydown ?

python - How can I plot hysteresis in matplotlib? -

Image
i trying plot development of pitchfork bifurcation on time. relationship between x , y starts off approximately linear, ends being sigmoidal s shape. final relationship not function; there multiple y values values of x . matplotlib nice wire frames surface plots, these surface plots don't seem able handle non-functions. there way of plotting surface of relationship? (if possible don't want solid shape.) at moment data in 0 arrays 1 s indicate approximation location of surface. i've included small sample data set, , sample code plot of location. how 'join dots'? actual data sets larger (500x200x200) , varied, need develop flexible system. this final figure might like: from reading mplot3d documentation here seems may need convert data 2d arrays. if case please provide method this, , if possible please tell me these arrays represent. i appreciate comment/suggestions advance this. import numpy np mpl_toolkits.mplot3d import axes3d import mat

knitr - error: R code interpreted as math formula in LyX -

i type code in lyx: <<>>= data$y <- data$x @ this code makes error, because "$$" makes content inside them interpreted math formula. there anyway contour problem? put code in tex box. this, highlight of text , go insert > tex code (default shortcut ctrl + l). if happen using lyx 2.1 beta, go > specific manuals > knitr see example. don't forget must have module loaded. this, go document > settings > modules

performance - Pagination and sorting large amount of data -

i wondering how implement sorting , pagination mechanism in application using tabular display of data. let's assume have entity id , description. there many instances of them in database. sort alphabetically description. want have result fast. possible without getting database of records, sorting them , displaying part of them? best (from performance point of view) approach problem? my question rather hypothetical , not pertain particular language or framework. it can done in 2 passes the first 1 returns id s of entity sorted whatever criteria. list of id s saved in memory. the second 1 takes 1 page, i.e. sublist of id s , fetches whole entities database presentation.

ios - Adding action to custom uiview -

i have been trying simple thing : adding action simple custom view. have looked on internet , found 2 "easy" solution : uitapgesturerecognizer uibutton i want programmatically , need handle tap. here code far, i've tried both solutions separately , , doesn't work ! .m #import "areaview.h" @implementation areaview #define grey 27.0/255.0 #define pink_r 252.0/255.0 #define pink_g 47.0/255.0 #define pink_b 99.0/255.0 - (id) initwithframe:(cgrect)frame imagename:(nsstring *)imagename areaname:(nsstring *)areaname minimumspending:(int)minimumspending andcapacity:(int)capacity { self = [self initwithframe:frame]; if (self) { self.backgroundcolor = [uicolor colorwithred:grey green:grey blue:grey alpha:1]; self.userinteractionenabled=yes; //init variables _areaname=areaname; _capacity=capacity; _minimumspending=minimumspending; //image view _logoimageview = [[uiimageview alloc

r - strange result with shortest.path in igraph -

i have small connected network obtained with: m<-induced.subgraph(g, v(g)[village=="sar"]) here's summary, 6 nodes , 30 links, connected directed network: igraph dnwb 6 30 -- attr: id (v/n), name (v/c), village (v/c), religion (v/c), adoption.lag (v/n), type (v/c), shape (v/c), size (v/n), color (v/c), dist (v/n), dist.sar (v/n), weight (e/n) when run this, got surprising result: >shortest.paths(m) b c d e f 0 3 3 3 3 3 b 3 0 3 3 3 3 c 3 3 0 3 3 3 d 3 3 3 0 3 3 e 3 3 3 3 0 3 f 3 3 3 3 3 0 the network directed, 6 nodes , 30 links every node linked else: shouldn't shortest paths values 1? comments. t

cmd - How many JVM instances will create when we issue java command in different command prompts? -

can please tell me how many jvm instances created when issue following commands in different commands. - command 1: c:\java -xms32m -xmx512m -xss254k accountsalary - command 2: d:\java -xms32m -xmx512m -xss254k accountsalary - command 3: c:\java -xms32m -xmx512m -xss254k accountsalary whether use save jvm heap size or each java process different heap size? each time run java command, create new jvm instances. (and each jvm instance distinct process .) so, in example, number of jvm instances 3. jvm instances not share heaps. each 1 have own heap. there no saving of heap space creating multiple heaps. (in fact use more heap space creating multiple jvms ... compared running 3 instance of application in same jvm using multi-threading.) the heap sizes independent. determined individual jvms' command line options ... with jvms, memory shared between jvm instances read-only segment containing jvm code, , (possibly) shared native libraries. historicall

java - How to show a JFrame after another one closed? -

Image
let's have 2 forms such a.java , b.java . there button inside a.java creates b object,hides , opens b.java . want show a.java again after close b.java . give me simple example situation? edit: let me give example situation. have chart this: when click 1 of values, new piechart pops up, gives detailed information value. can numbers of values opening new jframes. so, think jtabbedpane can't solve problem. this perfect situation cardlayout , panels "layered" , can navigate through them using methods show() , previous() , next() see more @ how use cardlayout you can see simple example here , if happen using netbeans gui builder can see how use cardlayout diesign view here also see the use of multiple jframes, good/bad practice? . popular answer no. cardlayout seems fit bill situation.

javascript - why qtip tool tip is not showing pop up on first click ,from second click its showing the tool tip -

Image
updated question :: working left click on node ,inaddtion right click should work us..on right click-->properties,pop shpuld displyed on actual node not on right click menu..as shown below ..when click right click on node,i right click menu !when click view properties pop should displayed on nodenot on right click menu i have 10-15 nodes in layout,all nodes dynamic,on click of each node ajax call needs made , results of ajax results needs shown using qtip tool tip.below code of .on first click not showing pop seconf click showing tool tip.why not showing pop on first click????? var str = "#jp"+ nodeid; $(str).qtip({ content: { text: 'loading...', ajax: { url: 'url', datatype : 'text', type: 'get', // post or data: {}, // data pass along request success: function(data, status) { alert(da

Android 4.4.2 - Youtube webview plays only the sound of the video -

i'm writing application , in activity there webview youtube video or channel. worked until upgraded phone android 4.4.2 kitkat. plays sound of video. webview: webview web_video = (webview) findviewbyid(r.id.web_video); websettings websettings = web_video.getsettings(); websettings.setjavascriptenabled(true); web_video.setwebviewclient(new callback()); web_video.setwebchromeclient(new webchromeclient() { @override public void onprogresschanged(webview view, int newprogress) { super.onprogresschanged(view, newprogress); if(newprogress==100){ loading.dismiss(); } } }); web_video.loadurl("http://www.youtube.com/watch?v=rc0ayg9jj9i"); anyone know problem? please check notes in google developer page changed webview behaviour. suspect custom url handling causing problem. the webview implementation changed in 4.4 webkit base chrome base. http://developer.android.com/guide/webapps/migrating

javascript - Rotatable 3D model in web page -

i have quite bit of quandary: i want create 3d model of human body, embed in web page , give user ability rotate it. i have considered few modelling libraries, css, svg etc (i've never used html5 canvas) honest not sure if possible. also - if above possible then possible manipulate joints eg bring knee or elbow in? my main thought building models in svg , having model rotate in steps of 36 degrees via javascript , may possible manipulate joints there. i willing learn new languages if need be. thanks in advance , hope can me. if tell me it's not possible. john hard , beautiful way: threejs. http://threejs.org/ easy way: create image each frame set background in container , change background-position accordingly (this allow rotate on 1 axis only, , no joints manipulation). i suggest learn threejs (if have enough time) examples great , it's not hard. browser support plays big role in choice, threejs uses canvas, it's pretty new feature. use

c# - How to create a windows application that will read/edit different excel files? -

my goal create simple (one file) executable windows environment open pretty simple form. form read data excel files , after user fills out form , submit - application write data different excel file. this used different users in shared drive. have programming experience c/c++/c#/.net/python , other languages never created windows program. any ideas should start? (a relevant tutorial appreciated) thanks! to read , edit excel files microsoft office interop libraries: class library documentation available here . regarding tutorials, best approach search web , see can find. couple found are: c# excel interop: http://www.dotnetperls.com/excel how automate microsoft excel microsoft visual c#.net: http://support.microsoft.com/kb/302084 good luck! :)

Learning how to parse strings and use structs in C -

i'm trying mess around structs , pointers in c. want accomplish user enter date in format dd-mm-yyyy in main(), parse string formatted_date. i've read few suggestions on how don't understand how apply it. appreciated. thanks! #ifndef date_h_ #define date_h_ // define structure date. typedef struct { int tm_mday; int tm_month; int tm_year; } date; // parses string 'formatted_date' representing date // in format dd-mm-yyyy, dd.mm.yyyy or dd/mm/yyyy // structure date 'parsed_date'. void parse_formatted_date(char * formatted_date, date * parsed_date) { } you use sscanf() parse formated date string this: int parse_formatted_date(const char *formatted_date, date *parsed_date) { const int ret = sscanf(formatted_date, "%d-%d-%d", &parsed_date->tm_mday, &parsed_date->tm_month, &parsed_date->tm_year); return ret == 3; } here full test program: #include

MS Access crashes on error -

i wrote little sql command correct field in table, since small (and maybe got little arrogant) didnt run once , put update package different user. dim sql string dim rs dao.recordset on error goto errhandler sql = "update table1 set name = 'calender' name = 'clalender'" currentdb.execute errhandler: exit sub thats why didnt notice should have been currentdb.execute (sql) when user startet command access said "critical error" , closed. how come errorhandling didnt catch error? , why didnt access tell me there missing when wrote it? quite pedantic that. thanks the statement currentdb.execute will not compile. compile error: argument not optional. your victim ;) must have hit error when tried run code, triggered "on-the-fly" compilation. error trapping in code not handle because code never got chance run (because wouldn't compile). in other words, access would have gotten pedantic on if had tried

c++ - Qt paintEvent() unnormally triggered -

i'm qt beginner. so have mainwindow qslider , qpixmap . redefined paintevent( qpaintevent* event ) , connect( slider, signal(valuechanged(int)), this, slot(centerchange(int)) ); with slot: void mainwindow::centerchange(int value) { center = value; update(); } so wanted repainte pixmap if slider's value changed. notice everytime when make mouse-in or mouse-out slider, repaint triggered. why happenning? thanks. paint event may triggered @ time underlying qt drawing system. should not assume paint event can triggered you. need change logic in app.

Fetch Records from Mysql By Splicting the value of the column "122-362-25-36" -

fetch records mysql splicting value of column "122-362-25-36": remove (-) sign , search records in table containing value 122-362-25-36 => 1223622536 125-365-36-56 => 1253653656 , search sql query it's not clear exact question per got think solution should be:- select * table id in (select replace('122-362-25-36','-','') id);

c# - Is there a way to know if a filename is an Excel format? -

my question may seem quite trivial despite numerous research, haven't found answer. is there way in .net know if filename excel spreadsheet ? i not interested in specific extension (.xls, .xlsx, etc), know if file excel generic spreadsheet. long ago, wrote similar here code: private enum extensions { unknown = 0, docorxls, pdf, jpg, png, docxorxlsx, } private static readonly dictionary<extensions, string> extensionsignature = new dictionary<extensions, string> { {extensions.docorxls, "d0-cf-11-e0-a1-b1-1a-e1"}, {extensions.pdf, "25-50-44-46"}, {extensions.jpg, "ff-d8-ff-e"}, {extensions.png, "89-50-4e-47-0d-0a-1a-0a"}, {extensions.docxorxlsx, "50-4b-03-04-14-00-06-00"} }; private static string getextension(byte[] bytes) { if (bytes.length < 8) return string.empty; var signaturebytes = new byte[8]; array.cop

ios - Presenting UIPopoverController without dismissing the keyboard -

Image
i'm attempting present uipopovercontroller result of uibutton tap. uibutton contained within custom view that's being displayed uitextfield's inputaccessoryview. issue i'm seeing when uipopovercontroller presented uitextfield displaying inputaccessoryview loses first responder status and, result, dismisses keyboard. there way avoid this? ideally i'd keyboard , inputaccessoryview remain visible while uipopovercontroller presented. i've attached screenshot below demonstrating i'm hoping achieve (right), , i'm seeing (left).

mysql - SQL Outer join 2 tables -

i have 2 tables, comp_product , comp_product_marchand . the comp_product contains product information (description, name, etc..) the comp_product_marchand contains different prices (product resellers). each reseller has price product. not products i in 1 sql query each reseller list of products , price (even if reseller doesn't have one) i have sql query: select p.id_product, pm.price comp_product_marchand pm left outer join comp_product p on p.id_product = pm.id_product id_marchand = 4 (where clause demo only) this sql query returns price products have price, not others... ideas ? change link between table: select p.id_product, pm.price comp_product p left outer join comp_product_marchand pm on p.id_product = pm.id_product , id_marchand = 4 in way you'll show product , if marchand = 4 has 1 info marchand showed. i put query on marchand id in on clause because if put in clause you'll cut lines marchand has n

html - Angular-translate not working with static json content -

angular translation works fine if symabol , translation provided inside $translateprovider.translations() . , when attempt perform translation value json file, translation not working . var mymodel= angular.module('mymodel',['pascalprecht.translate']). config(function($translateprovider) { $translateprovider.translations('en', { headline: 'hello there, awesome app!', intro_text: 'and has i18n support!' }) .translations('de', { headline: 'hey, das ist meine großartige app!', intro_text: 'und sie untersützt mehrere sprachen!' }); $translateprovider.usestaticfilesloader({ prefix: 'https://localhost/angular%20seed/app/js/languages/', suffix: '.json' }); $translateprovider.preferredlanguage('de'); $translateprovider.fallbacklanguage('de'); // $translateprovider.uselocalstorage(); }); my html file is <html ng-app="mymodel

android - Unable to make TextView visible -

am trying set textview element visible when click button. have set textview invisible , button in way: <textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/button1" android:layout_below="@+id/button1" android:layout_margintop="67dp" android:text="textview" android:visibility="invisible" /> <button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbaseline="@+id/button1" android:layout_alignbottom="@+id/button1" android:layout_marginleft="19dp" android:layout_torightof="@+id/radiogroup1" android:text="solution" /> now setting textview visible after clicking button have written following java

web services - Linq data fetch in wcf test client -

here query : select * menu i using wcf web services , have created local database. i want return data using linq , show table's data in wcf client. can me function? here code : namespace crossdine { // note: can use "rename" command on "refactor" menu change class name "service1" in code, svc , config file together. // note: in order launch wcf test client testing service, please select service1.svc or service1.svc.cs @ solution explorer , start debugging. public class service1 : iservice1 { string connectionstring = ...; sqlconnection con = new sqlconnection(connectionstring); public string getdata(int value) { return string.format("you entered: {0}", value); } public compositetype getdatausingdatacontract(compositetype composite) { if (composite == null) { throw new argumentnullexception("compos

Php is not working in https but works fine in http -

i configured centos server , installed openssl rpm. php working fine in http not in https. server uses cpanel. enabled: extension=php_openssl.dll allow_url_fopen = on these 2 lines in php.ini file. still not working. on issue. thanks, ramesh

functional programming - how to create receive {} block in scala with no arguments -

i want have nice code following in scala: class myclass { receive { case dothis => println("dothis") case dothat => println("dothat") } } now understand receive should partial function, no matter partial function created didn't work. partial function should creating receive noarg code working. or in other words code block should adding myclass can call new myclass().receive(dothis) // code add myclass can call receive thanks if want create partialfunction have specify type this: sealed trait doparent case object dothis extends doparent case object dothat extends doparent { case dothis => println("dothis") case dothat => println("dothat") }: partialfunction[doparent, unit] now can assign partial function (instance of partialfunction[doparent, unit] ) variable or field this: val receive: partialfunction[doparent, unit] = { case dothis => println("dothis") cas

android - Andengene get the closest sprite from a touchpoint -

this how adding sprites randomly on screen , moving them function randomly. question how can find closest sprite(sperm in case) touch-point when user touches screen. have scene touchevent, can find distance between 2 sprites not getting how can compare them dont have instance of them list or that... please me @override public scene oncreatescene() { this.mengine.registerupdatehandler(new fpslogger()); this.mscene = new scene(); this.mscene.setbackground(new background(color.blue)); this.mscene.setonscenetouchlistener(this); // ---------------------------------------------------------------- createhandlertoaddsperms(); // ----------------------------------------------------------------- return this.mscene; } private void createhandlertoaddsperms() { // ------------------------------------------------- mtimerclass = new timerclass(0.7f, new timerclass.itimercallback() { @override public void ontick() { if

embedded - Unable to receive USB packets -

i trying receive data packets through printer interfaced pic32. i can send setup bytes , receive 8 bit data correctly, when data received through in packet greater 8 bytes, cannot receive them correctly after first 8 bytes . additional information erroneously posted "answer" , moved here: i bit confused , when initiating read after in token ..the first 2 bytes come 341 , trying read device_id printer class , suggest length of string sent printer . this doing while preparing first in token. bdt_entry *pointbdt; // pointe bdt pointbdt = bdt_in; (even bdt) // free(pep0data); pep0data=null; if(!((pointbdt=(bdt_entry*) malloc(sizeof(bdt_entry)))==null)) { pointbdt=bdt_in; pep0data=(byte *) malloc(sizeof(8)); // pointer buffer pointbdt->stat.val=0; pointbdt->adr=converttophysicaladdress(pep0data); pointbdt->cnt=8; pointbdt->stat.bstall=0; pointbdt->stat.dtsen=1; pointbdt->sta

c# - Why am I getting an InvalidCastException when using an expression from a static field? -

i'm starting use linqkit entityframework 6.0.2 , have following question... why this: public static readonly expression<func<myenum, string>> converttostring = e => e == myenum.one ? "one" : e == myenum.two ? "two" : "zero"; private static string getsomethingelse(iqueryable<enumtest> things) { var ret = things .asexpandable() .select(c => program.converttostring.invoke(c.someenum)) .first(); return ret; } throw: an unhandled exception of type 'system.invalidcastexception' occurred in linqkit.dll additional information: unable cast object of type 'system.linq.expressions.fieldexpression' type 'system.linq.expressions.lambdaexpression'. but this: private static string getsomething(iqueryable<enumtest> things) { expression&

javascript - OpenStreetMap Click event after moving container -

i got aware of bug in osm map: the map click event seems trigger @ wrong coordinates if map div moved. how workaround problem? can't guarantee map div fixed, because site's content may change while map shown. as far searched google , stack overflow, seem 1 experiencing problem... here's fiddle: http://jsfiddle.net/w3f6l/ (set pointer => click "clickme" => try set pointer again) even simple setup of fiddle <div id="clickme">clickme</div> <div id="mapdiv"></div> with js $("#clickme").click(function(){ $(this).css("height","200px"); }); will reproduce error. also pretty odd is, if click clickme , use scrollbar move down, error vanishes (tough happens in fiddle, tried reproduce behaviour in site...) [edit] solution,a bit more generalized unknown's answer, based on it....in case else stumbles upon similar problem: setinterval(function(){ //map contain