Posts

Showing posts from February, 2014

Mongoose: how to define a combination of fields to be unique? -

if had schema this: var person = new schema({ firstname: string, lastname: string, }); i'd ensure there 1 document same firstname , lastname. how can accomplish this? you can define unique compound index using index call on schema: person.index({ firstname: 1, lastname: 1}, { unique: true });

windows - How to real time convert Ethernet packet to Wireless packet? -

in case of ethernet header have destination mac address , source mac address. in case of 802.11 packets there @ minimum 3 mac addresses , in cases 4 mac addresses. how 802.11 packet formed using 802.3 packet? know native wifi doing conversion in case windows. want know how achieving? "how 802.11 packet formed using 802.3 packet?" the conversion (between 802.3 , 802.11 mac frames) happens @ link layer. implementation details platform , driver-dependent. an example of how these done in linux kernel (using soft-mac 802.11 driver): http://lxr.free-electrons.com/source/net/wireless/util.c#l412 http://lxr.free-electrons.com/source/net/wireless/util.c#l530

xml - Haxe Iteration of defining variables -

i have chunk of code parsing xml variables. on 1 of variables, there never more 12 there may less. trying define each of these variables multiple times second. need them defined if have variable because right now, if there less 12 variables, program crashes. right code below works, if there 12 values present in xml document. how itterate code don't have list of "if != null" statements? var _vol1 = (ipts[0].volume); var _vol2 = (ipts[1].volume); .... .... var _vol12 = (ipts[11].volume); this code works when 12 values in xml document crashes if there less 12 might case. how structure code define/redefine variable if there value , not null? what needs iterated???? if ((ipts[0].volume) != null ){ var _vol1 = (ipts[0].volume); } i researched on haxe website wasnt sure applicable. syntax , programming not greatest. help. sorry if bad question. update: here complete code of now. doesn't crash not defining volume variables anymore added if statements var...

sql - Return values based matching times and days -

i'm attempting match results of employees schedules vs reporting schedules. need output report shows reports , assigned them. place i'm having trouble based on day of week. my reportschedule table looks this: ╔══════════════╦══════════════╦══════╦══════╦══════╦══════╦══════╦══════╦════╗ ║ reportid ║ time ║ m ║ tu ║ w ║ th ║ f ║ sa ║ su ║ ╠══════════════╬══════════════╬══════╬══════╬══════╬══════╬══════╬══════╬════╣ ║ 1001 ║ 06:18:00 ║ 1 ║ 1 ║ 1 ║ 1 ║ 1 ║ 0 ║ 0 ║ ║ 1002 ║ 06:48:00 ║ 0 ║ 0 ║ 0 ║ 0 ║ 0 ║ 1 ║ 1 ║ ║ 1003 ║ 07:18:00 ║ 1 ║ 1 ║ 1 ║ 1 ║ 1 ║ 1 ║ 1 ║ ╚══════════════╩══════════════╩══════╩══════╩══════╩══════╩══════╩══════╩════╝ my employeesschedule table looks this: ╔════════════╦══════════╦═════════════╦═══════════╦═══╦════╦═══╦════╦═══╦════╦════╗ ║ employeeid ║ reportid ║ reportstart ║ reportend ║ m ║ tu ║ w ║ th ║ f ║ sa ║ su ║ ╠════════...

android - Robolectric: failed on start test cause of wifi start scan -

i've created little test under robolectric. unfortunately, must comment these lines having success test : public class myapplication extends application { private void setupapplication() { .... //mnetworkevents = new networkevents(this, eventbus.getdefault()) // .withpingurl(buildconfig.ping_server_url) // .withpingtimeout(buildconfig.ping_timeout); } this class "networkevents" allows test internet connectivity. , in class there call: public static void startwifiscan(context context) { wifimanager wifimanager = (wifimanager) context.getsystemservice(context.wifi_service); wifimanager.startscan(); } and problem start wifi scan... this error: java.lang.nullpointerexception @ android.net.wifi.wifimanager.startscan(wifimanager.java:995) how can run test without comment these line in application class ?? thanks guys! i've tried reproduce error , found same. thinking should first set wifimanager start...

Java 8 : Invoke Interface's static method using reflection -

i want invoke static method of java 8 interface using reflection api. public interface timeclient { static void teststatic() { system.out.println("in static"); } } i able invoke default method of interface unable invoke static method. i see no problems: timeclient.class.getdeclaredmethod("teststatic").invoke(null); works without problems , prints "in static". getmethod works expected: timeclient.class.getmethod("teststatic").invoke(null);

xcode - Unable to install iOS Simulator 8.4 -

Image
i have xcode version 6.4 (6e35b), os x v 10.10.4 , ios simulator not show in preferences: if click "check , install now" nothing happens. have machine next me , installed correctly. ideas how fix it? xcode 6.4 comes ios 8.4 simulator runtime. a default set of devices should created automatically. if deleted them, can recreate them xcode's devices window or command line using xcrun simctl create ...

sql - Avoiding lots of counters in Java -

in java project, need read file 1.6 million lines. each line represents 1 action users have done in 1 day. there 83 different possible actions if i'm not wrong. i need analyze file follows , store found statistics in csv files: generally: count how 1 action has occurred (numbers go high half million) but there should separate files: how has 1 action occurred per hour? (24 rows in csv file) how has 1 action occurred per user? (about 20 different users - file each one) how has 1 action occurred per user per hour? (separate file per user, 24 rows in it) and on top, there 3 different channels (html, mobile, telephone) things can occur (also saved in log-file), need create 1 folder every channel , things mentioned above each one. the question: how can store/count efficiently? run-time not of problem (it shouldn't run day it's no problem it takes half hour) how count it? i can't create many counters (amount huge), , int[] aren't convenient in opi...

objective c - iOS - Custom Confirmation view -

Image
i working on creating custom control once user presses button , action completes. i'm trying replicate behavior of apple music app when album added shows confirmation view in center check mark shown below. there similar cocoa controls available use? (swift) create singleton class class customview: uiview { class var sharedview : customview { struct static { static var instance : customview? static var token : dispatch_once_t = 0 } dispatch_once(&static.token) { static.instance = customview() } return static.instance! } override init(frame: cgrect) { super.init(frame: frame) } required init(coder adecoder: nscoder) { super.init(coder: adecoder) } func showinview(view:uiwindow) { var image = uiimage(named:"someimage") self.frame = view.frame var originx = view.center.x var originy = view.center.y let centerview = uiimageview() centerview.center = cgpointmake(originx, o...

go - Builtin func "append" in method for pointer receiver -

having 2 types: type headers []headeritem type headeritem struct { // 1 doesn't matter. other type name string value string } i add function slice receiver. how can (pseudo-code): func (h *headers) addheaderitem(item headeritem) { h = &(append( *h, item )) } the compiler complains it, doesn't work. i tried: func (h headers) addheaderitem(item headeritem) { h = append( h, item ) } this compiles doesn't want: when later on range ing on items, empty result. inside addheaderitem() method h pointer. not want change pointer pointed value: func (h *headers) addheaderitem(item headeritem) { *h = append(*h, item) } testing it: h := headers{} fmt.println(h) h.addheaderitem(headeritem{"myname1", "myvalue1"}) fmt.println(h) h.addheaderitem(headeritem{"myname2", "myvalue2"}) fmt.println(h) output: [] [{myname1 myvalue1}] [{myname1 myvalue1} {myname2 myvalue2}] try on go playground . ...

php - live streaming using red5 -

i installed red5 server on ubuntu 12.04 server . , running. i trying live streaming. set rtmp protocol well. port 1935 listening red5. i installed mididemo app , started flash media encoder start streaming. when go demo apps publisher.html can see streaming means rtmp working. i tried couple of players on site stream , work when flash media encoder streaming. how can stream on site without flash media encoder? want, when user comes site have option start , stop streaming. web site php. you can use publisher app "publish", similar using fmle. 1 difference audio , video codecs available in demo app sorenson video , nellymoser audio.

How to pass meteor template helper as a parameter to meteor event handler? -

here's problem: in template file: <template name="button"> <button class="btn-class">{{disp}}</button> </template> in js: template.button.events({ 'click': function(event, templ) { if (this.onclick) { this.onclick(); } } }) in other template use 'button': <template name="buttongroup"> {{> button disp='button 1' onclick=onbutton1click}} {{> button disp='button 2' onclick=onbutton2click}} </template> and js: template.buttongroup.helpers({ onbutton1click: function() { console.log('button 1 clicked'); }, onbutton2click: function() { console.log('button 1 clicked'); }, }); obviously, can not work, because template buttongroup pass 'onbutton1click()' button, not function result(which returns 'undefined'). so how can make meteor pass helper functi...

python - How to control frame size with Tkinter and Python2.7? -

i have bigger frame size default, code doesn't work that. doing wrong? from tkinter import * class app: def __init__(self, master): frame = frame(master, width=600, height=450) frame.grid() frame.pack_propagate(0) # tell frame not let children control size self.label_file = label(frame, text="enter csv file:") self.label_encode = label(frame, text="enter encoding:") self.entry_file = entry(frame) self.entry_encode = entry(frame) self.label_file.grid(row=0, sticky=e) self.label_encode.grid(row=1, sticky=e) self.entry_file.grid(row=0, column=1) self.entry_encode.grid(row=1, column=1) root = tk() root.wm_title("top list") app = app(root) root.mainloop() you calling pack_propagate using grid lay out widgets. if you're using grid , must call grid_propagate . i urge resist temptation this. tkinter programs behave better geometry propagati...

ios - How to add data to object when keys retrieve only 1 object? PARSE.COM SWIFT -

Image
okay have classnamed: "privategroups". each row in privategroups contains "groupname" , "password". in uiview, if user enters groupname , password , hits submit, want add user objectid specific groupname/password entry under "members". this code have isn't working: var query = pfquery(classname: "privategroups") query.wherekey("privatename", equalto: joinname.text) query.wherekey("password", equalto: joinpassword.text) query.findobjectsinbackgroundwithblock { (objects, error) -> void in if objects.count == 1 { object in objects { query.getfirstobject().adduniqueobject(pfuser.currentuser().objectid, forkey: "members") query.getfirstobject().saveinbackground() }} so if match "members" , "password" , press button, want add user's object id "members" in loop for object in objects shouldn't need call query.getfirstobject() since have obje...

cuda - Use cudaDeviceSynchronize() inside kernel for global synchronisation -

i read documentation dynamic parallelism. wonder: can use cudadevicesynchronize() inside kernel synchronize blocks running on device? the documentation says: cuda runtime operations thread, including kernel launches, visible across thread block. means invoking thread in parent grid may perform synchronization on grids launched thread, other threads in thread block, or on streams created within same thread block. furthermore: streams , events created within grid exist within thread block scope have undefined behavior when used outside of thread block created. that's no question. since cudadevicesynchronize() uses global stream whole device, i'm not sure whether stream might visible , same threads on device, no matter block or launch belong. use cudadevicesynchronize() inside kernel global synchronisation. no. there no way safely device-wide synchronisation. section c.3.1.4 of programming guide ( link ): the cudadevicesynchronize() functi...

How to create a splash screen with progress bar in Java -

i going create splash screen application coded. splash screen should have progress bar, background image , info section badly needed because there files need installed before application start work, , want see them on splash screen (like eclipse splash screen). additionally, progress bar move forward according installed file. can me subject? thank interest please go through tutorials understand how use progress bar. , if face issue there post problem forum. tutorials are: https://docs.oracle.com/javase/tutorial/uiswing/components/progress.html http://www.java2s.com/code/java/swing-jfc/progressbarsample.htm or have @ these answers how add progress bar? progress bar java

ruby - Rails routing issue, can't figure out the link path -

let me fair outset, , tell i've 'solved' problem i'm describing. solution don't understand not solution, it? i have resource, newsbites. have index page newsbites. crud actions work fine. i created separate index ( frontindex.html.erb ) acts front page of website show newest newsbites. formatting different normal index readers larger photo, more of text of article(more ads too:). in routing table, have following statements: resources :newsbites 'newsbites/frontindex' root 'newsbites#frontindex' rake routes show following: newsbites_frontindex /newsbites/frontindex(.:format) newsbites#frontindex if load website root (localhost:3000), works great. there separate menu page rendered @ top, , loads fine. can click on links, except ' home ' link, , work fine. the 'home' link is: <%= link_to 'home', newsbites_frontindex_path %> when click on linked, following error: couldn't find newsbite ...

javascript - CodeCademy Codebit document.getElementById() cannot be a variable -

ok, go codebit have fun, , already, 30 seconds in, something's wrong. have div id of "main" , when window loads, start program. html: <link rel='stylesheet' href='style.css'/> <script src='http://code.jquery.com/jquery-1.9.1.min.js'> </script> <script src='script.js'></script> <div id="main"></div> js: var x = document.getelementbyid('main'); function loaded() { x.innerhtml ="willnotload!" } $(document).ready(function() {loaded();}); don't "you didn't load document, stupid?" get, because doing without variable works . you're running selector before dom ready div you're looking doesn't exist @ time - see x is. to fix it, move var x = document.getelementbyid('main'); part inside loaded function.

android - Text pushes centered elements -

Image
i'm new mobile apps , i'm having hard time layouts. have elements centered, when put more text pushes left. how can make text goes right without pushing else? layout: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"> <textview android:text="@string/status_text" android:textappearance="?android:attr/textappearancelarge" android:layout_width="wrap_content" android:id="@+id/status_view" android:layout_margintop="59.0dp" android:layout_height="70dp" android:textsize="30sp" /> <imageview android:src="@drawable/circle_green" ...

umbraco7 - Umbraco 7+ backoffice development, client actions -

i new in umbraco backoffice development. followed tutorials that. struggling because don't understand client model of umbraco backoffice. have done following view: <div ng-controller="umbextend.umbextendtree.importcontroller"> <div class="umb-pane"> <h1>datei hochladen</h1> <p> bitte laden sie die datei hoch, welche importiert werden soll. es sind nur csv dateien erlaubt. </p> <div class="umb-actions"> <input type="file" id="userimportfile"/> </div> <loading></loading> <div class="btn-toolbar pull-right umb-btn-toolbar"> <a id="uploadnowbutton" class="btn btn-primary" ng-click="runimport(99)" prevent-default>benutzer jetzt importieren!</a> </div> </div> </div> <script> fu...

php - LibreOffice writer truncate html .doc files at 65533 characters? -

i generate .doc html formated file php script. everithing work fine, file generated, if try open libreoffice (v4.2.8.2) file silently truncated 65533th character when displayed. is there workaround ? bug ? have informations that? i found problem. text within <body> tag. broke parts of text within <div> , worked (it won't work html5 tags such <article> ). think libreoffice can't handle more 65533 characters tags. in addition remarked "same" problem in libreoffice calc, if open .xls file html formated, not display more 65533 non empty cells (here didn't find (/searched) workaround). i think it's big bug software (i didn't test other such ooo or ms office). @ least warning message might displayed.

ios - Terminating app due to uncaught exception due to uncaught exception (Attemped to add a SKNode which already has a parent) error -

i'm trying make label shown when game launches, crashes starts. error "terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'attemped add sknode has parent: name:'(null)' text:'tap anywhere start!' fontname:'copperplate' position:{187.5, 333.5}'".this code: let startgametextnode = sklabelnode(fontnamed: "copperplate") required init?(coder adecoder: nscoder) { super.init(coder: adecoder) } override init(size: cgsize) { super.init(size: size) startgametextnode.text = "tap anywhere start!" startgametextnode.horizontalalignmentmode = sklabelhorizontalalignmentmode.center startgametextnode.verticalalignmentmode = sklabelverticalalignmentmode.center startgametextnode.fontsize = 20 startgametextnode.fontcolor = skcolor.whitecolor() startgametextnode.position = cgpoint(x: scene!.size.width / 2, y: scene!.size.height / 2) addchild...

c - Concatenating Strings-changing words into pig latin -

i keep receiving "segmentation fault (core dumped)". how can swap first letter of given word user inputs end of word , add "ay". example: input "code" output "odecay" #include<stdio.h> #include<string.h> int main() { char pig[100],p[10],i[100]; int j,length; printf("what word change pig latin"); scanf("%s",pig); length=strlen(pig); strcat(p,pig[0]); for(j=0;j<length;j++) { pig[j]=pig[j+1]; } strcat(pig,p); strcat(pig,"ay"); printf("%s",pig); return 0; } how can swap first letter of given word user inputs end of word , add "ay" save first character ("letter") char c = pig[0]; move rest of pig 1 char beginning memmove(pig, pig + 1, strlen(pig) - 1); alternativly use statement memmove(&pig[0], &pig[1], strlen(pig) - 1); (note memcpy() won't work here source , destiantion overlap.) ...

javascript - Enable resize for div inside contenteditable div -

i have div contenteditable set true. want enable resize div inside contenteditable div. in example html insert works fine how make inserted html div resizable? code: function inserthtml() { var sel = document.selection; if (sel) { var textrange = sel.createrange(); document.execcommand('inserthtml', false, "<div><img src='https://www.google.com/images/srpr/logo11w.png' height='42' width='42'></div>"); textrange.collapse(false); textrange.select(); } else { document.execcommand('inserthtml', false, "<div><img src='https://www.google.com/images/srpr/logo11w.png' height='42' width='42'></div>"); } } fiddle: http://jsfiddle.net/q6q05f1b/

How to overcome 'Coudn't find that formation' error when adding web dynos to Heroku django app? -

i'm trying deploy simple django app, , have pushed git repository heroku. however, when attempt run: heroku ps:scale web=1 i following error scaling dynos... failed ! couldn't find formation. any thoughts problem might be? contents of procfile (below) correct best of knowledge. web: gunicorn my_app_name.wsgi to state obvious: way encounter issue if you're working on new app, , try running heroku ps:scale web=1 before you've done git push heroku master . there no procfile on heroku server in case, because there aren't files @ all. :d

java - Are self signed certificates always prone to man in the middle attack while adding the certificate programmatically? -

i creating jax-ws client app needs accept self-signed certificates. there common ssl handshake exception problem when trying import self-signed certificates. common work around extend jsse security provider , initialize ssl context accept certificates like: security.addprovider(new com.sun.net.ssl.internal.ssl.provider()); trustmanager[] trustcerts = new trustmanager[]{new x509trustmanager() { public x509certificate[] getacceptedissuers() { return null; } public void checkservertrusted(x509certificate[] certs, string authtype) throws certificateexception { return; } public void checkclienttrusted(x509certificate[] certs, string authtype) throws certificateexception { return; } } ...

php - Using curl to get data from a website -

i trying use curl train information http://www.indianrail.gov.in/know_station_code.html . have following php code : <?php $fields = array( 'lccp_src_stncode_dis'=>'mangapatnam-+mum', 'lccp_src_stncode'=>'mum', 'lccp_dstn_stncode_dis‌'=>'ambala+city-+ubc', 'lccp_dstn_stncode'=>'ubc', 'lccp_classopt'=>'sl', 'lccp_day'=>'17', 'lccp_month'=>'8', 'currentmonth'=>'7', 'currentdate'=>'17', 'currentyear'=>'2015' ); $fields_string = ''; //defining empty string foreach($fields $key=>$value) { $temp = $key.'='.$value.'&'; $fields_string.$temp; } rtrim($fields_string,'&'); //removing last '&' gene...

How to Remove Editors from Protected Cells or Permanently Protect Cells in Google Sheets -

i'm trying permanently lock/protect cells on 14 different sheets (1 hidden workers formula stuff). have them locked , no 1 can edit if add them editor. template, make copies of each client (and new clients) staff. staff works on sheet , employees allowed edit cells work do. the problem if have workbook1 x cells locked on different sheets, make copy, rename workbook - client#id , add them employees john , jane, working on client, editors; can edit every cell, including protected ones (they added editors protected cells too). doesn't on original, happens copy made of template. have go through 13 sheets , remove them protected cells. i'm trying remove them automatically script add-on want turn button or later... or there better way fix bug? google has example of removing users , keeping sheet protected , have tried add in need make work, doesn't when run test add-on spreadsheet. open new app script project spreadsheet , enter in example code google // pr...

php - Strip HTML string but don't lose line breaks -

i have string contains lot of html (html email body). what want lose html keep line breaks, tried strip_tags() didn't work out me, makes string 1 line. after has been done, want echo first 5 lines string. anyone got idea? update: $string = strip_tags($string, '<p><br><br />'); seems working, have select first 5 lines string, idea? update: array keeps giving few empty values. managed remove empty ones array doesn't restart counting. array looks now: array ( [8] => dit een nieuwe test met meerdere regels. [9] => dit regel nummer 2. [10] => dit regel nummer 3. but should start counting @ 0 again. array_filter() array_merge() etc. not work. use strip_tags second parameter, this: strip_tags($html, '<p><br>') . can see, second parameter takes in $allowable_tags in docs .. see this question/answer also. perhaps easiest first few lines using explode : $lines = explode("<br>...

objective c - can you prevent Wifi from shutting off during screen lock or screen lock? -

i have app creates time lapse movies on os x webcams available through url. have had lots of users complaining recordings dropping tons of frames. have isolated problem yosemite disconnecting wifi when screen locks. there way let system know important app keeps network connection? annoying tell users go in , disable screen locking use app. if wi-fi turning off, that sounds apple bug . you can disable app nap & idle sleep registering "activity" . the nsactivityuserinitiated option should enough. there's nsactivityidledisplaysleepdisabled .

Python - How to Pass A Spaced File? -

this question has answer here: handling directories spaces python subprocess.call() 1 answer i'm writing script use ffmpeg create video picture. need save file file name something.mp4 (with spaces between words in filename). when try this, receive error: [null @ 02c2fa20] unable find suitable output format './lol/media/videos/lets' ./lol/media/videos/lets: invalid argument. the script gets first word of filename. here's code: from subprocess import check_output import ntpath import os class videomaker(): def makevidoes(self, path, savepath, time=15): if not os.path.exists(savepath): os.makedirs(savepath) try: filename = ntpath.basename(os.path.splitext(path)[0].replace('+', ' ') + ".mp4") print filename #file name 'lets play games.mp4' check_...

javascript - how to create new scope for each record of list of records which are repeating through while in java/jsp -

i stuck problem, can let me out of it. i getting data (mongodb) servlet jsp (mongodb). have list of (using dbcursor ) documents have show them, providing edit , delete button that. when click on particular edit or delete, particular record modified.i using ajax post (edit/delete) data. provide individual scope each record. angular ng-repeat . <% try { while (cursor.hasnext()) { dbobject tobj = cursor.next(); dbobj = tobj; string id = (string) tobj.get("_id").tostring(); string firstname = (string) tobj.get("firstname"); string lastname = (string) tobj.get("lastname"); string emailid = (string) tobj.get("emailid"); %> <tbody> <form name= "" action="" method="post"> <tr> <td><% out.println(firstname);%> </td> <td><% out.println(lastname);%> </td> <td><% out.println(emailid);%>...

ios - How to add the View below the TableView? -

how should add view ( imageview ) below uitableview ? and view can scrolled uitableview because tableitem can expanded you need implement uitableviewdelegate method - (uiview *)tableview:(uitableview *)tableview viewforfooterinsection:(nsinteger)section and return desired view (e.g. uilabel text you'd in footer) appropriate section of table. somewhat below. - (cgfloat)tableview:(uitableview *)tableview heightforfooterinsection:(nsinteger)section { return 30.0f; } - (uiview *)tableview:(uitableview *)tableview viewforfooterinsection:(nsinteger)section { uiview *sampleview = [[uiview alloc] init]; sampleview.frame = cgrectmake(x, y, width, height); sampleview.backgroundcolor = [uicolor blackcolor]; return sampleview; } and include uitableviewdelegate protocol. @interface testviewcontroller : uiviewcontroller <uitableviewdelegate>

How to insert new document only if it doesn't already exist in MongoDB -

i have collection of users following schema: { _id:objectid("123...."), name:"user_name", field1:"field1 value", field2:"field2 value", etc... } the users looked user.name, must unique. when new user added, first perform search , if no such user found, add new user document collection. operations of searching user , adding new user, if not found, not atomic, it's possible, when multiple application servers connect db server, 2 add_user requests received @ same time same user name, resulting in no such user being found both add_user requests, in turn results 2 documents having same "user.name". in fact happened (due bug on client) single app server running nodejs , using async library. i thinking of using findandmodify, doesn't work, since i'm not updating field (that exists or doesn't exist) of document exists , can use upsert, want insert new document if search criteria fails. can't make query not equal ...

android - ADB is not recognizing my Redmi Note device -

Image
adb not recognizing redmi note device. using windows 8 also when use below command in cmd, adb devices displaying i followed procedure in below link, using hardware devices for redmi note adb drivers, have go through hoop. same mi phones or maybe non-google mfg phones, not sure. first of if connect device usb cable , usb debugging off, see windows 8 loads generic driver copy on/off files phone , sd storage. appear when usb cable first plugged in , appears device icon under control panel, device manager, portable devices, hm note(or device working with). go phone , switch on usb debugging in developer section of phone. notice additional item appears undefined device in device manager list, have yellow exclamation mark , may not have same name of phone listed saw under portable devices. ignore item moment. now, without doing phone (it should in usb debug mode) go portable devices in device manager , right-click hm note or whatever phone working listed there wi...

android - multiple activities are starting when on click -

i calling 1 activity via intent when user clicks login button.when internet connection poor user clicks login button , activity not started user clicking login button again. after time 2 activities opening.how can resolve this. fine when internet connection good. thanks in advance problem solved android:launchmode="singletop" in manifest

How to decode URL parameter using AngularJS or JavaScript? -

i have value pass on url parameter original value looks this: 1436641259169/ndfmdmva when gets passed on converts this: 1436641259169%252fndfmdmva so, how convert when pull down? this may you: decodeuricomponent decodeuricomponent(string); example: decodeuricomponent(decodeuricomponent("1436641259169%252fndfmdmva")) > "1436641259169/ndfmdmva"

.htaccess - Apache redirect from root -

i wondering how perform redirect root in apache. i want check if goes root url (eg. example.com ) , redirect them example.com/h automatically. can in apache config, or in .htaccess file? namevirtualhost *:80 <virtualhost *:80> servername example.com redirectmatch 301 ^/$ /h </virtualhost> this redirect request example.com example.com/h

javaFX controllers doesn't communicate which each other -

i have problem javafx.i'm doing calculator , divide app between 3 fxml files(1 controller controlls numbers , operators, 2 controller textfield result field, , last 1 should let them communicate each other). i can not manage how can write own method example put number "3" when press number 3 in textfield-which in other fxml , has own fxml file.there nullpointer exception suppose im not initializing textfield.please me problem.is there way write own method(in example wrote showdigit()) in maincontroller class - method should set text textfield after pressing button - example button 2 put "2" in textfield. below i've pasted code. package pl.calculator.controller; import java.net.url; import java.util.resourcebundle; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.fxml.fxml; import javafx.fxml.initializable; import javafx.scene.control.button; import javafx.scene.control.textfield; public class mainpanecontroller impl...

php - CakePHP role based auth -

edit: version: 2.5.7 i'm trying setup role based authentication cakephp. far i've managed authentication work ok, controller access redirects login screen when not authenticated, , permits access when authenticated.. my problem comes when want 'admin' level access action methods, (prefixed admin_ ) yet denies them regular logins. if uncomment $this->auth->authorize in beforefilter, authentication works fine..comment in, , can't log in. appcontroller public function isauthorized() { if (!empty($this->params['action']) && (strpos($this->params['action'],'admin_') !== false) ) { if ($this->auth->user('admin')) { return true; } } return false; } public function beforefilter() { $this->auth->authorize = 'controller'; $this->auth->deny(); //deny everythng } my dashboard controller first screen after successful login. it'...

clojure - why doesn't with-open force evaluation -

just wondering why with-open doesn't force evaluation of lazyseq , yet prn does? with-open doing side effects, isn't bad idea doing inside with-open produces lazy possible consumption later on? in situation this? the 2 serve different purposes. prn function designed print things in way can read reader. if thing being printed happens lazy sequence, thing force evaluation of lazy sequence in order print contents. with-open , on other hand, general-purpose macro designed execute arbitrary code in body in context resources closed on completion of code. it's syntactic sugar. macro knows nothing code in body doing, or sort of result it's going produce. you correct returning lazy sequences with-open try read already-closed resource common source of bugs in clojure programs. however, it's not feasible with-open macro reliably detect when body causes lazy sequence produced , automatically force it. have aware of situation , handle in own code whe...

How to change selected text in Qt? -

how can store in qstring selected text, typed in qtextedit , change (for example toupper() ) , change selected in qtextedit ? this can done through qtextcursor api: qtextcursor cursor = textedit->textcursor(); if(cursor.hasselection()) { cursor.inserttext(cursor.selectedtext().toupper()); }

java - Guava Cache not expiring after x timeunit when using timed expire -

i'm having issue guava cache not expiring. i'll leave code down below. cache expires 1 write cache again. took javadocs timed expiration should expire x timeunit after writing. appreciated. private static final cache<uuid, rainbowwrapper> rainbows = cachebuilder.newbuilder() .removallistener(new removallistener<uuid, rainbowwrapper>() { @override public void onremoval(removalnotification<uuid, rainbowwrapper> notification) { coreapi.debug("removing rainbow: " + notification.getkey().tostring()); rainbowwrapper wrapper = notification.getvalue(); (uuid uuid : wrapper.getuuids()) { coreapi.debug("removing entity: " + uuid); bukkit.getworlds().get(0).getentitiesbyclasses(item.class, armorstand.class).stream() .filter(entity -> entity.getuniqueid().equals(uuid)) ...

osx - returning to previous if statements in bash -

say i've got following: echo "would blarg, or flarg?" read -e act if [ "$act" == "blarg" ] echo "go blarg." echo "possible blargs blah , flah, or go previous question." read -e marv fi if [ "$act" == "flarg" ] echo "go flarg." echo "possible flargs blah , flah, or go previous question." read -e carve fi (more if statements following general pattern) i need know how back go previous question (blah or flah) answer either marv or carve , , 1 go first 1 (flarg or blarg). edit: need know how redefine variable using read . boy, overthink things. do mean this: while ! [[ "${act-}" =~ [bf]larg ]] read -e act [...] done

ruby on rails - How to assign a value to a column by using String -

i have method this: class myclass < activerecord::base def assign_weighted_values unless foo.nil? self.weighted_foo = 3 * foo end unless bar.nil? self.weighted_bar = 3 * bar end unless hoge.nil? self.weighted_hoge = 3 * hoge end end end but want write like: def assign_weighted_values %w(foo bar hoge).each |column| next if send(column).nil? self.send("weighted_#{column}") = 3 * column end end is there way assign value column using string? you can use assign_attributes def assign_weighted_values %(foo bar hoge).each |column| next if send(column).nil? assign_attributes({ "weighted_#{column}" => 3 * column }) end end

java - How to add PhantomJSDriver command line arguments -

this question has answer here: why won't phantomjsdriver use capabilities set? 2 answers how can specify command line arguments java phantomjsdriver ? example, want set --ignore-ssl-errors=yes on script run. simply add phantomjs's default desired capabilities, so: desiredcapabilities desiredcapabilities = desiredcapabilities.phantomjs(); desiredcapabilities.setcapability("phantomjs.cli.args", collections.singletonlist("--ignore-ssl-errors=yes")); phantomjsdriver driver = new phantomjsdriver(desiredcapabilities);