Posts

Showing posts from September, 2014

java - How do you call on/use files from outside the activity class in Android Studio? -

i create array of images drawable folder in class outside app activity class in android studio. can use getresources() method in activity. keep code clean , organized , creating array in activity may messy if accumulate more images. there similar or way access getresources() method outside class? trying generate randomized background using images in drawable folder. open suggestions new developer , may approaching problem incorrectly. you not need activity per se hold of resources . activity extends context ; context gives access resources. need class takes context if want reference of resources .

android - AlarmManager executes my PendingIntent immediately instead of waiting for sertain time -

i trying implement alarm, , therefore app has 2 activities: main 1 (where user sets alarm) , 'ringing' 1 displayed when alarm triggered. here how send intent alarmmanager call 'ringing' window: public void schedulealarm(view view) { intent intent = new intent(this, wakeup.class); intent.setaction(intent.action_view); intent.setflags(intent.flag_activity_reorder_to_front); pendingintent wakeup = pendingintent.getactivity(this, 123, intent, 0); alarmmanager alarmmanager = (alarmmanager) this.getsystemservice(this.alarm_service); alarmmanager.setexact(alarmmanager.rtc_wakeup, calculatemillis(), wakeup); // setexact pretty made setting alarms anyway } private long calculatemillis() { calendar cal = calendar.getinstance(); cal.set(calendar.hour, hour); cal.set(calendar.minute, minute); cal.set(calendar.second, 0); return cal.gettimeinmillis() - calendar.getinstance().gettimeinmillis(); } in manifest have following: ...

c++ - Cannot find boost with CMake on Linux Mint -

i have been working on library in c++ , have run bit of difficulty trying integrate boost project. kept message boost not found, on other hand, fellow developer using arch had no issues. we figured out because linux mint (at least libboost-all-dev package) installs libraries /usr/lib/x86_64-linux-gnu not searched findboost module. fixed creating symbolic links: ln -s /usr/lib/x86_64-linux-gnu/libboost* /usr/lib/ what want know: there better (more acceptable) way of fixing because when compile major projects, not run problem. here cmakelists.txt (with omissions) cmake_minimum_required(version 2.8) project(testlibrary cxx) set(cmake_cxx_flags "-std=c++0x ${cmake_cxx_flags}") set(boost_use_static_libs on) set(boost_use_multithreaded off) set(boost_use_static_runtime off) find_package(boost 1.55.0 components unit_test_framework thread log required) include_directories(${boost_include_dirs}) add_library(testlibrary static ${source_main}) target_link_libraries(t...

php - Shell_exec nohup with nohup.out -

executing code: shell_exec('nohup command&'); or this shell_exec('nohup command > /path/to/nohup.out 2>&1&'); but there no nohup.out in both cases. how can run nohup nohup.out via php? shell_exec('nohup command > /path/to/nohup.out 2>&1&'); this line work. make sure have write permissions output folder. consider output folder /usr/nohup-out ls -l /usr/nohup-out it should have write, read , execute permissions ( rwx ). if not, this: sudo chmod -r 777 /usr/nohup-out now, try execute php file. should create nohup file in /usr/nohup-out folder. sample script , result: 1. date.php: <?php shell_exec('nohup date > /usr/nohup-out/nohup.out 2>&1&'); ?> 2. execute php terminal: php date.php 3. nohup.out content after execution thu apr 23 11:30:28 ist 2015

java - Eclipse Luna 1.7 to 1.8 errors -

Image
i working in eclipse luna , tried write static method in interface gave me error. moused on , forgot said ... 1.8 jre . clicked , there's error on every line saying things like: string cannot resolved type and java.lang.object cannot resolved how go fix it? the problem here confusion in eclipse between installed jre in system , used jre in project, resolve point installed jre in system, this: open project build path configuration: right click in project, choose properties --> java build path . 2. add new jre system library: click button add library choose jre system library : 3. choose installed jre library: click installed jres... button , choose installed jre in system. hope helps.

How do I write or edit Python files? -

when open python there no file, edit, format, run, or of other options. blank screen default text. if you're running python shell terminal, there aren't of options. running shell gives blank interpreter respond every line of code type instantly. python scripts run opening them in terminal. however, first need write 1 using ide, text editor, , saving .py file. can run file navigating directory in terminal or command window. on mac command be: python myfile.py

plugins - How can I make my Qt app see the "platforms" in a different place? -

i'm aware that, when installing qt application somewhere, need deploy plugin related system being used in folder platforms . traditionally folder supposed located in same place executable located. want change that: want put folder 1 level back, is, in place ../platforms . how can tell app in place shared library? reading threads on web came 2 possible solutions: 1 use qcoreapplication::addlibrarypath() , "general plugins" (those should placed inside plugins directory), not platform plugin afaik. such tried solution adding "../" in call qcoreapplication::addlibrarypath() and didn't work. (should have put "../platforms" instead?) other solution seems using qt.conf . problem don't know how edit file when comes adding path platform plugin: digia's manual file doesn't tell how specific configuration. set plugins in qt.conf point location of plugin sub-directories (ie .. in example), rather listing individual plugin sub-dir...

c++ - Adding linting to autotools-based build system -

i want add cpplint.py ( https://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py ) autotools-based project. 1 know right way this? let's assume want run linter on .cpp source files part of make . let's assume linter in path , not distributing copy of part of package. first of check make sure have linter available in configure.ac : ac_path_prog([cpplint], [cpplint.py], [true]) as_if([test "x$cpplint" = xtrue], [ac_msg_warn([we recommend cpplint.py developing package. https://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py , put in path, or point cpplint environment variable @ it.])]) see below explanation of true in case not mean boolean true value. if want make linter absolute requirement, use ac_msg_error instead. the best way make run write makefile code , hook automake's all-local target. if linter not available, nicely call true command nothing. lint: $(myprogram_sources) -$(cpplint) $^ all-local:...

html - How to increase div height to match the height of next div? -

i want page header , menu , content areas. this code. html : <div class="header">title</div> <div class="menu"> <ul> <li>option 1</li> <li>second option</li> </ul> </div> <div class="content"> <h1>asduahsd asdasd asid daksh</h1> <h1>asduahsd asdasd asid daksh</h1> <h1>asduahsd asdasd asid daksh</h1> <h1>asduahsd asdasd asid daksh</h1> <h1>asduahsd asdasd asid daksh</h1> <h1>asduahsd asdasd asid daksh</h1> <h1>asduahsd asdasd asid daksh</h1> </div> css .header { background-color: yellow; padding: 10px; } .menu { background-color: blue; float: left; width: 20%; } .content { background-color: red; float: left; width: 80%; } http://jsfiddle.net/x1q03qfk/ as can see in jsfiddle, .menu shorter .content , w...

ios - touchesBegan cancel UISwipeGestureRecognizer -

i have general touchesbegan in viewcontroller - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { nslog(@"--[%s:%d]",__pretty_function__,__line__); } this seems cancel uiswipegesturerecognizer. (not fired) uiswipegesturerecognizer *swipeleft = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(handleswipe:)]; uiswipegesturerecognizer *swiperight = [[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(handleswipe:)]; [swipeleft setdirection:uiswipegesturerecognizerdirectionleft]; [swiperight setdirection:uiswipegesturerecognizerdirectionright]; swiperight.numberoftouchesrequired=1; swipeleft.cancelstouchesinview=no; swiperight.cancelstouchesinview=no; swipeleft.delaystouchesbegan = yes; swiperight.delaystouchesbegan = yes; self.viewswipe.userinteractionenabled=yes; [self.viewswipe addgesturerecognizer:swipeleft]; [self.viewswipe addgesturerecognizer:swiperight]; ...

java - Removing Items from an ArrayList through a JTable -

i have jtable includes items arraylist , whenever try remove contents of deleted row arraylist indexoutofboundsexception depending on amount of rows wanted delete , location. how go solving issue? runnable code: http://pastebin.com/nnrnxzdg remove.addactionlistener( e -> { int k = 0; int[] rows = table.getselectedrows(); tablemodel tm= table.getmodel(); while(rows.length>0) { while(k<rows.length) { al.remove(table.getselectedrow() + k); k++; } ((defaulttablemodel)tm).removerow(table.convertrowindextomodel(rows[0])); rows = table.getselectedrows(); } table.clearselection(); }); basically, moment remove row, indices change. need do, make copy of selected rows, not index, actual row value... jtable table = gettable(); if (table.getselectedrowcount() > 0) { list<vector> selectedrows = new arraylist<>(25); defaulttablemodel model = getm...

Generics C# How to pass a property of a generic object by parameter -

i have created method has problem couldn't sort out. how can pass parameter predicate? because "x.isactive" , "source.id" , "x.id" vary, objects pass parameter have isactive , id properties. public static differences<t> checkchanges<t>(list<t> sourcetable, list<t> destinationtable) { var differences = new differences<t>(); foreach (var sourceitem in sourcetable.where(x => x.isactive)) { var destinationitem = destinationtable.firstordefault(x => x.id == sourceitem.id); } return differences; } if can make objects inherit common interface, easier: public interface iaccount { int id { get; set; } bool isactive { get; set; } } your method signature more then: public static differences<iaccount> checkchanges(list<iaccount> sourcetable, list<iaccount> destinationtable)

Python Pyserial Windows No Port Found -

i have tried connect usb mobile send sms through using @ commands. when use pyserial connect in windows os, error not open port, file specified cannot found. >>> import serial >>> ser = serial.serial(0) # open first serial port >>> print ser.name # check port used >>> ser.write("hello") # write string >>> ser.close() even if replace 0 other value, 0 -10 or 'com0','com1' etc, still error file specified not found, port cannot open. there command listed in pyserial documentation lists ports or allows open port python -m serial.tools.miniterm this command supposed list serial ports. shows none. i have 3 usb ports on system. causing issue. pyserial not guaranteed detect ports. depends on how device , os communicate , if pyserial designed pick on this. example, pyserial not detect labjack u3-lv or epsom-pos receipt printer plugged in in win8 session (both detected using linux ses...

jquery ajax load recursive callback -

here's jquery function, i'm stuck in circular callback functions. i'm wondering how convert code call itself? or possible? $('#content').load('myurl/items', function() { ... ... $(this).find('form').submit(function(e) { e.preventdefault(); $.ajax({ type: 'post', url: 'myurl/items', context: document.getelementbyid('content'), }).done(function() { $(this).load('/myurl/items', function(){}); // recursive }); } }); declare function: function loaditems() { $('#content').load('myurl/items', function() { ... ... $(this).find('form').submit(function(e) { e.preventdefault(); $.ajax({ type: 'post', url: 'myurl/items', context: document.getelementbyid('content'), ...

javascript - AngularJS ng-repeat with external image source not updating view with images -

i've run issue building new website i'm pulling request external api contains image "id". image id can accessed going https://externalsite.com/getimage/id_width.png (width variable, 128, 256, 512, etc.) once request complete, populates ng-src correct links. problem images never show up. can go developer tools , see source correct image doesn't display on page. if not use ng-repeat, images show fine , page behaves expected. if use ng-repeat, images never show in view if @ actual image tag, source set properly. html: <div ng-controller="killctrl" class="isotope-container row grid-space-20"> <div ng-repeat="kill in kills" class="col-sm-6 col-md-3 isotope-item web-design"> <div class="image-box"> <div class="overlay-container"> <img ng-src="{{kill.shipimage}}" alt="cover image"> js: var app = angular...

javascript - How to resolve a variable number of promises in node.js -

i'm working on function (called express.js route) merge event info in database facebook counterpart , return array of event objects. i having trouble asynchronous nature of node.js , resolving variable number of promises within foreach loop before returning whole object. i've tried numerous different methods of rearranging code (callbacks, counters, promises, etc.), have not been successful in solving problem, , know why. suspect has variables being overwritten in foreach loop, i'm not sure how solve that. i looking 3 things: what not grasping conceptually needed solve problem? how figure out or debug in future? how fix code make work? here function: function mergeevents(req, res, next, events){ console.log("merge events"); var dfd = q.defer(); ensureauthenticated(req, res, next).then(function(auth){ var ievent, event; var promises = []; if (auth){ console.log("authenticated!"); console.log("auth t...

android - Error using Facebook Graph api to get email, name? -

i have created application in android integrated parse.com facebook , twitter integration. i login facebook using parsefacebookutils gives me session access token in turns use call graph api. earlier worked. but following error: authentication error: unable respond of these challenges: {oauth=www-authenticate: oauth "facebook platform" "invalid_token" "error validating access token: session not match current stored session. may because user changed password since time session created or facebook has changed session security reasons."} 04-22 21:35:17.631: w/msgr(:<default>):k(30067): com.facebook.http.protocol.e: [code] 190 [message]: error validating access token: session not match current stored session. may because user changed password since time session created or facebook has changed session security reasons. [extra]: this graph api rest call make: https://graph.facebook.com/v2.1/me?email,name&access_token=<access-...

java - Android - Cannot resolve symbol "R" -

Image
many responses on stackoverflow advised import r. did , made sure rebuild/clean path on 10 times before asking question. here how files arranged: we can see error lies somewhere between mainactivity file or xml file. here code mainactivity file , pretty copy google's git hub account , error cannot identity "r" is.: package com.eatwithme; /* * copyright (c) 2015 google inc. rights reserved. * * licensed under apache license, version 2.0 (the "license"); * may not use file except in compliance license. * may obtain copy of license @ * * http://www.apache.org/licenses/license-2.0 * * unless required applicable law or agreed in writing, software * distributed under license distributed on "as is" basis, * without warranties or conditions of kind, either express or implied. * see license specific language governing permissions , * limitations under license. */ import android.content.res.resources; import andr...

objective c - iOS How Array objects separated by commas convert into string? -

i have array named child_list child_list: "9,8,21,22,20,24,25", take in nsstring @ index 0 when convert string work when use nsmutablearray crashed, don't know why. my code here: if([thedictionary objectforkey:@"child_list"]) { nsstring *str = [[thedictionary objectforkey:@"child_list"]objectatindex:0]; nslog(@"child list %@",str); _child_list = [[nsmutablearray alloc ]initwithobjects: [str componentsseparatedbystring:@","], nil]; } when break point come on str show result when comes on _child_list crashed. use initwitharray method while allocating _child_list nsmutablearray if([thedictionary objectforkey:@"child_list"]) { nsstring *str = [[thedictionary objectforkey:@"child_list"]objectatindex:0]; nslog(@"child list %@",str); _child_list = [[nsmutablearray alloc ] initwitharray:[str componentsseparatedbystring:@...

Remove auto appearing BEGIN TRAN and ROLLBACK in SQL Server 2008 R2 -

Image
i want remove auto appearing begin tran , rollback in sql server 2008 r2. here following image getting while selecting new query write. do have "ssms tools pack" installed ? at times "new query template" option had somehow been enable , configured. i think if disabled should have been removed

c# - Xml Parsing using SelectNodes and Xpath -

i'm writing program parse xml file (with book contents). what did, xmldoc = new xmldocument(); xmldoc.load(path); booklist = xmldoc.getelementsbytagname("book"); list<string> prices= new list<string>(); foreach (xmlnode node in booklist) { xmlnode price = node["price"]; prices.add(price.innertext); } // highest priced book(s) prices.sort(); what wanna use selectnodes highest priced books, , return xmlnodelist //to store highest price of book string highest = prices[0]; **// can't figure out xmlnodelist expensivelist = xmldoc.selectnodes("descendant::book[price = highest]");** any appreciated, thanks! edit: managed around making foreach loop nodes in booklist if case compare price.innertext highest. it's working i'd still know if can done xpath. thanks! edit #2: can improved upon using different approaches, wanna know if possible compare string variable node values xpath. ...

java - Create a HashMap with a fixed Key corresponding to a HashSet. point of departure -

my aim create hashmap string key, , entry values hashset of strings. output this output looks now: hudson+(surname)=[q2720681], hudson,+quebec=[q141445], hudson+(given+name)=[q5928530], hudson,+colorado=[q2272323], hudson,+illinois=[q2672022], hudson,+indiana=[q2710584], hudson,+ontario=[q5928505], hudson,+buenos+aires+province=[q10298710], hudson,+florida=[q768903]] according idea, should this: [hudson+(surname)=[q2720681,q141445,q5928530,q2272323,q2672022]] the purpose store particular name in wikidata , of q values associated it's disambiguation, example: this page "bush". i want bush key, , of different points of departure, of different ways bush associated terminal page of wikidata, want store corresponding "q value", or unique alpha-numeric identifier. what i'm doing trying scrape different names, values, wikipedia disambiguation , unique alpha-numeric identifier associated value in wikidata. for example, bush have: geo...

android - How to get the id of a particular switch in a custom list view and check it -

this getview() code. want access particular switch in custom listview. doing wrong ? public view getview(final int position, view convertview, viewgroup parent) { if(convertview==null) { //inflate custom layout convertview = inflater.from(parent.getcontext()).inflate(r.layout.list_item,parent,false); viewholder=new viewholder(); //cache views viewholder.sw=(switch) convertview.findviewbyid(r.id.switch1); viewholder.name=(textview) convertview.findviewbyid(r.id.name); viewholder.rollno=(textview) convertview.findviewbyid(r.id.roll); viewholder.id=(textview) convertview.findviewbyid(r.id.id); //link cached views convertview convertview.settag(viewholder); } else viewholder=(viewholder) convertview.gettag(); //set data displayed ...

Regex to fail email domain with two consecutive dots -

i trying validate domain part of email , want check there not 2 consecutive dots in domain i.e. following not valid joe@ms..com joe@ms.com..uk joe@..ms.com joe@ms.com.au.. i have regex find @+\.{2}|@.+\.{2} but using regex attribute in .net , want build regex valid (i.e. 1 dots) not 1 fails i thought ^ character meant everything not expression so thought ^(@+\.{2}|@.+\.{2}) have worked not nor .net framework emailaddress attribute - stops joe@ms..com not stop joe@ms.com..au you can use negative lookahead in front of regex: @(?!.*?\.\.)[^@]+$ which fail match if 2 consecutive dots present in domain anywhere. [^@] match 1 or more characters not @ regex demo

Android Custom ActionBar with Search View -

Image
i using custom actionbar library in android app. there want show searchview can not find solution, m working in library https://github.com/johannilsson/android-actionbar class private class exampleaction extends abstractaction { public exampleaction() { super(r.drawable.ic_title_export_default); } @override public void performaction(view view) { toast.maketext(otheractivity.this, "example action", toast.length_short).show(); } } //use signle action how use multiactions actionbar actionbar = (actionbar) findviewbyid(r.id.actionbar); actionbar.addaction(new exampleaction()); actually found code searchbar in .cs format how use searchview https://github.com/zleao/monodroid.actionbar bro & sis take @ answer . according answer searchview available support library. add dependency build.gradle compile 'com.android.support:appcompat-v7:22.0...

php - Laravel excel library(Maatwebsite) : How to create a drop down list in exports -

i creating excel template should contain dropdown list. see possible phpexcel library ( phpexcel multiple dropdown list dependent ). wondering if done laravel-excel library provided maatwebsite . need syntax functions dropdown,namedrange, datavalidation,setformula, etc. public function index() { \excel::create('file', function($excel) { require_once("/apppath//vendor/phpoffice/phpexcel/classes/phpexcel/namedrange.php"); require_once("/apppath/vendor/phpoffice/phpexcel/classes/phpexcel/cell/datavalidation.php"); $excel->sheet('new sheet', function($sheet) { $sheet->setcellvalue("a1", "uk"); $sheet->setcellvalue("a2", "usa"); $sheet->_parent->addnamedrange( new \phpexcel_namedrange( 'countries', $sheet, 'a1:a2' ...

javascript - How to use iframe within a jQuery slide show -

i have full-screen background slideshow uses jquery, 7 images , iframe displays youtube video. when iframe slide comes along shows bottom bit rest of page being white. when next slide comes along iframe not fade out , remains there until slide show resets (to first slide) also iframe non responsive, when click on doesnt play. please help html <div id="slider"> <img id="1" src="images/img_2615.png" style="hight:1048px; width:1571px;" alt="" /> <img id="2" src="images/img_2616.png" style="hight:1048px; width:1571px;" alt="" /> <img id="3" src="images/img_2619.png" "hight:1048px; width:1571px;" alt="" /> <iframe id="4" width="100%" height="100%" src="http://www.youtube.com/embed/kvwsp51kvo8?wmode=opaque" frameborder="0" cla...

sql server - How to take a merge replication back up? -

i have windows server 2012 sql server 2012 configured merge replication 3 subscribers. i want take full merge replication in case of total sql server crush. not sure how take or databases take up? how long? if thing happens restore configuration back. any idea? thanks you should take backups of these databases the publication database @ publisher the distribution database @ distributor the subscription database @ each subscriber the master , msdb system databases @ publisher, distributor , subscribers. these databases should backed @ same time each other , relevant replication database. example, master , msdb databases @ publisher @ same time publication database. if publication database restored, ensure master , msdb database consistent publication database in terms of replication configuration , settings. for more information, refer msdn

jsf - java.lang.UnsupportedOperationException: getRowData(String rowKey) must be implemented when basic rowKey algorithm is not used -

i have upgraded primefaces 5.1 final 5.2 final (the community release). have <p:datatable> lazily loaded follows (a minimal example reproduce problem pure testing purpose only). <p:datatable var="row" value="#{testmanagedbean}" lazy="true" editable="true" rowkey="#{row.fruitid}" selection="#{testmanagedbean.selectedvalues}" rows="50"> <p:column selectionmode="multiple"/> <p:ajax event="rowedit" listener="#{testmanagedbean.onrowedit}"/> <p:column headertext="id"> <h:outputtext value="#{row.fruitid}"/> </p:column> <p:column headertext="fruit name"> <p:celleditor> <f:facet name="output"> <h:outputtext value="#{row.fruitname}...

javascript - Object doesn't support property or method -

i using sdk ( finger print sdk ) used integrate finger print scanner application. application working fine in local server environment not on web server.the application uses activex have enabled. when ever trying run sdk gives error object doesn't support property or method 'initialize' .i did r & d , reset ie settings default didn't work. doing wrong?

Bypass SonarQube naming convention rule for Application_ methods in Global.asax -

is there way bypass rule "rename method match regular expression: [a-z][a-za-z0-9]++" for global.asax.cs, for application_ methods/events? don't want minimize amount of files skipped completely. public class mvcapplication : system.web.httpapplication { protected void application_start() { you can define narrow exclusion pattern rule on exact file, please follow instruction in sonarqube's manual.

c# - Asynchronous task for image resize -

this image resizer class: using system; using system.drawing; using system.drawing.imaging; using system.drawing.drawing2d; using system.io; using system.threading.tasks; public class imageresize { private static imagecodecinfo jpgencoder; public async static void resizeimage(string infile, string outfile, double maxdimension, long level) { byte[] buffer; using (stream stream = new filestream(infile, filemode.open)) { buffer = new byte[stream.length]; await task<int>.factory.fromasync(stream.beginread, stream.endread, buffer, 0, buffer.length, null); } using (memorystream memstream = new memorystream(buffer)) { using (image inimage = image.fromstream(memstream)) { double width; double height; if (inimage.height < inimage.width) { width = maxdimension; ...