Posts

Showing posts from April, 2015

node.js - Geting fully qualified path in a nodejs traceback? -

a nodejs (v8?) backtrace can this: ... @ replserver.emit (events.js:95:17) @ replserver.interface._online (readline.js:203:10) inside javascript program produces this, how can definitively figure out fully-qualified path given in parenthesis? example, above have events.js or readline.js . looking @ code nodejs's lib/module.js see there _findpath() function. try: x = 'events.js' // see traceback above m = require('module'); m._findpath(x, m.globalpaths) but guessing here. there better way? thoughts on doing this? since no other suggestions indicated above, use: x = 'events.js'; m = require('module'); m._findpath(x, m.globalpaths)

javascript - In VS, is there a way to ignore errors on some typescript files but still compile them in? -

i'm writing large application several 3rd party libraries. right now, using post-build script concatenate of .js files together, along output of combined typescript files. works fine, makes source mappings off debugging. what i'd accomplish converting of 3rd party .js libraries typescript (and converting, mean renaming them .js .ts since typescript superset). here, can use typescript compiler output of combined typescript files accurate source maps debugging in typescript still work. however, issue i'm running 3rd party libraries have various errors, cannot build work. is there way in visual studio have existing typescript files compiled while having these third party libraries compiled ignoring errors , have result output 1 single javascript file? typescript able forgive whole host of errors , still provide compiled javascript, in cases error prevent - i.e. code no longer make sense compiler because cannot determine enough information. the solution splat

What is the difference between bitwise and logical operators inside conditional statements in C? -

there many questions on net refer differences between bitwise , logical operators. hoping have done search, none of them specialize whether same or not when used inside conditional statements nor refer exclusively c language. majority referred c++ , c# , not know if same answers applicable c language too. this example code wrote test going on: // difference between logical && , bitwise & // #include <stdio.h> #define true 123>45 #define false 4>2342 void print_tt(int table[][4]); int main(void) { int and_tt[2][4]; // , truth table int or_tt[2][4]; // or truth table // create truth table logical , bitwise , operator in 1 2d array and_tt[0][0] = true && true ? 1 : 0; and_tt[0][1] = true && false ? 1 : 0; and_tt[0][2] = false && true ? 1 : 0; and_tt[0][3] = false && false ? 1 : 0; and_tt[1][0] = true & true ? 1 : 0; and_tt[1][1] = true & false ? 1 : 0; and_tt[1][2] =

xcode - App crashes on iOS 8.1.3, can't reproduce issue -

i submitted app(spritekit game made using swift)to app store, , rejected because bug found in it. apple's exact response was: we discovered 1 or more bugs in app when reviewed on ipad running ios 8.1.3 on both wi-fi , cellular networks. specifically, app loads blank display. please refer attached screenshot more information. i sent blank screenshot (that grey), of no help. cannot reproduce issue app runs fine on ipad (8.1.3). know can be? tested same build sent apple. here's view controller code: super.viewdidload() let scene:skscene = gamescene() // configure view. let skview = self.view as! skview skview.showsfps = false skview.showsnodecount = false /* sprite kit applies additional optimizations improve rendering performance */ skview.ignoressiblingorder = true /* set scale mode scale fit window */ scene.scalemode = .resizefill scene.anchorpoint = cgpoint(x: 0.5, y: 0.5) s

ios - Swift Parse: can not retrieve the value of a bool in _User class -

Image
i developing app using swift , parse. reasons have implemented bool named "modified" in _user class. have been playing around swift , parse few months not make sense. when try retrieve value of "modified" bool keep on getting "false" value though set on "true" on parse server. here code: var modified: bool = pfuser.currentuser().objectforkey("modified") as! bool println("user modified bool set to: \(modified)") i have tried self.modified = pfuser.currentuser().valueforkey("modified") as! bool println("user modified bool set to: \(modified)") and self.modified = pfuser.currentuser()["modified"] as! bool println("user modified bool set to: \(modified)") do have make specific query or there way access value directly? edit i have implemented specific query. still "false" value though var querymainuser: pfquery = pfuser.query()

php - Check if the array can be sorted with a single swap of 2 elements -

i trying write function check if array can sorted single swap of values in array. for example: array(1,3,5,3,7) must return true , array(1,3,5,3,4) must return false . i tried following code below, i'm stuck it: $noofiterations = 0; for($x = 0; $x < count($a)-2; $x++) { if($a[$x] > $a[$x+1]) { $noofiterations ++; } } return $noofiterations >1; // below solution helped well. //$arr = [1, 3, 5, 3, 7]; //[1, 3, 5, 3, 4] $arr = [1, 3, 5, 3, 4]; $sortedarr = $arr; sort($sortedarr); print_r(array_intersect_assoc($arr,$sortedarr)); execute sort, compare original array sorted array using array_intersect_assoc() .... if difference more 2 elements, answer 'no'

c# - Visual Studio 2012 "the project file has been moved, renamed, or is not on your computer" -

i'd been working on visual studio project, , decided rename it. after little bit of renaming, under new name. tried open project in visual studio, , load failed, saying project file had been moved, renamed, or deleted. can edit project via c# project file among other class files, no matter how try rename files change back, load still fails. any ideas on how fix this?

ios - ios8: any method called prior to an app quitting? -

this question formulate action plan. background: cannot count on silent pushes app not running. need know recent presence of app running, without repeatedly posting database. ideally, when app running, irrelevant app responds properly, when force-quit, have not reference when happened. in ios8, seems have no guaranteed method hook allow ensure can thing prior app being shut-down. hooks can figure manage enter background or when resign active mode. hit db on , on user can re-enter app many times. not ideal. so question: there other hooks can manage grab last-ditch moment before app force-quit fire off quick async db update?

c# - EntityFramework two Foreign Keys Code First Migration issue -

i have mvc project using ef6.1 , need add foreign key model. quite new field , i'm getting error when adding migration. i have 3 tables in place (tags, content, pages) there fk between content & tags defined system created tags_content table me. pubic class content { int id { get; set; } string title { get; set; } public virtual icollection<tag> tags { get; set; } public static new void configure<tself>(entitytypeconfiguration<tself> configuration) tself : content { configuration.hasmany(o => o.tags) .withmany(t => (icollection<tself>)t.content) .map(c => c.totable("tags_content")); } } class page : content { // extends general content } class tag { int id { get; set; } string name { get; set; } // add column tags fk content or pages // purpose implement option of assigning additional page (or content) tag (the pageid null or page) public int? pageid { get; set; } public virtual page pa

php - Htaccess code to remove id and title from URLs? -

this question has answer here: .htaccess php rewrite view.php?visopslag=(id) 2 answers i have used .htaccess file add www. index url , remove .php , remove ?id= urls. this original url: www.site.com/article.php?id=12&title=title-text url .htaccess code www.site.com/article/12 this code have removed &title=title-text url. how remove &title= without title-text ? this: www.site.com/article/12/title-text .htaccess file options +followsymlinks rewriteengine on rewritebase / rewritecond %{http_host} ^ifeelvideos.com [nc] rewriterule ^(.*)$ http://www.ifeelvideos.com/$1 [l,r=301] # externally redirect /dir/foo.php?id=123 /dir/foo rewritecond %{the_request} ^get\s([^.]+)\.php\?id=([^&\s]+) [nc] rewriterule ^ %1/%2? [r,l] # internally forward /dir/foo/12 /dir/foo.php?id=12 rewritecond %{request_filename} !-d rewritecond %{request_filen

c++ - How can I change my program by using a summing statement instead? -

my c++ assignment write program display population estimate of each of countries (mexico , us) year, 1985 present. round population nearest whole number , display information in 3 columns. after doing that, modify program display same information when mexico's population exceeds population. did program correctly, when ran it gave me correct information , professor gave me 0 credit because wants me not use pow function summing statement, don't know how can that, sounds more complicated me. program wrote way don't know how change using summing statement: //program compute when mexico's pop exceeds pop #include<iostream> #include<cmath> #include<iomanip> using namespace std; int main() { int years; double uspop, mxpop; cout<<setw(7)<<"year"<<setw(13)<<"us pop"<<setw(13)<<"mex pop"<<endl; cout<<setprecision(0)<<fixed; for(years=1985;years<=2014;

pretty print - Python printing text: Highlight or mark some text in the string with indicators -

i want print string buffer (or byte array) contains special characters, such \t , \n, besides that, need print indicators below line indicate special part of string, below: a b c d \t , e f g \n ~~~~~~~~ ^^^^^ here questions: 1, escape char , normal char should printed in fixed width, see repr() function can not. 2, indicator below first line should printed. 3, if still use repr() function, think marker in second line should calculated dynamically, because repr() don't print texts in fixed width format, \t takes 2 chars. any 1 can help? btw: whole idea want create python pretty printer gdb show token when debugging parsing algorithm. edit: here example: print (repr("abcd\t,efg\n")) when run code, printed string has 12 element instread of 10, me, ff want hight token "efg", index 6,7,8 in string, if draw markers in second index 6,7,8, following. abcd\t,efg\n ~~~ because "\t" has 2 chars not one, means function re

windows - How to automatically move and click mouse key using at least batch files? -

i learned use batch files , javascript send keyboard presses , movements interface using. (see this question 1 of problems solved using information this question .) however, not experienced javascript or other language user yet proficient in writing general basic language. while know there many javascripts, heck other languages, allow create mouse movement , clicks (see here 1 possible way of doing this), figured there way of integrating batch files other form of programming language types creating mouse interaction, 1 person in link 2 integrated javascripts , batch files in order create key presses. i need know how can control mouse batch file using javascript if needed. (most needed no batch file command has jurisdiction on either mouse or keyboard directly.) theres configuration out on windows 7 called mouse keys. allows mouse controlled keyboard, of can control using jscript press keys. heres official link... http://windows.microsoft.com/en-us/windows7/use-mou

Matlab command window output of matrix values does not match output in file -

i have large matrix , want check on screen before continue use it. now, when displaying it, values wrong (off factor of 100), when print them file fine. (and here have loved post picture of this, don't have enough reputation...) here's code: disp(bigmatrix) %does not work way expected = 1:size(bigmatrix, 1) %from here j = 1:size(bigmatrix, 2) % fprintf(fileone, '%f', bigmatrix(i,j)); % fprintf(fileone, '\t'); % end % fprintf(fileone, '\r\n'); % end %here perfect so, in file have 1 @ end of each column disp() function (or typing name of matrix) gives me 0.0010. other values wrong well, might formatting issue. ideas what's going on? it formatting issue: because matrix big, couldn't scroll beginning matlab's standard format format short dec

android - Should we replace Action Bar by ToolBar? -

i have been using toolbar since added support v7 library . , think used well. there point can't understand. why google create such widget? mean can toolbar can using actionbar . why have use toolbar ? advantages of toolbar on actionbar if any? necessary replace actionbar toolbar ? any tips appreciated. , in advance. ps: found toolbar decandant of viewgroup . so, how use toolbar layout ? post codes of that? yes should replace actionbar new toolbar reasons 1) looks modern , follows new material design 2) unlike action bar , toolbar not part of window decor.you defines , place other widget...therefor have freedom place anywhere in parent layout. 3) have freedom put widget inside toolbar. 4) can define multiple toolbars. edit what meant can place other widgets(views) inside toolbar. create separate layout file toolbar(good reusability).in case file name main_toolbar . <?xml version="1.0" encoding="utf-8"?> &

java - How do I create spacing in between JButtons with GridBagLayout? -

Image
i trying create little main menu simple scheduling program right now, having bit of difficulty having space in between buttons. stick right next each other, there gap between each button. i have tried use weightx, weighty commands nothing seems change. have blank space between edges of gui , sides of buttons, , between each button. here's screenshot import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; public class scheduler { jbutton vday, vweek, task, exit; jframe wframe, dframe, tframe; jlabel head; public void createframe() { jframe frame = new jframe("main menu"); buttonlistener btnlst = new buttonlistener(); jpanel panel = new jpanel(); panel.setlayout(new gridbaglayout()); gridbagconstraints c = new gridbagconstraints(); c.weightx = 1; c.weighty = .25; c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.fill = gridbagconstraints.both; hea

angularjs - How to remove timezone in JavaScript? -

i time , format {{transaction.submittime | date:'yyyy-mm-dd hh:mm:ss z'}} it returns 2015-04-23 02:18:43 +0700 but want show without +0700 , hour plus 7. how can that? try d = new date(); d.tolocalestring(); // -> "2/1/2013 7:37:08 am" d.tolocaledatestring(); // -> "2/1/2013" d.tolocaletimestring(); // -> "7:38:05 am"

internet explorer - IE Options: How to enable Proxy settings sections -

Image
![hi all, though having admin rights, not enable proxy settings. i've tried using regedit still not enable this. also, need add few more urls needs added in proxy. please why proxy settings section not enabled?] 2 read doc.. configure internet explorer use proxy server

constructing a multipart form request in a adapter using MobileFirst version 6.3 -

i have application need construct multipart form in http adapter , send webservice using wl.server.invokehttp. there way can achieve this?. javascript adapters not support multi-part. you have 2 options: in mfpf 6.3, use java in javascript adapters upgrade mfpf 7.0, provides java adapters you can try implement following (or similar specific use case): how can make multipart/form-data post request using java? if form post not directed @ backend protected worklight's security framework, opt not use adapters @ all: sending multipart/formdata jquery.ajax

ckeditor - Encoding of entities - no perfect solution? -

Image
we use ckeditor plugin redmine ( https://github.com/a-ono/redmine_ckeditor ) , experience following problem: if encoding of basicentities / entities set false, xml/html text not shown correctly when stored via ckeditor ( https://github.com/a-ono/redmine_ckeditor/issues/158 ), there problem pressing show sourcecode button or editing content repeatedly if these parameters not set, problems quotes in code blocks (shown &quot), links parameters (& incorrectly encoded) , wiki links umlauts or other accentuated letters broken ( https://github.com/a-ono/redmine_ckeditor/issues/132 ) as a-ono, dev of plugin, puts it: "there seems no perfect solution." i found http://komlenic.com/246/encoding-entities-to-work-with-ckeditor-3/ , http://ckeditor.com/forums/support/inside-tries-create-paragraph#comment-54348 , additional information "forcesimpleampersand:true" config.entities_latin = false;, i'm not sure how proceed. in process of moving additional us

A declaration cannot be both 'final' and 'dynamic' error in Swift 1.2 -

the declaration of value below import foundation class aaa: nsobject { func test2() { self.dynamictype } } extension aaa { static let value = 111 } causes following compilation error a declaration cannot both 'final' , 'dynamic' why happen, , how can deal this? i using swift 1.2 (the version shipped within xcode 6.3.1 6d1002) this issue arises because swift trying generate dynamic accessor static property obj-c compatibility, since class inherits nsobject . if project in swift only, rather using var accessor can avoid issue via @nonobjc attribute in swift 2.0: import foundation class aaa: nsobject {} extension aaa { @nonobjc static let value = 111 }

css - How to ensure all links in an email template of some color and cross-client compatible? -

i trying create email template below i have style in <style type="text/css"> .rich-text a{color:#ffffff !important;} .ii a[href] { color:#ffffff!important;} </style> and inside template have in below <p class="rich-text" style="color:#ffffff !important;"> <font color="#ffffff" style="color:#ffffff !important;"> <xsl:value-of select="body/contents" disable-output-escaping="yes"/> </font> </p> now problem can contains blob of text including links. links come out blue color on email clients such gmail. seems gmail stripping out .rich-text style added @ top. how ensure gets applied? want links in template color white. different e-mail clients applies different styles. it's best use inline css. can check if style supported in this list of common email clients . remember, client may use safe (or old/simple) client not support css/html

linux - codeigniter autoload file issue -

i have uploaded codeigniter file in linux server using php version 5.5. got issue on application\config\autoload.php file. $autoload['libraries'] = array(); //default code //$autoload['libraries'] = array('database'); when run program using default code. program runs fine. when load database library, didn't error or output. shows blank page. you can check here . sample code: class test extends ci_controller { function show() { echo 'methos call'; } } this program runs in local without issue. server problem or codeignitor issue. thanks in autoload.php file change $autoload['libraries'] = array('database') then go database.php , configure database.(bottom of page). if codeignitor 2.0.0 $db['default']['hostname'] = 'localhost'; $db['default']['username'] = ''; $db['default']['password'] = ''; $db['defau

ios - Difference between setting an NSMutableURLRequest header and adding one -

i wondering difference between setting header value , adding header value nsmutableurlrequest is. sounds sort of obvious but, example, can't use addvalue every time? setting header doesn't exist throw error? adding header when exists in request overwrite existing value? example let request.nsmutableurlrequest(url: nsurl(string: "someurl")!) request.addvalue("application/json", forhttpheaderfield: "content-type") ... i think discussion in apple's official doc quite clear: addvalue this method provides ability add values header fields incrementally. if value set specified field, supplied value appended existing value using appropriate field delimiter. in case of http, delimiter comma . setvalue the new value header field. existing value field replaced new value. setvalue replaces. addvalue appends delimiter

javascript - Avoid duplication using jquery -

how avoid duplication of data using jquery? code : <button id="gen">generate</button> <table id="report" border="1" style="visibility:hidden"> <tr> <th>sl.no.</th> <th>district name</th> </tr> </table> js: $("#gen").click(function(){ $("#report").css("visibility","visible"); for(var i=0; i<5; i++){ var row='<tr><td>('+(i+1)+')</td></tr>' $("#report").append(row); } }); each time when clicking button, same data shown. how avoid it? sqlfiddle: http://jsfiddle.net/etdx5o08/ do this: $("#gen").click(function() { $("#report").parent().show(); var rows=''; (var = 0; < 5; i++) { rows = rows+'<tr><td>(' + (i + 1) + ')</td><td></td></tr>

c# - Reading xml web response -

when send request webservice following response: <?xml version="1.0" encoding="utf-8"?>n<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:header xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"/> <soap-env:body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <web:xxxresponse xmlns:web="http://xxxxx"> <repliek> <antwoorden> <antwoord> <referte>xxx</referte> <inhoud> <persoon> <insz>xxx</insz> <naam> <achternamen> <achternaam>xx</achternaam> </achternamen> <voornamen> <voornaam>x x</voornaam> </voornamen>

excel - How to underline the last row before the counta total? -

so figured much: dim mylastrow long 'find last row in column mylastrow = cells(rows.count, "a").end(xlup).row ' insert count after last cell in column cells(mylastrow + 1, "a").formula = "=counta(a2:a" & mylastrow & ")" this count column , put total on bottom. how underline last row before total? this should trick. dim mylastrow long 'find last row in column mylastrow = cells(rows.count, "a").end(xlup).row 'insert count after last cell in column cells(mylastrow + 1, "a").formula = "=counta(a2:a" & mylastrow & ")" cells(mylastrow + 1, "a").borders(xledgetop) .linestyle = xlcontinuous .colorindex = xlautomatic .tintandshade = 0 .weight = xlmedium end

php - Wordpress Bootstrap html5 wp_enqueue_style -

i'm trying wp_style_add_data bootstrap html5shiv.min.js , respond.min.js tried: wp_enqueue_style( 'theme-ie', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', array( 'theme-style' ), '3.7.2' ); wp_enqueue_style( 'theme-ie-2', 'https://oss.maxcdn.com/respond/1.4.2/respond.min.js', array( 'theme-style' ), '1.4.2' ); wp_style_add_data( 'theme-ie', 'conditional', 'lt ie 9' ); wp_style_add_data( 'theme-ie-2', 'conditional', 'lt ie 9' ); but adding if lt ie 9 twice: <!--[if lt ie 9]> <link rel='stylesheet' id='theme-ie-css' href='https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js?ver=3.7.2' type='text/css' media='all' /> <![endif]--> <!--[if lt ie 9]> <link rel='stylesheet' id='theme-ie-2-css' href='https://oss.maxcdn.com/respond/1.4.2/respond.min.js?ver=1.4.2'

wysiwyg - CKEditor 4.5 insert widget into other widget -

ckeditor 4.5 beta should allow nested widgets. http://ckeditor.com/blog/ckeditor-4.5-beta-released can me figure out how can test nested widgets? i've downloaded 4.5 beta, created simplebox widget instructions in tutorial (but without 'allowedcontent' filters). still cannot put 1 widget inside editable of another. can clarify i'm doing wrong or point me correct example. thank you! the easiest way test nested widgets checking sample created development purposes. it's stripped packages, need clone repo. git clone https://github.com/ckeditor/ckeditor-dev.git git co major and see file: ckeditor-dev/plugins/widget/dev/nestedwidgets.html . it's nothing more image2 , placeholder plugins running simplebox. can check simplebox inside simplebox inside simplebox inside simplebox... ;)

Coloring an 8-bit grayscale image in MATLAB -

Image
i have 8-bit grayscale image different values (0,1,2,3,4,..., 255). want color grayscale image colors blue, red, etc. until now, have been doing coloring in greyscale. how can actual colors? here code have written far. searching values white in image , replacing them darkish gray: for k = 1:length(tiffiles) basefilename = tiffiles(k).name; fullfilename = fullfile(myfolder, basefilename); fprintf(1, 'now reading %s\n', fullfilename); imagearray = imread(fullfilename); %// logic replace white grayscale values darkish gray here ind_plain = find(imagearray == 255); imagearray(ind_plain) = 50; imwrite(imagearray, fullfilename); end what asking perform pseudo colouring of image. doing in matlab quite easy. can use grayscale intensities index colour map, , each intensity generate unique colour. first, need create colour map 256 elements long, use ind2rgb create colour image given grayscale intensities / indices of image.

ember.js - How to pass multiple (dynamic) Parameter to store.find() method // avoid duplicate entrys -

we have search formular multiple (dynamic generated) input fields. our server rest api spring mvc powered , accepts call this: /rest/search/1?identnummer=0000000&parameter2=xy&parameter3=zy in search method of formular (action: search) i collect parameters , build string this: queryparams = 1?identnummer=0000000&parameter2=xy&parameter3=zy and call store.find method: that.store.find('trefferliste', queryparams).then(function(response) { console.log("success loading hit list...", response); }, function(error) { console.error(error); that.transitionto('trefferliste'); } }); i overwrote buildurl method (removed encodeuricomponent() if (id && !ember.isarray(id)) { url.push(encodeuricomponent(id)); } for trefferlisteadapter app.trefferlisteadapter = app.applicationadapter.extend({ buildurl: function(type, id) { var url = []; var ho

publish - How to make my Android-Chromecast app visible in the official Chromecast apps Google page? -

i succesfully integrated android app chromecast, have published both , working great, in developer console enabled listing app switch , filled required fields app isn't visible in chromecast.com/apps must more? published them 3 days ago thank in advance

r - Using lapply with colorRampPalette -

i have following vector: x <- c(1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 5, 5, 5, 5, 5, 5) what want assign color each number using colorramppalette . why command gives more output expected: library(rcolorbrewer) mycolorfunction <- colorramppalette(brewer.pal(9,"set1")) unlist(lapply(as.list(x),mycolorfunction)) it gives this: [1] "#e41a1c" "#e41a1c" "#e41a1c" "#e41a1c" "#999999" "#e41a1c" "#999999" "#e41a1c" "#999999" "#e41a1c" "#999999" [12] "#e41a1c" "#999999" "#e41a1c" "#999999" "#e41a1c" "#999999" "#e41a1c" "#ff7f00" "#999999" "#e41a1c" "#ff7f00" [23] "#999999" "#e41a1c" "#ff7f00" "#999999" "#e41a1c" "#7e6e85" "#e1c62f" "#999999" "#e41a1c" "

nfc - Can I access a device using Android HCE from a device running Android 4.3 (or below)? -

i have developed app emulates contactless smartcard using android hce , app accesses (reads) emulated card. both run on android 4.4 (kitkat) , above. no develop reader-side devices run android 4.3 (or lower). possible access device uses android hce device api level < 19? not want use android beam feature. no, that's not possible. default, 2 android devices (when held together) communicate in peer-to-peer mode . case if 1 or both devices support host card emulation. once android device established peer-to-peer mode link, won't try use reader/writer mode on same target. in order permit android hce-emulated card visible (accessible from) second android device, second device must disable peer-to-peer mode capabilities , operate in reader/writer mode. this android reader mode api (that seem use in reader app android 4.4). using nfcadapter.enablereadermode() flags flag_reader_nfc_a , flag_reader_nfc_b forces android act in reader/writer mode , disable peer

xcode - ios storyboard place a view to right of the middle of superview -

search bit not find solution. suppose have label , text field. want textfield aligned 10 pixel right of middle of superview having width of half of superview - 20 pixel. i.e. 10 px gap in both side. how can achieve in storyboard? possible or have write code that? label half of superview - 20 px width. left aligned. 10 px left gap. if understand correctly, want both views having same width? |-10-[uilabel]-20-[uitextfield]-10-| then 1 way go create constraints leading margin uilabel horizontal spacing between uilabel , uitextfield trailing margin uitextfield same width of uilabel , uitextfield

java - Changing the default cursor to busy cursor does not work as expected -

after many attempts trying make jprogressbar work expected, became successful @ achieving goal. had used @madprogrammer 's advice , used swingworker program work want. now, want cursor change busy_cursor http://telcontar.net/misc/screeniecursors/cursor%20hourglass%20white.png when jprogressbar goes 0% 100%. i've googled , found out that setcursor(cursor.getpredefinedcursor(cursor.wait_cursor)); is code it. i've tried not work expected. relevant piece of code: jprogressbar progress; jbutton button; jdialog dialog; //fields of gui class progress=new jprogressbar(jprogressbar.horizontal,0,100); button=new jbutton("done"); dialog=new jdialog(); //done methods progress.setvalue(0); progress.setstringpainted(true); progress.setborderpainted(true); //also done methods button.addactionlistener(this); //also done methods dialog.setlayout(new flowlayout(flowlayout.center)); dialog.settitle("please wait..."); dialog.s

r - How to efficiently find pattern in one column and assign a corresponding value to another column in a list of data frames? -

i have list of 15 data frames each 13 columns (time + 6 stations each 3 layers) , 172 rows. want collapse columns (observations @ stations) in 2 columns (one station , 1 observation) applying function on whole list. here use gather tidyr . in addition, want find pattern (upper, middle or lower layer) in 1 of columns , assign new value (depth) in new column. use ddply plyr , grep. problem is veryyyy slow. guess created bottleneck limited r knowledge. bottleneck , how improve it? an example: data <- list(a = data.frame(time = (1:180), alpha.upper = sample(1:180), beta.middle = sample(1:180), gamma.lower = sample(1:180)), b = data.frame(time(1:180), alpha.upper = sample(1:180), beta.middle = sample(1:180), gamma.lower = sample(1:180))) > data $a time alpha.upper beta.middle gamma.lower 1 1 133 179 99 2 2 175 147 56 3 3 169 9 2

c++11 - How to convert every element of a string to int -

i trying total sum of every digit of big number stored in string variable. first thing convert each element int , add total sum. question how can convert element of string int? tried using std::stoi got compiler error. here's code anyway: std::string x = "7825394359371498287"; int sum = 0; (int = 0; < x.size(); ++i) { sum += std::stoi(x[i]); } the problem std::stoi wants string , give single character. this problem can solved knowing text encoding used can convert digit character corresponding number. take example common encoding system ascii , if see table in provided link tell character '7' have ascii value 55 , while character '0' have value 48 . should tell number 7 character '7' have subtract '0' '7' (i.e. 55 - 48 ), so: sum += x[i] - '0';

ruby - _destroy isn't working in Coocon gem with Rails 4 -

i have same issue one but solution didn't me. here strong params: def request_params params.require(:request).permit(:name, :address, :phone, :mobile, :type, :filled_cartridges_attributes => [:cartridge_name,:client_id,, :count,:_destroy,:id], so have :_destroy , :id. guy in previous forgot add :id strong params. adding id solved problem. here request model: has_many :filled_cartridges, inverse_of: :request, dependent: :destroy accepts_nested_attributes_for :filled_cartridges, :reject_if => :all_blank, allow_destroy: true and how params after submitting: request: ...some params.... filled_cartridges_attributes: !ruby/hash:actioncontroller::parameters '0': !ruby/hash:actioncontroller::parameters cartridge_name: hp laserjet3000 _destroy: 'false' id: '1' '2': !ruby/hash:actioncontroller::parameters cartridge_name: new 9 _destroy: '1&

javascript - MongoDB query to remove duplicate documents from a collection -

i take data search box , insert mongodb document using regular insert query. data stored in collection word "cancer" in following format unique "_id". { "_id": { "$oid": "553862fa49aa20a608ee2b7b" }, "0": "c", "1": "a", "2": "n", "3": "c", "4": "e", "5": "r" } each document has single word stored in same format above. have many documents such. now, want remove duplicate documents collection. unable figure out way that. me. an easy solution in mongo shell: ` use your_db db.your_collection.createindex({'1': 1, '2': 1, '3': 1, etc until reach maximum expected letter count}, {unique: true, dropdups: true, sparse:true, name: 'dropdups'}) db.your_collection.dropindex('dropdups') notes: if have many documents expect procedure take long time b

javascript - Text input fields sometimes not responding because of labels -

i'm making website using materializecss framework , encouraged bug inputs not responding correctly. this happens when clicking example on first input, , targeting higher part of second input. happens first input still being clicked. it seems <label>name1</label> are causing it. there way solve problem? here example . you used same id ( input_text ) every input, id unique, try using different id every input , link each label's for attribute id. here's fixed jsfiddle

javascript - how to prevent the jsp to execute -

var answer = confirm("do want save?"); alert(answer); if(answer==true){ <% session.setattribute("confirm", "true"); %> }else if(answer==false){ <% session.setattribute("confirm", "false"); %> } what wrong code? made confirm dialog. whenever clicked cancel button, set attribute of confirm false. when clicked ok, did codes inside true condition did jsp code inside false condition. ignore condition. tell me whats wrong? the jsp executed on server before javascript runs on browser (before sent browser). for server-side execution, javascript ignored. part of output, html. all server sees is: jspout.write("var answer = ......... "); session.setattribute("confirm", "true"); jspout.write("} else if ..... "); session.setattribute("confirm", "false"); as can see, there no conditional execution here @ all. if want inte

python - How can I place a best fit line to the plotted points? -

i have simple plot containing 2 datasets in arrays , , trying use regression calculate best fit line through points. however line getting way off left , of data points. how can line in right place, , there other tips , suggestions code? from pylab import * = array([-13.74,-13.86,-13.32,-18.41,-23.83]) gra = array([31.98,29.41,28.12,34.28,40.09]) plot(gra,is,'kx') (m,b) = polyfit(is,gra,1) print(b) print(m) z = polyval([m,b],is) plot(is,z,'k--') if curious, data bandgap of silicon transistor @ various temperatures. you have careful of arrays pass x coordinates , y coordinates. consider have data values y @ positions x . have evaluate polynomial wrt. x too. from pylab import* = array([-13.74,-13.86,-13.32,-18.41,-23.83]) gra = array([31.98,29.41,28.12,34.28,40.09]) # rename variables clarity x = gra y = plot(x, y, 'kx') (m,b) = polyfit(x, y, 1) print(b) print(m) z = polyval([m,b], x) plot(x, z, 'k--') show()

jquery - Run function on page load (Refresh RSS feed with new URL) Javascript -

i have app want display different rss feeds on 1 page, when corresponding team clicked. for example, when click "aberdeen" want page show rss aberdeen. when click "celtic", want same page display rss celtic. i attach code in 1 section - when page #feed loads, need run getfeed() function. i using jquery mobile. html "feed" page <div data-role="page" id="feed"> <div data-role="header"> <h1 id="fheader">header</h1> </div> <div data-role="content"> <a href="#" data-role="button" data-icon="plus">add teams</a> <ul data-role="listview" class="list" data-inset="true" > </ul> </div> </div> function getfeed var feedurl="http://www.football365.com/arsenal/rss"; var n = 12; function getfeed(url, success, n

debugging - iOS building custom rating control issue -

Image
i know there's lots of 3rd party solutions out there, i've decided build 1 myself in full control of animations , learn new. it seems of time made through subclassing uicontrol , tracking touches, i've used different approach. create system buttons images. way nice highlight animation on press free. anyway, works quite nice until press on fast. here's gif of what's happening. sometimes, if fast full star gets stuck. i'll try explain what's happening behind animation. since full , empty stars have different color, change tint color of button each time becomes full or empty. animation see separate uiimageview added on top of button right before beginning of animation block , removed in completion block. believe on emptying star animation not fired , image not removed in completion block. can't catch bug in code. i added debugging code see if block makes star empty fired. seems is, , completion block called. 2015-04-23 13:00:00.416 reratingcon