Posts

Showing posts from February, 2010

deployment - How do you trigger a gulp/grunt task on a remote server after deploy? -

i've switched roots sage starter theme wordpress: roots.io/sage/docs/ , i'm reading on deployment processes. my processes usually: - make changes - build grunt/gulp - commit (including compiled scripts) - deploy sage's .gitignore file removes dist folder (compiled files) repo ie. no css/js in repo. supposed install node/npm , build assets on staging/production environment after deploy? if so, how trigger gulp/grunt task on remote server after deploy? i'm using https://www.springloops.com/ managing git , deploy. are supposed install node/npm , build assets on staging/production environment after deploy? you should avoid doing this. there mixed opinion committing compiled assets vcs stated doing previously, too. let's @ example. you finished testing locally. haven't run npm update in few days , 1 of dependencies has loose version constraint specified; "~1.0.0" . you deploy. on server, npm install run before gulp or grun

javascript- facebook uploading photo -

i working on chrome extension project , i'm trying upload photo facebook album returns following response no matter image try upload. { "error": { "message": "this message contains content has been blocked our security systems.", "type": "oauthexception", "code": 368 } } here code: var canvas = document.createelement('canvas'); var ctx = canvas.getcontext('2d'); var img = new image; img.crossorigin = 'anonymous'; img.onload = function(){ canvas.height = img.height; canvas.width = img.width; ctx.drawimage(img,0,0); var dataurl = canvas.todataurl( 'image/png'); blob = datauritoblob(dataurl); goon(blob); canvas = null; }; img.src = "image url"; function datauritoblob(datauri) { var bytestring = atob(datauri.split(',')[1]); var ab = new arraybuffer(bytestring.length); var ia = new uint8arr

forms - PHP not getting POST information -

i trying user feedback emailed me using php mail() function. here code: <form method="post" action="#" onsubmit="return false" name="form"> <table> <tr> <td>your email:</td> <td><input required type="text" name="youremail" placeholder="email@email.com"></td> </tr> <tr> <td>your message: </td><td><textarea rows="30" cols="40" name="message" style="vertical-align:top;"></textarea></td> </tr> <tr><td> <input type="submit" name="submit"> </td></tr> </table> </form> <?php $to = "email@email.com"; $message = $_post["message"]; mail($to, 'feedback', $message); ?> the message sent, there nothing in body of email. i've tested it, , doesn't work. you should

visual c++ - cmake - extracting pdb files from object libraries -

i building static library using object libraries shown using cmake 3.1.3. i have add_subdirectory(a) add_subdirectory(b) .... add_library(mylib static ${sources} $<target_objects:a> $<target_objects:b> ) set_target_properties(mylib properties compile_pdb_name mylib compile_pdb_output_dir ${cmake_binary_dir}) now, problem generates vc120.pdb in a's cmake subdirectory. b generates own vc120.pdb in b's cmake subdirectory. and, mylib generates mylib.pdb in main binary cmake folder. i want 1 static library , 1 pdb file. want mylib , mylib.pdb. how can merge vc120.pdbs mylib.pdb or ideally generate 1 pdb file? this not direct answer question, alternate solution may want consider. with static libraries, better off using /z7 generation of debugging information. when using /z7 compiler not produce .pdb file, embeds debugging info directly generated object files. when these object files linked static library,

c++ - Segmentation fault: Calling an Qt object's method from another object's method by pointer -

i have definition of class class mainwindow : public qmainwindow { q_object //ignore private slots: void on_pushbutton_clicked(); private: ui::mainwindow *ui; qtimer* cyclecomplete; } and constructor , member function definitions: mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); qtimer* cyclecomplete = new qtimer(this); } mainwindow::on_pushbutton_clicked() { cyclecomplete->start(1000); //error: segmentation fault } if cyclecomplete->start(1000) method (or function?) called, program crashes without message, or if using debugger, windows sends qt editor (an ide) error says "segmentation fault". is not allocated correctly? or not allocated @ all? interpretation of code constructor class mainwindow creates object of class qtimer, , pointer stored in mainwindow can call qtimer object's methods (functions?) within mainwindow object's

Build apk with android studio -

are build apk latest android studio keystore imported pkcs12 return different fingerprint? you can convert p12 file jks. 1) create empty jks store keytool -genkey -alias anyname -keystore certificate.jks keytool -delete -alias anyname -keystore certificate.jks 2) import certificate.p12 certificate.jks keytool -v -importkeystore -srckeystore certificate.p12 -srcstoretype pkcs12 -destkeystore certificate.jks -deststoretype jks also, make sure build variant set release.

Can I iterate over NEW in a PostgreSQL trigger function? -

i've written trigger function hoping iterate on new , check values. create or replace function fix_nulls() returns trigger $_$ begin val in new loop if val = '{x:null}' val := ''; endif; endloop; return new; end $_$ language 'plpgsql'; create trigger prevent_nulls_siteinfo before update or insert on siteinfo each row execute procedure fix_nulls(); but syntax error: error: syntax error @ or near "new" line 3: val in new ^ is possible iterate on values in new ? write bunch of if statements check each column, i'd prefer function general can use other tables in future. static code simple cases for bunch of given columns spell out. create or replace function fix_nulls() returns trigger $func$ begin if new.val1 = '{x:null}' new.val1 := ''; end if; if new.val2 = '{x:null}' new.val2 := ''; end if; if

android - How to smoothly move mouse cursor with Java? -

i'm trying use robot class move mouse pointer based on accelerometer readings i'm getting android device via bluetooth. problem mouse cursor moves in steps. need way move smoothly, physically dragging pointer. here's have far @override public void serialevent(serialportevent serialportevent) { if(serialportevent.geteventtype() == serialportevent.data_available) { try { string inputline = input.readline(); string[] values = inputline.split(","); int x = integer.parseint(values[0])*(-1); int y = integer.parseint(values[1])*(-1); mouse.movemouse(x, y); //system.out.println(inputline); } catch (ioexception e) { system.err.println(e.tostring()); } } } here mouse pointer moves in smaller or bigger steps depending on how phone tilted. want move faster or slower. what you're looking called

asp.net - Can you revert back to using Username in DNN 7.3.4 module permission grid? -

in dnn 7.3.4 when adding user individually module permissions grid can add them user's display name now. used done username. looks changed between dnn 7.0.2 , dnn 7.3.4. new way useless if have thousands of users , many of them have display names not unique. how identify john smith looking without username? please tell me there setting somewhere change username have not been able find one. if so, please tell me @ or missing. thanks! personally never recommend provide user based permissions pages or modules. should roles.

ios - NSUbiquityIdentityDidChangeNotification and SIGKILL -

swift 1.2 xcode 6 long-time listener, first-time caller. hello, straight horse's mouth: "to handle changes in icloud availability, register receive nsubiquityidentitydidchangenotification notification." here code provide implement this: [[nsnotificationcenter defaultcenter] addobserver: self selector: @selector (icloudaccountavailabilitychanged:) name: nsubiquityidentitydidchangenotification object: nil]; i swiftified in app to: var observer = nsnotificationcenter.defaultcenter().addobserverforname (nsubiquityidentitydidchangenotification, object: nil, queue: nsoperationqueue.mainqueue() ){...completion block...} src: https://developer.apple.com/library/ios/documentation/general/conceptual/iclouddesignguide/chapters/icloudfundametals.html#//apple_ref/doc/uid/tp40012094-ch6-sw6 what correct way implement this? go in appdelegate? remove observer when app gets sent background? the problem i'm encountering when ubiquity token cha

asp.net - Thinktecture EmbeddedSTS causing duplicate HTTP requests -

i need in resolving strange behavior came across while using thinktectures embedded sts locally in asp.net mvc application. don’t see issue on server using adfs. the issue is after sign in application, of http calls on getting called twice. first http request goes without fedauth cookie server responds status code of 302 (redirect) , request same url made time fedauth cookie. i'm trying understand causing browser send first request without fedauth cookie , why server redirects same url? i need in understanding how embeddedsts url gets resolved. went through code on github not clear me how embeddedsts url resolved. any appreciated. i able figure out issue on own. issue related cookie paths being case sensitive. virtual directory in localhost configured atsweb while making ajax calls constructing full url different case virtual directory (atsweb). since adfs cookie set path /atsweb, while doing ajax call browser not sending fedauth cookie server. leading sorts o

CakePHP - Letting the User Select the Layout -

im working on cakephp application display dvd collection. include dropdpwn menu user can select on view/colour scheme. nothing fancy, needs either change layout file css file. either work. any tips? can't seem figure out. regards, jon use themes switch either layout, css, or both. in appcontroller.php add: $this->theme = 'fancy'; this default layout in app/view/themed/fancy/default.ctp . choose want customize theme. if don't have special layout file fancy theme, cakephp default app/view/layouts/default.ctp . likewise, can choose provide special stylesheet in theme go in app/view/themed/fancy/webroot/css/default.css , if not cakephp use app/view/webroot/css/default.css . you can set user's theme selection cookie it's remembered. you didn't version of cakephp you're using, solution similar in either 2.x or 3. above links 2.x cookbook.

linux - scp gives "not a regular file" -

i have problem when using scp on linux, says "not regular file". looked @ other questions/answers that, can't find out what's wrong... wrote: scp aa@aa:/home/pictures/file.fits . to copy file.fits aa@aa , /home/pictures current directory. tried without using /home/ , didn't work neither... do understand what's wrong? i tested , found @ least 3 situations in scp return not regular file : file directory file named pipe (a.k.a. fifo) file device file case #1 seems likely. if meant transfer entire directory structure scp use -r option indicate recursive copy.

php - Echo only the day number -

this code right now: echo"<tr> <td>{$row['game_release']}</td> </tr>"; how echo day? example 2015-05-06 should echo '6'? this code found on stackoverflow, couldn't work: $string = "2010-11-24"; $date = datetime::createfromformat("y-m-d", $string); echo $date->format("d"); this should work you: here create new datetime object, format format want. echo"<tr> <td>" . (new datetime($row['game_release']))->format("j") . "</td> </tr>";

javascript - How to fix the offset x position of this div on click? -

Image
using vanilla javascript work on panel drag function. right stuck @ how correctly offset x position of dragger div not snap right of cursor. how correct x offset below? http://jsfiddle.net/leongaban/rrcl63y9/41/ window.onload = addlisteners(); var xposition = 0; function addlisteners() { document.getelementbyid('drag-container').addeventlistener("click", getclickposition, false); document.getelementbyid('dragger').addeventlistener('mousedown', mousedown, false); window.addeventlistener('mouseup', mouseup, false); } function getclickposition(e) { xposition = e.clientx; console.log(xposition); } function mouseup() { window.removeeventlistener('mousemove', divmove, true); } function mousedown(e) { window.addeventlistener('mousemove', divmove, true); } function divmove(e) { var max = 443; var x = event.clientx; if (x > 100 && x < max) { var div = docu

bluetooth - Android BLE sending message using synchronized method -

i need send message custom device via ble. i able send message below 20 bytes. used just: public boolean writecharacteristic(byte[] value){ if (mbluetoothgatt == null) { log.e(tag, "lost connection"); return false; } bluetoothgattservice service = mbluetoothgatt.getservice(uuid_service_generic_attribute); if (service == null) { log.e(tag, "service not found!"); return false; } bluetoothgattcharacteristic charac = service.getcharacteristic(uuid_write); if (charac == null) { log.e(tag, "char not found!"); return false; } charac.setvalue(value); boolean status = mbluetoothgatt.writecharacteristic(charac); return status; } but need send longer message in "as short time possible". found: android: sending data >20 bytes ble but need use synchronized method , oncharacteristi

algorithmic trading - MQL5: how do I automatically delete all un-triggered pending orders before placing new orders? -

i working on project requires me place buystop , sellstop pair of orders , on next bar if orders not triggered, delete them , place fresh ones. here code: if(logic == true && orderstotal() == 0) {bool res = ordersend(....);} if(orderstotal() != 0) { if(ordertype == op_buy || ordertype == op_sell) { bool del = orderdelete(....); } } this code placing orders , deleting them when testing. but when ea active on live server, not open orders because platform has orders of other instruments open. i'm sure there quite easy way around since novice, i'm not able figure out. old proverb says: measure twice before cut once there 4 values ( 3 pendings ) check before orderdelete() as definition states handle { op_{buy|sell}stop } orders, there following 3 items check: symbol() match ( not causing unwanted side-effects deleting other ea's or manual orders ) ordertype() match ( not ignoring actual state { pending | at_market

php - How to display MySQL data based on a column field -

i trying make appointment maker potential customers. hours available depend on personal schedules, don't want generic calendar type appointment maker. trying sql db 4 columns [id, made, date, time] following types [int, bit, varchar, varchar]. when selecting data , displaying it, attempting have if statement (php) determine if "made" "00" or "01" - 00 being "appointment available", 01 being "taken". the output display rows; however, showing rows "appointment available". 1 of rows has "01" in "made" column, , still showing available. php/sql script after connection: $sql = "select * $tname"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { if ($row["made"] = '00') { echo "<tr><td>" . $row["id"] . "</td><td>" . 'make appointment' . "</t

Fetch a post under certain no of words or characters in wordpress? -

is possible fetch post content under 140 characters or 25 words ? if possible how it here random post code // random post link function randompostlink(){ $randpostquery = new wp_query(array('post_type'=>array('tip'),'posts_per_page' => 1,'orderby'=>'rand')); while ( $randpostquery->have_posts() ) : $randpostquery->the_post(); echo the_permalink(); endwhile; wp_reset_postdata(); } character count easy, can add condition and char_length(post_content) < 140 clause. word count more difficult because there no built in mysql function counting words. can find simple solutions don't work in every use case complete solutions use stored functions . i'll use simple solution sake of example. what need add filter clause , apply additional conditions there: add_filter( 'posts_where', 'venki_post_length_limit' ); function venki_post_length_limit($where = '') { remove_filter( '

pandas - Time Series Plot Python -

Image
i using pandas , want make time series plot. have dataframe, , want plot date on x-axis number of units on y-axis. assuming need convert date object datetime before can make plot. df1_99.dtypes date object store_nbr int64 units int64 tavg int64 preciptotal float64 dtype: object df1_99 date store_nbr units tavg preciptotal 101885 2014-10-13 1 2 49 0.00 101996 2014-10-14 1 1 67 0.00 102107 2014-10-15 1 0 70 0.00 102218 2014-10-16 1 0 67 0.87 102329 2014-10-17 1 3 65 0.01 as dates strings can use to_datetime convert datetime objects: in [4]: df['date'] = pd.to_datetime(df['date']) df.info() <class 'pandas.core.frame.dataframe'> int64index: 5 entries, 101885 102329 data columns (total 5 columns): d

tsql - How do I use an SQLCMD variable to define a table name? -

so, using ssdt on visual studio 2013, can specify database name... create view vsample1 select * [$(randomdatabase)].dbo.tablename i can 4 part name create view vsample2 select * [$(randomserver)].[$(randomdatabase)].dbo.tablename but when try tablename, errors... create view vsample3 select * [$(randomserver)].[$(randomdatabase)].dbo.[$(randomtable)] it gives me error similiar error: sql71561: view: [vsample3] has unresolved reference object [$(randomserver)].[$(randomdatabase)].dbo.[$(randomtable)]. i've been looking @ sqlcmd variables window in project settings , have verified $(randomtable) variable defined tablename, still gives me build errors. why this, , how fix it? thanks i use pre/post deployment script create such view using sp_executesql , dynamic query. exec sp_executesql n'create view vsample3 select * [$(randomserver)].[$(randomdatabase)].dbo.[$(randomtable)]'

bash - shell script “${array[@]}” expansion: first and last entry have extra characters -

i have shell script uses array. script cycle through entries of array reason first , last entry has problem. the array: queue_names=( clqueue dlq expiryqueue ) the loop: for in “${queue_names[@]}” #do stuff done i can see in console , shows first entry shows: �clqueue. last entry shows: expiryqueue� i'm guessing these markers know start , end of array. unfortunately interfering functionality of script. use these queue names search , fails find because of added character. how rid of them or there code change avoid problem? “${queue_names[@]}” not "${queue_names[@]}" , because “” not "" . "smart quotes" aren't recognized quotes @ in bash; thus, effect same if expansion had been unquoted -- string-splitting , glob-expansion on array contents -- literal "quotes" grafted around start , end characters. you need use real quotes -- "" -- not opening/closing "smart quotes" created word proc

ecmascript 6 - Is ES6 class extend fully equivalent to Object.assign based extending of an object? -

in other words these 2 different blocks of code equivalent? es6 class extend based class child extends parent { // define subclass } var myinstance = new child(); object.assign based var myinstance = object.assign(new parent(), { // define subclass } in particular use case trying extend (facebook's) flux dispatcher. in examples use object.assign. es6 class extend, worried there subtle differences between 2 should stick object.assign. no, these code blocks not equivalent in class inheritance example new constructor makes objects having features parent class. extending objects via object.assign example of mixins . add properties 1 instance not change future children. unlike child classes, instance after extension still have constructor property pointing parent . means can't recognize extended child among non-extended, because have same constructor , operator instanceof give same result. can't access overridden methods in child, because l

c++ - Class overloading? -

this question has answer here: c++ class definition split 2 headers? 1 answer can have class in c++, in different .hpp files? because have class called map 5000 lines , wonder know if can split in 2 or 3 files same class name, , if other headers see class if wasn't split. no, can't that. besides, class way big. instead of trying split lexically, consider splitting semantically , multiple classes. read single responsibility principle . in short, there moderately serious design problem @ core of question.

ldap - split function to change order -

i used methode treepath [dc=example,dc=com,ou=usres] , need make ou=usres,dc=example,dc=com tried methode change order public static string changestring(string old) { old = old.replace('[', ' '); old = old.replace(']', ' '); old.trim(); string array[] = old.split(","); string result = ""; (int = 1; <= array.length; i++) { if(i != 1) result +=","+ array[array.length-i]; else result += array[array.length-i]; } but ou=usres,dc=com,dc=example how can change position of ou=users if using java, suggest use unboundid sdk . using dn class , can break down items public rdn[] getrdns(), returns rdn[] then reorder rdn[] , create new dn dn(rdn... rdns).

python generate json output from input file -

i have file similar input : lin1,line2,line3 lin1,line2,line3 lin1,line2,line4 and need convert json python. example, output should this: { "localport_starts_from": 1080, "config": [ { "1": "lin1", "2": "line2", "3": "line3" }, { "1": "lin1", "2": "line2", "3": "line3" }, { "1": "lin1", "2": "line2", "3": "line3" } ] } i have never worked json library, can show me example of how make this? use csv module parse input , json dump parsing. with open(input_file) f: rows = list(csv.reader(f)) # rows list of lists, each inner list contains values formerly separated commas # e.g. [["lin1", &qu

azure - Specify container deployment target with Kubernetes, e.g. Test/Production -

based on following setup of kubernetes on microsoft azure . i able deploy docker containers, using same configuration settings. we have 2 categories of containers, front-end , back-end, back-end consist of high intensive processing. latter want run on large instances, whereas front-end run on small instances. what best option separate these, gues labeling hosts. not able find in docs, or in examples. currently, adding labels hosts , restricting pods nodes appropriate label (e.g. 'large' / 'small') best way this. example, see examples/node-selection kubernetes has resource model which, once implemented, allow tell scheduler resources each pod needs , system ensure pod placed on node available resources. unfortunately, can tell design document on github, isn't implemented yet.

Multiple stylesheets for qt application -

is possible have multiple stylesheets single qt application , select of them needed? for instance, have different styles of push buttons within application. understand have like: qpushbutton { background-color: green; } and push buttons have green style per above line. however, have stylesheet somehow this: qpushbutton1 { background-color: blue; } qpushbutton2 { background-color: green; } i may need place several push buttons in application , each of those, want select either qpushbutton1 style or qpushbutton2 style. is feasible within 1 or multiple stylesheets, can use setstylesheet() enable custom style? thanks! you can use global stylesheet , set special settings each special object name. #qpushbutton1 { background-color: blue; } #qpushbutton2 { background-color: green; } but in case need set these object names in code. can done with: ui->pushbutton1->setobjectname("qpushbutton1"); ui->pushbutton2->setobjectname("qpushbutto

c# - WebApi 2 return types -

i'm looking @ documentation of webapi 2 , , i'm severely disappointed way action results architected. hope there better way. so documentation says can return these: **void** return empty 204 (no content) **httpresponsemessage** convert directly http response message. **ihttpactionresult** call executeasync create httpresponsemessage, convert http response message. **other type** write serialized return value response body; return 200 (ok). i don't see clean way return array of items custom http status code, custom headers , auto negotiated content though. what see like public httpresult<item> post() { var item = new item(); var result = new httpresult<item>(item, httpstatuscode.created); result.headers.add("header", "header value"); return result; } this way can glance on method , see whats being returned, , modify status code , headers. the closest thing found negotiatedcontentresult<t> , weird

php - How can I count the values in an array? -

i have attempted print values of array, cannot seem total count of array. i've tried count(), sizeof() , array_count_values neither of these functions seems job. $query = db::getinstance()->query("select orderstatus customerorders"); foreach ($query->results() $orderered) { $result_array = array($orderered); //print_r($result_array); $orderdata = array_map(function ($object) { return $object->orderstatus; }, $result_array); $test = json_decode(json_encode($result_array), true); $orvalue = serialize($test); $orvalue2 = unserialize($orvalue); $ordervaluenew = call_user_func_array('array_merge', $orvalue2); print_r($ordervaluenew);//debug }//close foreach loop results of array after printing: array ( [orderstatus] => 0 ) array ( [orderstatus] => 0 ) array ( [orderstatus] => 0 ) array ( [orderstatus] => 1 ) array ( [orderstatus] => 1 ) after performing count() , sizeof: 11111

dns - How do I add a subdomain to cloudflare in PHP "on the fly"? -

how add subdomain cloudflare account specific domain on fly? possible do, how other websites tend create subdomains in code? cloudflare has api, https://www.cloudflare.com/docs/client-api.html#s5.1 . there php library cloudflare well. https://github.com/vexxhost/cloudflare-api

JavaFX ImageView Transition -

i'm trying create image gallery , use image animations. problem imageview. play() rotatetransition method , call method time it's not working @ all. there should issue threads if called new thread nothing happening. there solution how work imageview , transitions generally? public class imagegallery extends imageview{ rotatetransition rt; public imagegallery() { setimage(new image("/img/01.jpg")); setpreserveratio(true); rt = new rotatetransition(duration.millis(800), this); rt.setbyangle(90); //this works not need //fitwidthproperty().addlistener(e -> rt.play()); } public void rotateright(){ rt.play(); //nothing //run later not working //platform.runlater(new viewtransition(this)); } } thanks as per user comments in question, adding mcve main.java import javafx.application.application; import javafx.geometry.pos; import javafx.scene.scene; i

angularjs - prevent ngMessage from showing before the form is submitted -

how can prevent ngmessages showing until user has either focused on input or form has been submit? you need manually validate/invalidate form. take @ using angular 1.3 ngmessage form submission errors

c - What is the advantage of specifying two types when creating a typedef'd struct? -

example 1: struct t{ int a; }; creates type struct t example 2: typedef struct { int a; } t; creates type t example 3: typedef struct t{ int a; } t; creates both types struct t , t i tend see example 3 lot, , i'm not sure why choose on example 1 or 2. are there advantages gain doing way? are there reasons people compatibility? is advantageous kind of scoping reason? i avoid doing example 3 way, because less maintenance on type, , restricts multiple ways of declaring same thing. however, reconsider it, if there benefits "double naming" technique. i tend see example 3 lot, , i'm not sure why choose on example 1 or 2. are there advantages gain doing way? i hold truth self-evident, namely cumbersome code cumbersome. prefer write t object; instead of struct t object; however, hard-core c coder might think hey, t struct, better call that , also, mitigates chance confusion you'

javascript - is it possible to attach the value in html elements like php have -

just increase knowledge, asking question you. think, possible attach value in html elements php. let brief example. in php. <img src="<?php echo $imgsource ?>" title="<?php echo $imgsourcetitle ?>" > can same in javascript or jquery. this. <img src="javascript:$(this).val(imgsrc)" title="javascript:$(this).val(imgsrctitle)" > it's not possible attach values that, because javascript code not parsed php , should executed once dom ready. change dom elements can use jquery inside $(document).ready() function. try this: $(document).ready(function() { $("#my_a").attr("href","http://google.it"); $("#my_a").attr("title", "my_title"); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a id="my_a">test</a> note code executed once pag

android - Javascript Testing Webservice Locally - CORS -

i'm attempting build jquery mobile application locally connect website via xmlhttprequest/xcrf/json. when attempting connect website following error: xmlhttprequest cannot load http://wwws.mydomain.com/rest/system/connect. wildcard '*' cannot used in 'access-control-allow-origin' header when credentials flag true. origin 'http://localhost' therefore not allowed access. i'm enabled cors on webserver (mydomain.com) per cors documentation: header set access-control-allow-origin "*" how can test webservice outside of website? when converted android app have similar problems? this part of security, cannot that. if want allow credentials access-control-allow-origin must not use *. check out these thread: cross origin resource sharing credentials

initialization - what initializers should a MKAnnotationView subclass have in Swift? -

i'm creating subclass of mkannotationview in project. needs have 2 properties storing subviews need initialize somewhere @ beginning. mkannotationview has 1 initializer listed in documentation, initwithannotation:reuseidentifier: , figured i'd override that: class pulsatingdotmarker: mkannotationview { let innercircle: uiview let outercircle: uiview override init!(annotation: mkannotation!, reuseidentifier: string!) { innercircle = ... outercircle = ... super.init(annotation: annotation, reuseidentifier: reuseidentifier) } ... } but causes runtime exception: fatal error: use of unimplemented initializer 'init(frame:)' class 'pulsatingdotmarker' ok, guess initwithannotation:reuseidentifier: internally calls initwithframe: , it's 1 should override instead. let's try that: class pulsatingdotmarker: mkannotationview { let innercircle: uiview let outercircle: uiview override

java - String split not working when there is no text in one side -

trying split "username:password" textarea, textareauser , textareapass, when input "username:" or ":password" stops. private void jbuttonstartactionperformed(java.awt.event.actionevent evt) { string[] lines = jtextareascrap.gettext().split("\n"); string[] divid = null; string user, pass; jtextareauser.settext(null); jtextareapass.settext(null); (int i=0; i<= lines.length; i++){ if (lines[i].contains(":")) { divid = lines[i].split(":"); user = divid[0]; pass = divid[1]; jtextareauser.append(divid[0]+"\n"); jtextareapass.append(divid[1]+"\n"); } } stack trace : exception in thread "awt-eventqueue-0" java.lang.arrayindexoutofboundsexception: 1 @ dorkcreator.dorkcreator.jbuttonstartactionperformed(dorkcreator.java:135)

lint - Is there a JavaScript technique to check for type equality in >,<,>=,<= operations? -

if have if(object.keys(obj) < 2) have bug might slip past tests if don't test objects property counts below , at/above 2. i.e. should have .length . if linter check type on either side of <,>,<=,>= warn this. alternatively, how else catch this? know more high quality tests catch this. problem never know when have enough high quality tests. if linter or other tool had ability warn of types in situation automatically caught. there no conclusive way check type equality in linter without running code because code can sorts of things , linter can't know might present in variable when used in comparison. consequence of using language such javascript not require strict typing. there variants of javascript such typescript (that can compiled javascript) offer more capabilities in regard.

QEMU on Linux works, but on Windows (probably 7/8) fails when -redir parameter is used -

i'm shipping project via qemu static build , linux vm. project uses port 4848 server configuration , port 8080 http (tools) , ephermal ports (49152+) spawned sub-projects use p2p websockets. note qemu binary qemu-system-... binary linux , qemu.exe on windows, statically compiled. on linux, i'm starting command. works charm expected: ./qemu -curses \ -kernel ../vmlinuz \ -initrd ../root.gz \ -l ./ \ -redir tcp:4848::4848 \ -redir tcp:8080::8080 \ -redir tcp:49152::49152 \ -redir tcp:49153::49153 \ -redir tcp:49154::49154 \ -redir tcp:49155::49155 \ -redir tcp:49156::49156 \ -redir tcp:49157::49157 \ -redir tcp:49158::49158 \ -redir tcp:49159::49159 \ -redir tcp:49160::49160 \ -redir tcp:49161::49161 \ -redir tcp:49162::49162 \ -append "quiet autologin loglevel=3" on windows xp vm (in virtualbox), command here works fine without issues once have approved firewall popup, seems not work on windows 8: start qemu.exe -kernel ..\vmlinuz -initrd ..\root.gz -l

graphics - glClear() Takes Too Long - Android OpenGL ES 2 -

i'm developing android app using opengl es 2. problem encountering glclear() function taking long process game appears jittery frames delayed. output of run of program timing probes shows while setting vertices , images atlas takes less 1 millisecond, glclear() takes between 10 , 20 milliseconds. in fact, clearing takes 95% of total rendering time. code based upon common tutorials, , render function this: private void render(float[] m, short[] indices) { log.d("time", "--start render--"); // handle vertex shader's vposition member int mpositionhandle = gles20.glgetattriblocation(rigraphictools.sp_image, "vposition"); // enable generic vertex attribute array gles20.glenablevertexattribarray(mpositionhandle); // prepare triangle coordinate data gles20.glvertexattribpointer(mpositionhandle, 3, gles20.gl_float, true, 0, vertexbuffer); // handle texture coordinates location int mtexcoordloc = gles

java - Spring: @Value vs. @Autowired -

i'm having issues injection in application i'm working on (using spring version 3.1.2). start with, i'm seeing lot of code this: @value("#{searchrequestbean}") private searchrequest searchrequest; @value("#{searchresponsebean}") private searchresponse searchresponse; @autowired private savedsearchservice service; each of these 3 appears have effect of autowiring specified bean/service class. don't understand is, what's difference between @value , @autowired in these cases? every example find online seems use @value inject values properties file. in case, searchresponse , searchrequest abstract classes. i'm hoping better understanding of me solve issues i'm having session bean. @value can used injecting default values. example inject default of string value of property file. in example, @value used set default value of class spring managed bean. @autowired can't used first example: it's not proper

sql server - Dropping SQL foreign key on a live database -

would run issue if tried dropping foreign key constraint on live sql database? want make sure there's no reason take database offline before doing this. dropping foreign key on live databases can done online without impacting users. may run data quality issues though, guess foreign key in place reason.

sql - How to reverse the string 'ab,cd,ef' to 'ef->cd->ab' -

when select table oracle, want handle 1 col'val : eg: 'ab,cd,ef' 'ef->cd->ab'; 'ab,bc' 'bc->ab'; 'acnn,bbccac' 'bbccac->acnn'; 'bbbdc,dccx,fff' 'fff->dccx->bbbdc' we have 2 tasks. first tokenize original strings. quite easy regular expressions (although there more performant approaches if dealing large volumes ). second task re-assemble tokens in reverse order; can use 11gr2 listagg() function this: with tokens ( select distinct col1, regexp_substr(col1, '[^,]+', 1, level) tkn, level rn t23 connect level <= regexp_count (col1, '[,]') +1 ) select col1 , listagg(tkn, '->') within group (order rn desc) rev_col1 tokens group col1 / here a sql fiddle .

whitespace - Is there a reference for what the white space character symbols represent in eclipse? -

Image
i'm doing text compare unit test in eclipse, , difference in whitespace, i've got 'show white space characters' on. question - there reference characters represent? i know >> symbol tab ("\t"), , imagine pi looking symbol new line ("\n"). u+0020 - • - space u+3000 - ˚ - ideographic space u+0009 - » - \t - tab u+000d - ¤ - \r - carriage return u+000a - ¶ - \n - line feed if want show/hide them on eclipse go preferences -> general -> editors -> text editors click on "configure visibility"

c++ - Writing to index of vector<int> beyond end of container -

why following work? thought writing an index of vector object beyond end of vector object cause segmentation fault. #include <iostream> #include <vector> using namespace std; int main() { vector<int> x(1); x[10] = 1; cout << x[10] << endl; } what implications of this? there safer way initialize vector of n elements , write those? should use push_back() ? somebody implementing std::vector might decide give minimum size of 10 or 20 elements or so, on theory memory manager has large enough minimum allocation size use (about) same amount of memory anyway. as far avoiding reading/writing past end, 1 possibility avoid using indexing whenever possible, , using .at() indexing when can't avoid it. i find can avoid doing indexing @ using range-based for loops and/or standard algorithms tasks. trivial example, consider this: int main() { vector<int> x(1); x.push_back(1); (auto : x) cout << <<

java - GAE Session id mismatch -

i running issue gae , session management. i have endpoint creates , stores user information in session upon successful login. however, unable retrieve information on client side. 1 thing i've noticed jsessionid , gae session id being different. session being created in google's datastore said, id differs 1 on client side (jsessionid). i have tested using servlet instead of endpoints , works charm... did in order pinpoint root cause downsize code basic example (see below). any idea root cause is? appreciate help. thanks. gae endpoint @apimethod(name = path.operationurl.test, path = path.operationurl.test, httpmethod = httpmethod.post) public response test(httpservletrequest request) throws databaseexception { string name = request.getparameter("name"); string pwd = request.getparameter("pwd"); //creating session httpsession session = request.getsession(); session.setattribute("name", name); session.setattri

android - How do I support large screens with low densities? -

i provide drawables different densities (mdpi, hdpi, xhdpi, etc.) , work fine, 10-inch 1280 x 800 tablet not high density (150dp?) , relatively low-density drawables scaled large size. doesn't good. my app larger like, want avoid copying more drawables bunch of different drawable-large-mdpi , drawable-large-ldpi , etc. folders. i don't know how many screens today still ldpi , mdpi, want support smaller screens while still looking on large screens, large screens lower density. there standard or recommended approach this?

Is there a way to undo git reset if files are not added? -

i stupidly ran git reset --hard on branch. in wrong branch. unfortunately, didn't perform git add . . there way work? no. not believe there method local code if never added local or git repository @ point. if added @ point, use git fsck last deleted data added @ point. there stack overflow here talking possibility

Django model -- Not able to show all the objects -

am new django. question is from a.models import customerrequest p = customerrequest.objects.all() print p result: [<customerrequest: customerrequest object>] why result showing eventhough have lots of data inside database model. please help

pandas - Print Column contents, according to particular contents of another column -

i have dataframe columns trip_id, service_id etc., like trip_id service_id 1 weekday 2 weekday 3 weekday 4 saturday 5 saturday 6 holiday 7 sunday i want print out trip_id's 'weekday', saturdays , holidays, separately. tried join_df.query(join_df['service_id'] == 'weekday') way, doesn't seem right one. tried print join_df[join_df.service_id =='weekdays'] didnt work. got empty dataframe output. could me please. thank you this looks typo (it's weekday not weekdays), either latter or using loc should work: in [11]: df[df.service_id == 'weekday'] out[11]: trip_id service_id 0 1 weekday 1 2 weekday 2 3 weekday in [12]: df.loc[df.service_id == 'weekday'] out[12]: trip_id service_id 0 1 weekday 1 2 weekday 2 3 weekday you can use query, syntax isn't quite

asp.net mvc - No default Instance is registered and cannot be automatically determined for type -

the definition of interface follows: public interface iapplicationsettings { string loggername { get; } string numberofresultsperpage { get; } string emailaddress { get; } string credential { get; } } the implementation of interface given below: public class webconfigapplicationsettings : iapplicationsettings { public string loggername { { return configurationmanager.appsettings["loggername"]; } } public string numberofresultsperpage { { return configurationmanager.appsettings["numberofresultsperpage"]; } } public string emailaddress { { return configurationmanager.appsettings["emailaddress"]; } } public string credential { { return configurationmanager.appsettings["credential"]; } } } i created factory class obtain instance of concrete implementation of webconfigsetting

hadoop - Design questions for long running yarn applications -

i trying write yarn application , hoping suggestions on few design questions had in mind. have gone through simpler sample apps distributed shell , variations of familiar basic api. create application has web interface user can interact , potentially provide kind of tasks (nature of tasks irrelevant). based on work, ui requests containers processing. the ideal arrangement comes mind application master provides web ui , no containers allocated until comes website , requests work. @ point, should able register new containers , allocate work them. if provides web ui , understanding chosen rm every time application submitted rm. means can have different ip and, therefore, different url upon application restart. behavior suggests should not used such purpose , potentially different application (non-yarn) can provide web ui , better suited it? in examples, have seen sample yarn apps requests containers part of invocation. can please point related apis allow requesting containers @

javascript - why doesn't jquery insert created span into two divs? -

i have following html: <div id="one"></div> <div id="two"></div> when run following code in jquery: $(function () { var span = $("<span>name</span>"); $("#one").append(span); $("#two").append(span); }); the span added last div: <div id="one"></div> <div id="two"><span>name</span></div> i'd expect added both divs, why it's not? each dom element can connected 1 specific parent. can't append same dom element 2 dom parents. refer so in case, must clone node. $(function () { var span = $("<span>name</span>"); $("#one").append(span); $("#two").append(span.clone()); }); <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <div id="one"></div> <div i

Qt: pull a section of image data on the fly -

i have large image(10000*10000) , several reasons cannot modify (like chop smaller tiles.) i don't want display whole image small section of improve gui efficiency. when user click , drag around, new part of image displayed in viewport. so, how pull section of image data on fly? i don't recall qt providing support working partial images in case of high resolutions. maybe libtiff . basically, image composed of either strips or tiles, can use tiffreadscanline() or tiffreadencodedstrip() respectively load portions of image. can compose image appropriate resolution viewport. alternatively, take @ qtiffhandler class, private class in qt not directly accessible, copy , if necessary modify source expose functionality. internally uses libtiff well.

internet explorer - ExtJs page makes no response while using the second time - on IE9 only -

when extjs page opened in ie9 first time, works properly. but when open same page second time don't response. can me. ps getting error on ie9 this sounds have problems ids , ext.cache. please check panels, windows , on. dont use property id use itemid instead. if use id in datasource check ids unique. otherwise become problems during rendering of gridpanel, treestore, combobox , on...

ruby on rails - Facebook put_wall_post results in sending crawler request to our url and this results in long wait -

i using ruby on rails , koala library interact facebook. use put_wall_post api post on user wall. api takes link , picture url among other parameters. before change on fb side few months back, picture url used show picture of our application (or whatever passed) when app posted on user's wall. fb later on changed mechanism , use link parameter. when call put_wall_post api, fb gets call, use link attribute send crawler scrap page @ link picture og:image tag. after crawler call returns, put_wall_post api returns. simple wall post results in 2 round trips. noticed take 2-3 seconds or takes 8-9 seconds before crawler comes our app page. put_wall_post api takes 2-3 on in cases 8-9 seconds before returns. , creating huge experience issue users since whatever doing (which resulted in wall post) takes long , have wait... note can't call put_wall_post on background thread outcome of needs reflected user in way... why fb have use mechanism opposed previous way of looking @ pictur