Posts

Showing posts from August, 2010

javascript - How can I delimit a transparent area on png image when I'm using HTML 5 Canvas? -

Image
i'm having issues when i'm trying delimit area in html5 canvas, have img: i want transparency in white parts of img, not on img. i'm drawing img in part of code: this.draw = function(){ context.save(); context.drawimage(sniperscoop, 0, 0, w,h); context.restore(); } that possible using html 5 canvas/javascript ? thanks! if you, i'd edit image program gimp , cut out white part. there reason not way?

bdd - Re-using Python's behave feature file for both Unit and Functional tests -

the following gherking test defines desired behaviour 1 of servers: scenario outline: calling server valid json given gis update server when call /update json in file <filename> response status code <status_code> , response valid json , response json contains key status , response json contains key timestamp , response json contains key validity examples: | filename | status_code | | valid_minimal.json | 200 | | valid_minimal_minified.json | 200 | | valid_full.json | 200 | | valid_full_minified.json | 200 | | valid_full_some_nulls.json | 200 | | valid_full_all_nulls.json | 200 | i wrote code unit testing flask server. steps file, interpret gherkin directives, open test client , make necessary calls , assertions: @given(u'a gis update server') def step_impl(context): context.app = application.test_client() ...

asp.net - Display an image on webform2 upon click of button from webform1 -

- making webform1 displays list of car names. - each car has corresponding button directs webform2 image of corresponding car displayed. - storing image of each car in folder in project. what algorithm or code should put on button load different image based on corresponding car name clicked on. you this: child form public string carsource{ get; set; } public testform() { initializecomponent(); } public void updatevalues() { image.source = carsource; } initiate it var child = new testform {carsource = sometextbox.text}; child.updatevalues(); child.showdialog();

oracle11g - How to establish initial connection in SQL Developer to Oracle DB instance in Windows 8.1: "username/password invalid" -

Image
i want work in windows oracle db (oraclexe112_win32). i've installed oracle db instance on windows 8.1 machine, admin page being here: the listener seems working properly: want sql developer connect db instance running, yet fail make connection: login/password enter "sysdba/oracle" (or sys/oracle or oracle/oracle or sysdba/password) no avail. "username/password invalid" prompt getting of trials: the hr/hr user account not yet unlocked. this post explains how it. prior neen connection. username/password need initial connection? need help. update the shot of env. , system variables in win 8.1: tns ping igor : the bin directory without netca : seems forgot default password , dont have user log in with. connect database command line sysdba using os admin user sqlplus / sysdba create self dba user create user igor identified topsecret; grant dba igor; conn igor/topsecret

php - How to create db counter in wordpress -

let's i've got custom post type order , custom field order number , , let's these custom posts created on form submission. what need increment order number field automatically in safe way, numbers aren't duplicated. the trivial solution: on form submission, find last order , use number + 1. in case when 2 users submit form @ same time, same order number. i doing such things custom frameworks in past: lock db row update, increment number, release. safely increment number. require creating separate table counter , i'd prefer avoid that. i didn't find ready in wp api. i'm using wp 3.8 on mysql. auto-increment functionality implemented long time ago in mysql, have specify id of table auto_increment . however, if insert data on form submission , create custom post type, inserting data in wp_posts table, done there, because table, posts stored in wordpress , already have id set auto_increment .

html - Adding code before <body> tag in wordpress -

Image
i using wordpress , have bellow html code after body tag. now want move code before body tag starts. <div class="top-bar"> <div class="container"> <div class="logo"><a href="#cmr"><img title="cmr &ndash; convention management resources" alt="cmr &ndash; convention management resources" src="http://192.168.1.145/cmsrush/wp-content/themes/cmsrush/images/cmr_logo.png"></a> </div> <a class="tar-but" id="rfp1" href="javascript:decryptx('tbmftadnsvt/dpn@tvckfdu&gt;sgq!tvcnjttjpo')">submit rfp</a> <a class="tar-but" href="#contact">request demo</a> <div class="menu"> <div class="menu-top-menu-container"><div class="menu-collapser" style="display: none;"><div c...

Pagination library in codeigniter -

this config: $config['pagination'] = array( 'page_query_string' => true, 'query_string_segment' => 'page', 'full_tag_open' => '<div id="page_footer">', 'full_tag_close' => '</div>', 'anchor_class' => 'class="pagecurrent"', //'next_link' => '&raquo;', //'prev_link' => '&laquo;', 'use_page_numbers' => true, 'last_link' => 'trang cuối', 'first_link' => 'trang đầu', 'num_links' => 4, ); controller: $this->pagination->initialize( array_merge( $this->config->item('pagination'), array( 'total_rows' => $this->_data['total_quizs'], 'per_page...

xcode - NSIndexPath: a useful lldb summary string -

while debugging lldb in xcode see in debugger window simple summary string nsindexpath objects. like: indexpath = (nsindexpath *) { section=2 : row=0 } would more helpful displayed lldb default: indexpath = (nsindexpath *) [nsindexpath * @ scalar section] i did try many summary string formatters written .lldbinit file, these among them: type summary add nsindexpath --summary-string '${var.section}' type summary add nsindexpath --summary-string '${[var section]}' type summary add nsindexpath --summary-string '[${var section}]' type summary add nsindexpath --summary-string '[${var} section]' the result first 3 is: indexpath nsindexpath * error: summary string parsing error 0x08e309a0 and last 1 is: indexpath nsindexpath * [nsindexpath * @ scalar section] 0x08a45b80 which not more helpful neither. do know how force lldb display more useful summary string nsindexpath? (lldb) type...

dns - kamailio proxy server can't find other server -

we running 2 proxy server, need connect server b server. but server can't find b server because b server sip domain register tcp! only answer dig _sip._tcp.serveraddress srv, not answer dig _sip._udp.serveraddress. our dns server admin say, sorry can't support udp. how fix kamailio source support tcp dns? the latest version (at time 4.1.2) should try protocols. you can try play dns proto preference global parameters, giving higher priority tcp, see: http://www.kamailio.org/wiki/cookbooks/4.1.x/core#dns_parameters as example: dns_tcp_pref=50

datastax enterprise - New Solr node in "Active - Joining" state for several days -

we trying add new solr node our cluster: dc cassandra cassandra node 1 dc solr solr node 1 <-- new node (actually, replacement old node; followed steps "replacing dead node") solr node 2 solr node 3 solr node 4 solr node 5 our cassandra data approximately 962gb. replication factor 1 both dcs. normal new node in "active - joining" state several days? there way know progress? last week, there time when had kill , restart dse process because began throwing "too many open files" exception. right now, system log full of messages completed compaction/flushing tasks (no errors far). edit: the node still in "active - joining" state of moment. it's been week since restarted dse process in node. started monitoring size of solr.data directory yesterday , far haven't seen increase. system.log still filled compacting/flushing messages. one thing bothers me in opscenter nodes screen (ring/list view), node shown under ...

c - Sublime Text 2 : Having trouble making an OpenGL sublime-build -

just trying set sublime-build opengl coding on windows 8.1. this have: { "cmd": [ "gcc -o \"$file\" \"$file_base_name\" -lglu -lgl -lglut && ./\"$file_base_name\""], "working_dir": "${project_path:${folder}}", "selector": ["source.c"], "shell": true } the error i'm getting gcc: error: "tute2": invalid argument when trying compile tute2.c. what doing wrong? please replace "cmd": [ "gcc -o \"$file\" \"$file_base_name\" -lglu -lgl -lglut && ./\"$file_base_name\""], with "cmd": [ "gcc -o $file_base_name $file -lglu -lgl -lglut && ./$file_base_name"], and try again.

javascript - Modalbox - .click event not working after ajax call -

i have integrated modal box page: http://leanmodal.finelysliced.com.au . when working elements on page, modal box works fine. however, when receive data ajax call, click event doesn't work. the problem seems .click works elements on page. problem .click works elements on page - , using "on", should work. have tried editing js-file without succes. link js: http://leanmodal.finelysliced.com.au/js/jquery.leanmodal.min.js how should edit js-file? in advance. ensure inserted elements ajax call have correct attributes (rel="leanmodal") modal script for. after inserting ajax data page, should assign modal code new elements by; $('a[rel*=leanmodal]').leanmodal({ top : 200, closebutton: ".modal_close" });

tracking - Google Analytics - Demographics aren't working -

good morning, i've updated customers google analytic's account use latest version of tracking code. i've amended setting 'enable demographics , interest reports' enabled. for past 3-4 days no information has come through despite visitors website. please can advise me on isn't working... the website is: http://www.fellpromotions.co.uk/ i forward hearing you. kind regards, shaun https://twitter.com/shaunswales demographics not yet supported in universal analytics. the dc.js javascript library not supported in universal analytics during phase. users need following related features should wait until phase 3 upgrade: remarketing google display network impression reporting doubleclick campaign manager reporting google analytics demographics , interests reports (from ua upgrade center)

matlab - Displaying entire vector shows only zeros but displaying a any single element shows a correct nonzero number -

i have vector defined x=(1:1000) , vector y of same size lot of different numbers those: -0.0019 -0.0018 -0.0018 -0.0019 -0.0019 -0.0020 i have copied values of y x while statement , when put in console x(1) result -0.0019 , y(1) , on rest of indexes when put in console x shows list this: -0.0000 -0.0000 -0.0000 -0.0000 in workspace, value of both vectors <1000x1 double> , when plot 2 vectors graph of y alright graph of x line of zeros this code: %grabar audio en un archivo fs = 200000; y = wavrecord(1*fs, fs, 1); %10 segundos wavwrite(y,fs,'cancion.wav'); %leer el archivo y graficar las ondas [wave,fs] = wavread('cancion.wav'); t = 0:1/fs:(length(wave)-1)/fs; sound(wave,fs) plot(t,wave) fs2 = 1000; j=1; i=1; xa=(1:fs2); while j<fs2 xa(j) = wave(i); i=i+fs/fs2; j=j+1; end intervalo = 0:1/fs2:1-(1/fs2); xa=xa'; figure(2) plot(intervalo,xa); %display(length(wave)) anyone can tell me happening? in line...

javascript - How can I compress my c++ code in a single line? -

i writing document html , javascript. i want compress c++ code single line(to save bytes), how can efficiently? sublime text editor directly select text , press 'ctrl+j'

javascript - Bootstrap custom carousel tweak -

i came across demo: http://www.bootply.com/94444 . have been looking for. as can see takes 3 slides in 1 view. have 2 slides in 1 view. can tell how accomplish this? thanks in advance. see example: http://www.bootply.com/124246 you need modify few things on 3 slides example.. change css 50% 33% change cols col-4 col-6 cols 50% wide modify jquery append next sibling active item (creating 2 slides in each active frame)

converting string to double in c -

i having problem converting string double. please me out. here's code: char price[100]; double newprice; printf("\nplease enter price:"); fgets(price,100,stdin); newprice = atof (price); printf("\nprice of item %f",newprice); it gives diff output while running diff files. file1 (method 1): char price[100]; double newprice; int main() { myval(); return 0; } myval() { printf("\nplease enter price:"); fgets(price, 100, stdin); newprice = atof(price); printf("\nprice of item %f", newprice); } file2 (method 2) #define max 50 char oldprice[max]; double newprice; int main() { userinput(); } int userinput() { printf("\nplease enter price:"); fgets(oldprice, max, stdin); newprice = atof(oldprice); printf("\nprice of item %f", newprice); return 0; } the above 2 methods compiled using tcc(tiny compiler). both methods same , diff output these 2. ou...

string - How to find the closest time value to a given time value in matlab -

say have time value given, example: 2012-03-28_15:10:00 , have sting stores multiple time values: 2012-03-28_14:00:00 2012-03-28_14:10:00 2012-03-28_14:20:00 2012-03-28_14:30:00 2012-03-28_14:40:00 2012-03-28_14:50:00 2012-03-28_15:00:00 2012-03-28_15:05:00 2012-03-28_15:20:00 2012-03-28_15:30:00 i want find time value in string closest original time value. know how can done in matlab? code data1 = '2012-03-28_15:10:00' data2 = [ '2012-03-28_14:00:00' '2012-03-28_14:10:00' '2012-03-28_14:20:00' '2012-03-28_14:30:00' '2012-03-28_14:40:00' '2012-03-28_14:50:00' '2012-03-28_15:00:00' '2012-03-28_15:05:00' '2012-03-28_15:20:00'] [~,ind1] = min(abs(datenum(data2)-datenum(data1))); closest_time = data2(ind1,:) output closest_time = 2012-03-28_15:05:00 extended part: if have many dates, char matrix , compared list, using bsxfun approach might better solution, avoids loops. shown belo...

Swipe method not working in android automation testing -

i trying implement swipe method.may know correct way achieve objective? public void swipewithcordinatelocation(webdriver driver,double startx, double starty,double endx,double endy, double duration) { javascriptexecutor js = (javascriptexecutor) driver; hashmap<string, double> swipeobject = new hashmap<string, double>(); swipeobject.put("x", startx); swipeobject.put("y", starty); swipeobject.put("x", endx); swipeobject.put("y",endy ); swipeobject.put("duration", duration); // hashmap[] param = {swipeobject}; js.executescript("mobile: swipe", swipeobject); } common.swipewithcordinatelocation(driver, 100.00, 500.00, 500.00, 500.00, 1.00); but appium perform swipe takes different credentials [x=360][y=592] [x=360][y=592] . do? can 1 me please. the best way analyze swipe in automation enable "show touches" ,...

naming conventions - "most common" typedef for basic types in C -

i had small discussion @ work since decided go new naming convention basic typedefs c. their argument follow common naming convention used c developers. now, don't care change, wondering there such thing? 'most common naming convention among c programmers'. know windows tends use naming word , dword etc. they decided go from: u8bit uint8_t s8bit int8_t etc. as said, there's no real naming convention, can rely on libc style (using _t suffix, use uppercase macro … ) for you're example, don't know how decision made, such types exists in c99 standard header stdint.h : signed type have form ints_t s replaced size in bits , unsigned types have form uints_t (with s … ) so, uint8_t exists in standard , signed version ,int8_t (and not sint8_t.) redefining them waste of time, should prefer provided standard. using provided definition has other advantages: don't have worry how correctly define sizes (remember, lot of integer types don...

OpenLDAP multi-tenant like ACL -

is possible write acl openldap implements multi-user , multi-tenancy environment. mean secure dit using 1 rule , match dynamically every customer. example dit: root ..customer1 ....users ......admin ......user ....objects ..customer2 ....users ......admin ......user ....objects what want admin user customer1 may see , write objects customer1 , customer2 users may see , write customer2 objects. same goes user of each customer, in read-only mode. i didn't such acl working , found examples write below users entry in tree, nothing 2 levels , allow write below that. has idea how apply such acl? thanks- i suggest want here openldap's acl feature called sets try like this: olcaccess: dn.regex="^o=[^,]+,dc=example,dc=com$" set="this/-*/manager/member* & user" write set="this/-*/manager & user" write set="([ldap:///cn=admin,ou=users,] + + [??sub?objectclass=inetorgperson]) & user" write set="...

c# - Simple way to create a command -

i new c# , need create simple binding command 1 button. have been reading lot of articles last hours got me more confused. i have wpf window (let's window1) have button "addcustomer". simplest way create command it? (by simplest mean easy understand) in every article doing differently. need show me how bind in xaml, more detailed better... said, new. thank help. here's take on it, following 'simplest' because leveraging prism library , amount of code write small. use nuget manager add prism project if you're not using ... the xaml: <button command="{binding addcustomercommand}" content="add customer"/> in viewmodel: (1) declare command: public icommand addcustomercommand{ get; private set; } (2) define command: addcustomercommand= new delegatecommand(addcustomer); (3) , create method: private void addcustomer() { //do logic here } extended version: can pass parameter xaml: <button comm...

c# - Array element is maybe not set -

in method below set string smdrext tmp[3]. however, tmp[3] seems empty because "index outside bounds of array.". before set it, can change exist make sure program not halt again due this? public void writetocsv(string line, string path) { string[] tmp = line.split(','); string smdrext = tmp[3]; if (ext.contains(convert.tostring(smdrext))) { file.appendalltext(path, line + "\n"); } } please try below code snippet. public void writetocsv(string line, string path) { if (!string.isnullorempty(line)) { string[] tmp = line.split(','); if (tmp.length > 3) { string smdrext = tmp[3]; if (ext.contains(convert.tostring(smdrext))) { file.appendalltext(path, line + "\n"); } } } } let me know if concern.

Why call javascript from server side? -

i new asp.net. know javascript client-side scripting language. benefit call server side using registerclientscriptblock method. please explain... some server side modules in cms or shopping cart requires client side javascript. example gallery plugin / module installed via server side admin area bit requires client side js code work. these plugins use functions registerclientscriptblock add required js libraries template.

microcontroller - Byte order issue between Micro controller and Microprocessor? -

my host stm32l100 "little enidian"which connected network processor lon:ft5000 "big enidian",communicates through uart ,how on come problem of difference in enidians.,one solution know,interchange bits before sending , receiving,any standard solution , app involves nested structure , enums) the network protocol should define endianness. example, tcp/ip , modbus big endian. while cip protocols such devicenet little endian. if you're creating own protocol choose whichever endianness convenient. the software running on network endpoints should convert data appropriately. note means swapping bytes rather swapping bits. see introduction endianness more information including excerpt. a common solution endianness problem associated networking define set of 4 preprocessor macros shown in listing 1. these macros follows: htons(): reorder bytes of 16-bit unsigned value processor order network order. macro name can read "host network ...

Platform independent Code fro C/C++/java without additional package -

is possible to make server/client code in c/c++/java, can platform independent? it should not require additional package (like no jvm requirement) installation on system executable file run (if possible on windows/linux/mac). if not tell me other way (maybe language) achieve ? thank you just executable file run (if possible on windows/linux/mac). this can done qt c++ writing portable code , using static linking bind dll's. downside end larger executable file. java uses jvm rules out stated. it should noted platform compile target executable works on. program compiled on windows won't work on ubuntu (you need compile seperate version - unless install .exe in wine perhaps).

java - Cannot disable SSL for JMX -

Image
i following jmx guide here . under disabling ssl section says com.sun.management.jmxremote.ssl=false jvm property can set disable ssl jmx. i testing on tomcat server. edit tomcat startup script catalina.sh , add property. this property used tomcat during startup: then connect tomcat using jconsole it still tries connect via ssl: i've tried active mq, soap ui etc no luck. click on insecure. jconsole complains there no ssl , warn that.

cordova - Probem in create a new phonegap project -

i try create phonegap project command-line tools error. this command: e:\android\sdks\android\cordova-android\bin\create.bat e:\android\sdks\android\projects com.example.project_name projectname and error: c:\users\amin7x>e:\android\sdks\android\cordova-android\bin\create.bat e:\androi d\sdks\android\projects com.example.project_name projectname e:\android\sdks\android\cordova-android\bin\node_modules\q\q.js:126 throw e; ^ project exists! delete , recreate i'm sure project not exist. the problem error mentioned in comment ( https://www.dropbox.com/s/bi14lqq64ot6n69/error.txt ) want create project in c:\program files\ , don't run cmd admin rights. solutions: (recommended): use path directly in c:\ or in user directory c:\users\<user>\ run cmd administrator

google chrome - How to pass parameters in URL with ChromeCast? -

is there example show how pass parameters in url sender app receiver app? i pass parameters , of theese parameters receiver app creates manifest url , authorization xml, need play playready videos. thank much! if need pass parameters receiver, need either use customdata field available on number of apis (it json object can pass) or can create custom namespace , send data receiver. former useful when data need send can happen @ same time calling apis such load, play, pause, etc. latter useful when such alignment cannot happen , needs out-of-band communication.

orm - Symfony 2, Doctrine 2 Multiple one to one relations from one entity to another -

i once more need you. possible implement more 1 onetoone relationship entity? i have entity called route: in entity have start-variable , end-variable. want both of them onetoone instance of second entity called position. entity position: in here have id, name, latitude , longitude. this picture shows better: http://s14.directupload.net/images/140324/36o8vyxm.jpg is possible, , how implement in doctrine? i´ve tried to give both, start , end, onetoone annotion, doctrine won´t notice changes. thank help! simply define fields; problems? in route entity /** * @var string * * @orm\onetoone(targetentity="position", cascade={"all"}) * @orm\joincolumn(name="start_position_id", referencedcolumnname="id") */ private $answerright; /** * @var string * * @orm\onetoone(targetentity="position", cascade={"all"}) * @orm\joincolumn(name="end_position_id", referencedcolumnname="id") */ ...

ios - Setting properties on a UIView -

i need set property on uiview uiviewcontroller . sounds simple enough ( moreplandetails uiview ), moreplandetails *moredetails = [[moreplandetails alloc] initwithframe:cgrectmake(10, 60, self.view.frame.size.width-20, self.view.frame.size.height-80)]; moredetails.plan = self.plan; [self.navigationcontroller.view addsubview:moredetails]; the property on moreplandetails defined usual way: @property (nonatomic, strong) pfobject *plan; and synthesized: @synthesize plan = _plan; this should it, doesn't it? reason moredetails.plan stays null . missing? as noted in comment, use self.plan. don't need add "@synthesize" anymore, long have @property compiler generate getters , setters you. add: @property (nonatomic, strong) pfobject *plan; reference in code: self.plan = whatever

arrays - Ruby diagonal matrix from random numbers -

i need create diagonal matrix (8x8) , fill random numbers in [-30..45] range after need transform array vector , sort it i tried different ways. at first create matrix (8x8) matrix = matrix.build(8) {0} puts matrix.each_slice(matrix.column_size) {|r| p r } also made array random numbers in range array = (-30..45).to_a.shuffle puts array [0..8] and made diagonal matrix matrixd = matrix.diagonal(1,2,3,4,5,6,7,8) puts matrixd.each_slice(matrix.column_size) {|r| p r} how can fill diagonal matrix array , put in vector? have 2 algorithms sorting vector class array def bubblesort! length.times |j| in 1...(length - j) if self[i] < self[i - 1] self[i], self[i - 1] = self[i - 1], self[i] end end end self end end class array def selectionsort! 0.upto(length - 2) |i| (min_idx = + 1).upto(length - 1) |j| if self[j] < self[min_idx] min_idx = j end end if self[i] > s...

How to show color attribute with sku id in magento -

i need show color attribute of other product sku id. example. on product page. have sku of other product(b,c) . need display other product color ,size sku. how can it? thanks you can fetch product sku code below , use/display information want display. $product = mage::getmodel('catalog/product')->loadbyattribute('sku',$sku); //$sku product's sku. if don't show details can try load product it's code $productid = $product->getidbysku($sku); //$sku prdouct's sku if ($productid) { $product->load($productid); } if have more 1 sku create array , call in loop.

ios7 - Custom UICollectionViewLayout calls layoutAttributesForElementsInRect multiple times -

i created custom uicollectionviewlayout creates 2 dimensional grid. scrolling horizontal ant vertical works fine. there problem if test on different os . if right or bottom border of whole uicollectionview , bounces turned on, on ios7 nothing happens. when gets ios6 every time drag uicollectionview on bounds size, method layoutattributesforelementsinrect called multiple times. causes massive lag because inside layoutattributesforelementsinrect layout enumerating views views should displayed. does know causes problem on ios6 cache layout attributes in preparelayout. loop through them , see intersects in layoutattributesforelementsinrect. make breakpoint in layoutattributesforelementsinrect , ensure it's uikit code triggering call. if it's own code triggering call, see if can avoid triggering more necessary. in case method used uikit determine how lay out onscreen cells.

magento - How to fix SolrException, EOFException: read past EOF: MMapIndexInput? -

i've got problem can't solve. partly because can't explain right terms. i'm new sorry clumsy question. below can see overview of goal. i'm using magento ce 1.7.0.2 & solr 4.6.0. i'm integrating solr file site in host.when starts server showing following errors please take @ , tell me thing wrong did here,the same file working in local magento. http error 500 problem accessing /solr/. reason: {msg=solrcore 'collection1' not available due init failure: error opening new searcher,trace=org.apache.solr.common.solrexception: solrcore 'collection1' not available due init failure: error opening new searcher @ org.apache.solr.core.corecontainer.getcore(corecontainer.java:818) @ org.apache.solr.servlet.solrdispatchfilter.dofilter(solrdispatchfilter.java:297) @ org.apache.solr.servlet.solrdispatchfilter.dofilter(solrdispatchfilter.java:197) @ org.eclipse.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler....

shell - How to execute multiple SQL files in UNIX? -

i have n .sql files example 1.sql, 2.sl, 3.sql.... n.sql in folder named sql_scripts. want execute files using single shell script. whats easiest , preferred way so? cat 1.sql 2.sql 3.sql ... n.sql |sqlplus username/password@sid or cat *.sql|sqlplus username/password@sid ?

url - Grails UrlMappings alphanumeric id -

i managed have string id domain assigned generator, url show/edit /controller/action/alphanumeric_id . it worked fine till vulnerabilities tests, found problem when id contain slashes (and backslash) when encoded %2f (and %5c) browser gives 400 bad request error. my mapping default 1 /$controller/$action?/$id? , watched validator constraints see going on, request not arrive there when containing these characters. if access /controller/action/?id=alphanumeric_id goes well, wonder if there no way continue using default short url. edit: create new grails application (mine version 2.1.3); create controller; in action println params.id , if want can in urlmapping too; try access controller /appname/controller/action/abc , goes fine; now try /appname/controller/action/a%2fbc or /appname/controller/action/a%5cbc , gives 400 bad request; other combinations %00 upto %ff should work well, not of them does, way, %00 not work. bugged combinations: %00 %2f %5c ...

ios - addObserver forkeypath not working in MPMusicPlayerController -

i using following code know currentplayback time. not working when play song using mpmusicplayercontroller .help me on this. ideas or suggestions grateful [self addobserver:self forkeypath:@"musicplayer.currentplaybacktime" options:0 context:nil]; song play code mpmediaitemcollection *collection = [[mpmediaitemcollection alloc] initwithitems:[nsarray arraywithobject:song]]; [musicplayer setqueuewithitemcollection:collection]; [musicplayer preparetoplay]; [musicplayer setnowplayingitem:song]; //[self.musicplayer setvolume:volumeslider.value]; [musicplayer play]; as stated volker, property not kvo compliant. see docs here nsnotification events listen for. make sure call [musicplayer begingeneratingplaybacknotifications] and [musicplayer endgeneratingplaybacknotifications] for reference these notifications posted mpmusicplayercontroller: mpmusicplayercontrollerplaybackstatedidchangenotification mpmusicplayercontrollernowplayingitemdidchangenotifica...

Over-ride the back button of android device through phonegap in javascript -

i making app in html5 , javascript , deploying on android device. after confirmation in application, don't want go on previous page. but, on button of device goes on previous page. i tried many demos. following 1 of link tried. http://docs.phonegap.com/en/2.8.0/cordova_events_events.md.html#backbutton i tried displaying alert demo purpose. not work. please suggestions. thanks. i tried following. doesn't work. need add external jquery file? <script type="text/javascript" charset="utf-8"> function onload() { document.addeventlistener("deviceready", ondeviceready, false); alert("on load"); } function ondeviceready() { document.addeventlistener("backbutton", onbackkeydown, false); alert("device ready"); } //document.addeventlistener('backbutton', onbackkeydown, false); function onbackkeydown(event) { event.preventdefault(); ...

php - Unused variable warning (editor) array_walk -

following code generates editor warning not using $key in code. idea how avoid warning? there similar check done php parses too? array_walk($services, function(&$value, $key) { $value = str_replace('xxx', '', $value); }); just remove it. array_walk($services, function(&$value) { $value = str_replace('xxx', '', $value); }); but note it's editor warning, it's not php warning .

c++ - Check if A is a subclass of B? -

i using unreal engine 4 , seems can't avoid casts. acontroller* c = this->getcontroller(); aplayercontroller* p = (aplayercontroller*)c; is there way can check if c playercontroller before cast? like lot of game engines, unreal engine compiled without rtti performance reasons, dynamic_cast not work. unreal engine provides own alternative, called cast . can't find documentation right now, this question describes use nicely. acontroller* c = this->getcontroller(); aplayercontroller* p = cast<aplayercontroller>(c); if (p) { ... } acontroller has convenience method casttoplayercontroller same thing: acontroller* c = this->getcontroller(); aplayercontroller* p = c->casttoplayercontroller(); if (p) { ... } if sure c going aplayercontroller castchecked more efficient: acontroller* c = this->getcontroller(); aplayercontroller* p = castchecked<aplayercontroller>(c); ... in debug builds, use cast , throw assert i...

ocr - How to preserve document structure in tesseract -

Image
i using tesseract ocr extract text image. preserving structure of document important me. tesseract not preserve structure, infact changes order of text. input image below. and output getting follows: someto left someto left in middle in middle some tab some tab some space between them some space between them sometext here sometext here this how desired output of same structure in image? i.e. follows: text here text here left left in middle in middle some tab some tab some space between them some space between them newer versions of tesseract (3.04) have option called preserve_interword_spaces should want. note number of spaces tesseract detects between words may not same between similar lines. words left-aligned run of spaces preceding them (as in examp...

objective c - Runtime checking of Blocks and Queues in NSDictionary -

this question has answer here: checking objective-c block type? 5 answers i have array of dictionaries, stores blocks , queues. after method need execute it. for (nsdictionary * dict in self.arrayofblocksandqueues) { if (!dict[@"block"] || !dict[@"queue"]) { continue; } dispatch_block_t block = dict[@"block"]; dispatch_async(dict[@"queue"], ^{ block(); }); } so question is, how can check in runtime, dict[@"block"] , dict[@"queue"] type i’m expected? have typedef void(^handler)(); , need sure dict[@"block”] type of handler . know, blocks , queues in fact objective-c objects, don’t conforms <nsobject> protocol. so, there anyway it? thanks in advance! you can create class block/queue property easy manipulation. try setting block , queue properie...

java - How to configure com.datastax.driver.core.Cluster.Initializer from a configuration file -

i wanted know if it's possible build com.datastax.driver.core.cluster.initializer configuration file mentioned in api java docs . are there existing implementations parse file , create cluster.initializer or expected write our own? thanks.

java - how to mock a servletContext instead of Servlet or HttpServletRequest? -

i have independent project writing test cases; problem can't mock httpservletrequest , because in servlet there calls getservletcontext() test cases running outside servlet container. return error saying "no context found". 1 dependency servlet container; there can hundreds. example, initialcontext.lookup() depends on container. how can use mockito write test case in scenario? please don't ask error message; it's more of logical problem technical. looking on internet tutorials makes me wonder if doing wrong. no 1 seems have encountered problem before... how can mock httpservletrequest without ever having getservletcontext() called in servlet? mean seriously, how rare can be? you have servlet implementation uses servletcontext , e.g. public class someservlet extends httpservlet{ protected void doget(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { servletcontext servletcontext = getservletc...

c# - Null reference exception in EF 6.0+ after upgrading from 6.0-beta1 -

after upgrading project ef 6.0-6.1 (this happens every version) ef 6.0-beta1 i'm getting exception: system.nullreferenceexception: object reference not set instance of object. @ system.data.entity.core.mapping.viewgeneration.structures.typerestriction.asuserstring(stringbuilder builder, string blockalias, boolean skipisnotnull) @ system.data.entity.core.mapping.viewgeneration.structures.boolexpression.asuserstringvisitor.visitterm(termexpr`1 expression) @ system.data.entity.core.common.utils.boolean.termexpr`1.accept[t_return](visitor`2 visitor) @ system.data.entity.core.mapping.viewgeneration.structures.boolexpression.asuserstringvisitor.visitandor(treeexpr`1 expression, exprtype kind) @ system.data.entity.core.mapping.viewgeneration.structures.boolexpression.asuserstringvisitor.visitand(andexpr`1 expression) @ system.data.entity.core.common.utils.boolean.andexpr`1.accept[t_return](visitor`2 visitor) @ system.data.entity.core.mapping.viewgene...

c++ - Cplusplus std::set of bidimensional array -

i'm new c++ , need use set stl i'm struggling concept. i have array int my_data[3] i want create (don't know if possible) set space 3 ints , key set int stored on first column. i want make custom sort. this i've tried no success. struct sort_set { bool operator() (const int& a, const int& b) const { int* arr1 = (int*) a; int* arr2 = (int*) b; int diff = arr2[1] - arr1[1]; if (diff) { return true; } else if (diff == 0) { int diff2 = arr2[2] - arr1[2]; if (diff2) { return false; } } return arr1[0] < arr2[0]; } }; set<int[3],sort_set> data; can point me in right direction? you cannot have arrays elements of containers. they're not assignable nor copyable. use std::array<int, 3> if have c++11 avaliable, or define custom class otherwise.

.net - Is it "bad" to use objects as Keys in dictionaries? -

i assume when doing look-up in dictionary needs hash key giving , use hash find object looking for. if so, using larger objects keys slow down look-up or have other consequences not encountered using string or simple data type key? yes, it's bad idea use mutable object dictionary key. taking @ https://stackoverflow.com/a/7941876/400760 , leads me believe there unintended consequences, correctly implemented gethashcode() based on how hash based collections typically implemented. it should safe use immutable object dictionary key.

Can't Getting called onReceive() when package cleared in android -

i using code register broadcast receiver package <receiver android:name="com.abc.abc.activity.receiver" android:exported="true" > <intent-filter> <action android:name="android.intent.action.package_added" /> <action android:name="android.intent.action.package_removed" /> <action android:name="android.intent.action.package_data_cleared" /> <category android:name="android.intent.category.default" /> <data android:scheme="package" /> </intent-filter></receiver> but not getting called when clear application's data can me in advance.! i tested , it's work me code: <receiver android:name=".permission_policy.appinstallremovereceiver"> <intent-filter android:priority="100"> <action android:name="android.intent....

Facebook PHP SDK notifications do not show up in Facebook ios notifications? -

i have web based app send notifications users using following: $response = $facebook->api('/'.$userid.'/notifications', 'post', array( 'template' => 'a template here', 'href' => 'link-here', 'access_token' => 'part1|part2')); it works expected , users notification if browsing facebook in browser notification not appear in facebook app on iphones or mobile devices? why this, have missed setting in developer setup? according documentation of notifications api - the logic that, on web, if canvas setting exists, show 'canvas url + href'. if not, show nothing. in future (not in version), use existing url re-writing logic support mobile canvas , native mobile apps. append special tracking params (fb_source, notif_id, notif_t) target url developers track @ side. since api in beta, should wait n...

c# - MouseLeftButtonDown animation activates very late when clicking control -

hi have strange problem in wpf project. i'm trying style elements on ui , want implement animations click animations or hover animations. there no problems when creating of these animations except mouseleftbuttondown animation. in style implemented animation (this style label s): <eventtrigger routedevent="mouseleftbuttondown"> <eventtrigger.actions> <beginstoryboard> <storyboard targetproperty="(foreground).(solidcolorbrush.color)"> <coloranimation to="#6a6a6a" duration="0:0:0.04" /> </storyboard> </beginstoryboard> </eventtrigger.actions> </eventtrigger> my expectation foreground of label changes #6a6a6a whenever press left mouse button. in fact expected animation doesn't executed 1 second after pressed left mouse button (lmb pressed -> waiting 1 sec -> color changes). don't know why happens. ...

android - Error parsing XML: duplicate attributes? -

i'm having trouble setting background button. tried setting android:background="@drawable/mybutton_background" but caused error, saying "string types not allowed" referring "@drawable/mybutton_background" . caused error causing me lose r.java file , giving me "r cannot resolved variable error" . gave on button , deleted background, error remained after deleted. well, error gone , message says error parsing xml: duplicate attributes 1 line of code, once delete line, error message moves on line! it's eclipse won't update realize deleted line of code. checked updates , cleaned project countless times, i'm still getting same error. know what's project? my error log: activity_main.xml: paint.setshadowlayer not supported. activity_main.xml: failed convert @drawable/ drawable activity_main.xml: failed convert android:background=" drawable activity_main: <relativelayout xmlns:android="http://schemas.an...

php - Split Multiple Arrays Into Unique Groups -

i'm having hard time thinking of solution problem (maybe because it's monday). have multiple arrays of user members (email address) , want split them unique groups. data example: $members = array( 'group one' => array( 'user a', 'user b', 'user c', 'user d' ), 'group two' => array( 'user a', 'user b', 'user d' ), 'group three' => array( 'user a', 'user e' ) ); now want separate them unique groups , have results this: array ( 0 => array ( 'groups' => array ( 0 => 'group one' ), 'members' => array ( 0 => 'user c' ) ), 1 => array ( 'groups' => array ( 0 => 'group one', 1 => 'group two' ...

mongodb - Mongo w/ Mongoose on Express connection closes -

Image
my connection mongo database close or timeout if left in active. i'm getting following error when leave app in active "no open connections" my mongo db running in replication set on aws. i'm using following options when connecting using mongoose. i'm unsure if other flags should set. basing options on teh monodo node driver doc @ http://mongodb.github.io/node-mongodb-native/api-generated/server.html .users in applicaiton 8+ hours @ time , don't want timout when go lunch or leave meeting. mongooptions : { user: 'root', pass: '********', replset: { auto_reconnect: true, poolsize: 25, socketoptions: { keepalive: 1 }, ssl: true, sslcert: fs.readfilesync('./server/config/ssl/mongodb-cert.crt'), sslkey: fs.readfilesync('./server/config/ssl/mongodb-cert.key')} } mongoose.connect('mongodb://server.com:27017', config.mong...

javascript - Fill dropdown and radio button choice to proceed to right url -

i trying force customers 2 choices on cart.php before can proceed checkout. based on choices customer redirected correct page. not showing want in woocommerce cart page. html proceed please fill following steps.<br> country:<br><select id="selectme"> <option value="none">choose country</option> <option value="sweden">sweden</option> <option value="other">other</option> </select> <br><br><br> <div id="sweden" class="group"> <blockquote><font size="4" face="alice">choose payment method</font><hr> <pre> <form name="jump"> <input type=radio name=a value="http://facebook.com">klarna checkout<br> <input type=radio name=a value="http://google.com">paypal<br> <input type=radio name=a value...