Posts

Showing posts from April, 2012

python 2.7 - nltk - still old version after upgrading -

i trying install latest version of nltk. used pip , in /usr/local/lib/python2.7/dist-packages get >>> import nltk ; nltk.__version__ '3.1' but in project directory get >>> import nltk ; nltk.__version__ '2.0b9' how can change use nltk 3.1?

Basic Arduino Serial Communication -

i'm trying basics of serial communication started; i'm trying use example found, understand should working. want type serial monitor output back, can see how works. tried removing while serial.available in case serial monitor doesn't trigger condition. here code: // buffer store incoming commands serial port string indata; void setup() { serial.begin(9600); serial.println("initialized\n"); } void loop() { while (serial.available() > 0) { char recieved = serial.read(); indata += recieved; // process message when new line character recieved if (recieved == '\n') { serial.println("arduino received: "); serial.println(indata); indata = ""; // clear recieved buffer } } } it uploads fine, , prints "initialized" doesn't work if try "send" data. serial.read() returns , int . need cast (char) in order store char. char recieved

python - How to receive dbus signals when there is a webserver running forever? -

hey guys planning make webserver works dbus signal receiving. webserver runs gevent.wsgiserver because need support of websocket, while dbus handled via python-dbus package. the question is: webserver has event loop running forever, receive dbus signals, python-dbus requires event loop (which mainloop) run forever well. i not able make webserver running while keeping snooping dbus signals. here codes: if __name__ == '__main__': log = logging.getlogger('rocket.errors') log.setlevel(logging.info) log.addhandler(logging.streamhandler(sys.stdout)) dbus.mainloop.glib.dbusgmainloop(set_as_default=true) bus = dbus.systembus() app = bottle() # register dbus recieve handler #bus.add_signal_receiver(hostheartbeatsignal) bus.add_signal_receiver(testsignal) **this block webserver running!!!!!!!!** mainloop = gobject.mainloop() mainloop.run() @app.route('/websocket', skip = true) def handle_websocket(

Swift - Compile error when constraining associated type -

so don't have write code replicate error - might should using generics in case, feels solution should work. following block of code gives me "type dcserviceclient not conform protocol dmserviceclient": protocol dmserviceendpoint { } protocol dcserviceendpoint: dmserviceendpoint { } protocol dmserviceclient { typealias endpoint: dmserviceendpoint } class dcserviceclient: dmserviceclient { typealias endpoint = dcserviceendpoint } however, if remove constraint on associated type (endpoint), compiles without issues. because dcserviceendpoint conforms constraint (dmserviceendpoint) seems should compile. ideas i'm missing here? guys! protocol dmserviceendpoint { } protocol dcserviceendpoint: dmserviceendpoint { } protocol dmserviceclient { typealias endpoint: dmserviceendpoint } class dcserviceclient: dmserviceclient { typealias endpoint = newclass // implementation class conforms endpoint } // add new class conforms dmserviceendpoint cl

javascript - Rails 4 - event to run code after a partial is rendered -

i have js.erb file called ajax through controller action. js.erb file renders partial. inside partial data attribute generated based model. need way run code after partial rendered because code using information in data attribute. items_controller.rb def remove_tag @item = item.find_by_id(params[:id]) //code remove tag item @item.save respond_to |format| format.js @item.reload end end remove_tag.js.erb $("#taglist").html('<%= escape_javascript(render partial: "items/tag_list", locals: {item: @item}) %>'); //the code below needs run after above partial rendered $('#add-tag').rules("add", { taguniqueness: $('#taglist').data('tag-list').split(', ') }); _tag_list.html.erb <div id="taglist" data-tag-list="<%= item.all_tags_list %>"> //more html </div> the way now, .rules method using html data there before partial upda

html - Cannot override padding in print style when transition-duration is set -

Image
i have peculiar problem seems affect chrome (tested in chromium 47.0.2526.73 on ubuntu, chrome 48.0.2564.82 m on windows, firefox 43.0.4 on ubuntu), , in actual print-preview (the problem not occur when emulating print media in developer tools). i have been trying fix issue print styles in gitlab, in there undesirable gap on left-hand side of page, shown below. now, 1 expect easy fix. main container element has padding-left of 230px leave room sidebar, needs 0 when printing. however, cannot print style in place eliminates padding. i have reduced down minimal test case, shown here . i'd use in-place snippet, doesn't work when try print-preview it. source of example follows: <!doctype html> <html> <head> <title>print style problem demonstration</title> <style type="text/css" media="all"> .page-with-sidebar { background: purple!important; transition-duration: .3s; } @media(min-width: 1199px) { .page-side

sql server - Azure SQL Database - Indexing 10+ millions rows -

i have database hosted on azure sql database , below schema single table: create table [dbo].[article]( [articlehash] [bigint] not null, [feedhash] [bigint] not null, [publishedon] [datetime] not null, [expireson] [datetime] not null, [datecreated] [datetime] not null, [url] [nvarchar](max) null, [title] [nvarchar](max) null, [summary] [nvarchar](max) null constraint [pk_dbo.article] primary key clustered ( [articlehash] asc, [feedhash] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) i have few queries i'm executing slow since table contains on 10 million records: select * (select row_number() on (order publishedon desc) page_rn, * article (feedhash = -8498408432858355421 , expireson > '2016-01-18 14:18:04.970') ) paged page_rn>0 , page_rn<=21 and 1 more: select articlehash article (feedhash = -8498408432858355421

c# - Server startup error -

server start error when trying add purger timer ( game feature) seems server not allowed access? purgetimer: using system; using system.threading; using system.collections.concurrent; using plus.habbohotel.gameclients; using plus.habbohotel.rooms; namespace plus.habbohotel.minigames.purge { /// <summary> /// countdown before match starts /// </summary> public class purgetimer { /// <summary> /// timer our operation /// </summary> private timer timer; public bool on = false; /// <summary> /// constructor /// </summary> public purgetimer() { // method call when completed timercallback timercallback = ticked; // create new instance of timer timer = new timer(timercallback, null, 30000, timeout.infinite); } /// <summary> /// method call when timer finished /

javascript - node.js hapi.js socket memory leak on server AWS -

Image
i have stack of servers on aws, , seems leaking memory. heapdump showing have ever increasing sockets in array, peer of sockets elbs sit in front of server instances. the elbs ping health check every 6 seconds. how close these sockets if using hapi.js? how fix memory leak? const config = require('./config'); const hapi = require('hapi'); const path = require('path'); const fs = require('fs'); server = new hapi.server({ debug: { request: ['error'] }, connections: { routes: { files: { relativeto: path.join(__dirname, 'public') } } } }) var connectiondict = { port: config.port, host: config.host} server.connection(connectiondict); module.exports = server; server.start(function () { setimmediate(function(){ server.log([controller_name, "server-start"], 'server started at: ' + server.info.uri); }); }); server.route({ method: 'get', p

ios - Parse PFRelation complex search -

i'm building ios app parse has few complex queries , running trouble pfrelation. it's social network website people submit articles. can follow other users , see articles submitted. can search based on topics. this code have pfquery* query = [pfquery querywithclassname:@"article"]; //remove articles user has seen or submitted [query wherekey:@"likedby" notequalto:currentuser]; //'likedby' relation [query wherekey:@"dislikedby" notequalto:currentuser]; //'dislikedby' relation [query wherekey:@"submittedby" notequalto:currentuser]; //'submittedby' relation [query wherekey:@"tagarray" containedin:tags]; [query orderbydescending:@"createdat"]; pfrelation* relation = [currentuser relationforkey:@"following"]; //following relation user pfquery* followingquery = [relation query]; [followingquery findobjectsinbackgroundwithblock:^(nsarray* results, nserror* error) { //results

shell - Extract tokens from log files in unix -

i have directory containing log files. we interested in particular log line goes 'xxxxxxxxx|platform=sun|.......|orderid=abcdeg|........' have extract similar lines log files in directory,and print out token 'abcdeg'. duplication acceptable. how achieve single unix command operation? sed -r '/platform=.*orderid=/s/.*orderid=([^|]+).*/\1/g' * from lines containing platform= && orderid= ( /platform=.*orderid=/ ), take non-| sequence of characters ( ([^|]+) )after orderid= .

HighCharts: how to update bar color when updating the point value -

i use "update" command refresh value of point in series: mychart.series[0].data[i].update(sigvalue); now update color of column/point well. tried mychart.series[0].data[i].color = "#ff0000"; but did not work... color should changed attr() function. http://jsbin.com/ubapaz/10/edit $('#test').click(function() { chart.series[0].data[4].graphic.attr("fill","#ff0000"); }); api here reference.

mysql - Sql Join taking a lot of time -

i tying execute query taking more 5 hours, data base size 20mb. code. here joining 11 tables reg_id. need columns distinct values. please guide me how rearrange query. select * degree join diploma on degree.reg_id = diploma.reg_id join further_studies on diploma.reg_id = further_studies.reg_id join iti on further_studies.reg_id = iti.reg_id join personal_info on iti.reg_id = personal_info.reg_id join postgraduation on personal_info.reg_id = postgraduation.reg_id join puc on postgraduation.reg_id = puc.reg_id join skills on puc.reg_id = skills.reg_id join sslc on skills.reg_id = sslc.reg_id join license on sslc.reg_id = license.reg_id join passport on license.reg_id = passport.reg_id group fullname please me if did mistake this bit long comment. the first problem query using select * group fullname . have zillions of columns in select not in group by . unless really, really, know doing (which doubt), wrong way write query. your performance

sql server - How to update datetime field in MSSQL using python pyodbc module -

i trying update db table using convert(datetime,'19-01-16 11:34:09 pm',5) , when pass string insert db table i'm getting data type conversion error. conversion failed when converting date and/or time character string. insert run (runid, startdate) values ('19012016',"convert(datetime,'19-01-16 11:34:09 pm',5)") you getting error because passing treating string value. instead: insert run(runid, startdate) values ('19012016', convert(datetime, '19-01-16 11:34:09 pm', 5)) that is, had many quotes. in python, typically written as: """insert run(runid, startdate) values ('19012016', convert(datetime, '19-01-16 11:34:09 pm', 5))""" if want insert values: """insert run(runid, startdate) values ('{0}', convert(datetime, '{1}', 5))""".format("19012016", "19-01-16 11:34:09 pm") i su

ios - Thread 1:EXC_BAD_INSTRUCTION error when calling "addObjectsFromArray"method for NSMutableArray -

i have created program calculates borders of countries based on custom object being inputed function. function returns array of custom objects. keep getting error when trying add array nsmutablearray. error called "thread 1: exc_bad_instruction(code=exc_1386_invop, subcode=0x0)". here adding code: @iboutlet var label: uilabel! @iboutlet var imageview: uiimageview! override func viewdidload() { //afganistan afghanistan.name = "afghanistan" afghanistan.borders.addobjectsfromarray(relate(afghanistan)) label.text = string((afghanistan.borders[0] as! develop).name) } here relate method along group dictionary: func relate(x : develop) -> array<develop>{ var : [develop] = [] (_, value) in groups { y in value { if y.name == x.name { in value { if i.name != x.name { a.append(i) } } } } } return } //groups var

user interface - matlab gui becomes unresponsive or partially closes -

i working on matlab gui , after beginner's problems data handling quite satisfied result. there 1 hiccup: whenever program done running, gui becomes unresponsive , buttons , text elements vanish, can see background. i have scanned functions thoroughly close all; statements , such, there nothing there. how return 'clean' gui can put in more data? need put gui in constant while loop? best wishes chris you can following: modify attribute of controls interruptible: set(handles.figure, 'interruptible','on'); create callback function based on pressing determined key combination. set(keypressfcn, @resume_fcn); create callback function solves problem. function resume_fcn() if eventdata.key = ... exit; end end however, consistency of data may lost. in case don't want return 'clean' gui, can type: delete(get(0,'children'))

ImportError: cannot import name 'PrintTable' in Python 3.5.1 by pyenv -

i installed pyenv manage different versions of python, , use pip install printtable download , install printtable . but when import module in interactive shell, doesn't work , shows importerror . $ pyenv versions system 2.7.11 * 3.5.1 (set /users/apple/.pyenv/version) $ pip list pip (8.0.0) printtable (1.2) setuptools (18.2) $ python python 3.5.1 (default, jan 21 2016, 12:50:43) [gcc 4.2.1 compatible apple llvm 7.0.0 (clang-700.0.72)] on darwin type "help", "copyright", "credits" or "license" more information. >>> import printtable traceback (most recent call last): file "<stdin>", line 1, in <module> file "/users/apple/.pyenv/versions/3.5.1/lib/python3.5/site-packages/printtable/__init__.py", line 1, in <module> printtable import printtable importerror: cannot import name 'printtable' how can manage modules in pyenv? ps. i'm following book aut

Eclipse, save project on main and backup folders -

i using eclipse develop php project, wondering if there way on "save" eclipse saves project on 2 diferent folders, want use google drive folder backup destination , have project on working folder. nope. eclipse doesn't have function saving duplicates. however, there plugins available make integrate nicely git, svn, or other revision control systems proper code backup (assuming regularly push commits remote repository). you can use synced google drive folder workspace, , synced drive.

mysql - Enable hbm2ddl.keywords=auto-quote in Fluent NHibernate -

i have made tiny software tool allows me display or run sql generated nhibernate. made because hbm2ddl.auto not recommended production . i have 1 problem: when generate sql infamous index column unquoted, because need .aslist() mappings. prevents me run sql. in theory, if had xml configuration of nhibernate use hbm2ddl.keywords tag, unfortunately since tool designed dba-supporting tool multiple environments, must use programmatic approach. my approach (redundant) following: private static configuration buildnhconfig(string connectionstring, dbtype dbtype, out dialect requireddialect) { ipersistenceconfigurer persistenceconfigurer; switch (dbtype) { case dbtype.mysql: { persistenceconfigurer = mysqlconfiguration .standard .dialect<mysql5dialect>() .driver<mysqldatadriver>()

java - SAAJ: how to create child elements for SoapHeaderElement -

trying post data remote machine, returns fault <soapenv:fault> <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:client.nosoapaction</faultcode> <faultstring>no soapaction header!</faultstring> my gues there problem in way sending header elements: // java code snip soapheader header = envelope.getheader(); header.setprefix("soapenv"); qname headerelementname = new qname("http://soft.com/webservices/", "authheader"); soapheaderelement authheader = header.addheaderelement(headerelementname); qname headerchild = new qname("username"); soapelement username = authheader.addchildelement(headerchild); username.addtextnode("smart"); headerchild = new qname("password"); soapelement passwd = authheader.addchildelement(headerchild); passwd.addtextnode("smart"); from response, clear soap toolkit on remote machine axis, , final request sent , response looks this:

javascript - How to access the correct `this` inside a callback? -

i have constructor function registers event handler: function myconstructor(data, transport) { this.data = data; transport.on('data', function () { alert(this.data); }); } // mock transport object var transport = { on: function(event, callback) { settimeout(callback, 1000); } }; // called var obj = new myconstructor('foo', transport); however, i'm not able access data property of created object inside callback. looks this not refer object created other one. i tried use object method instead of anonymous function: function myconstructor(data, transport) { this.data = data; transport.on('data', this.alert); } myconstructor.prototype.alert = function() { alert(this.name); }; but exhibits same problems. how can access correct object? what should know this this (aka "the context") special keyword inside each function , value depends on how function

Spark scala running -

hi new spark , scala. running scala code in spark scala prompt. program fine, it's showing "defined module mllib" not printing on screen. have done wrong? there other way run program spark in scala shell , output? import org.apache.spark.{sparkconf, sparkcontext} import org.apache.spark.mllib.classification.logisticregressionwithsgd import org.apache.spark.mllib.feature.hashingtf import org.apache.spark.mllib.regression.labeledpoint object mllib { def main(args: array[string]) { val conf = new sparkconf().setappname(s"book example: scala") val sc = new sparkcontext(conf) // load 2 types of emails text files: spam , ham (non-spam). // each line has text 1 email. val spam = sc.textfile("/home/training/spam.txt") val ham = sc.textfile("/home/training/ham.txt") // create hashingtf instance map email text vectors of 100 features. val tf = new hashingtf(numfeatures = 100) // each email sp

apache pig - Unable to read input file : Pig store to MYSQL using DBStorage -

i trying store data mysql using dbstorage in pig script. when run the script ,i getting error unable read input file. whereas when try dump store same data file working fine. sample pigscript : %default database_host 'localhost'; %default database_name 'test'; %default database_user 'username'; %default database_pass 'password'; %default database_driver 'com.mysql.jdbc.driver'; %default database_type 'mysql'; = load '/tmp/testdivya/pig/pigsqltest.txt' using pigstorage() (name: chararray); store 'test' using org.apache.pig.piggybank.storage.dbstorage('$database_driver', 'jdbc:$database_type://$database_host/$database_name', '$database_user', '$database_pass', 'insert test(name) values (?)'); hadoopversion pigversion userid startedat finishedat features 2.7.1.2.3.4.0-3485 0.15.0.2.3.4.0-3485 hdfs 2016-01-21 01:34:552016-01-21 01:35:07 unkn

How do you track in realtime the costs of google cloud VM instances -

i signed google cloud , track costs in real time or @ least hour. from documentation costs incurred in 10-minute bundles cannot view costs incurred in billings area. you can enable cloud platform billing alerts in developers console , setup billing export provides daily export of usage , cost estimates, in either json or csv formats, easy import favorite tools.

Class Loading issue in websphere -

we have production server websphere instance, copied jar (say, c.jar existing in ear , overriden now) ear deployed hot fix. have class a, referring class b in same jar c.jar, , while loading class a, class b unable find , resulting in noclassfounderror. hot deployment in server disabled. however, after restarting server able find b. property missing? why class b not found although present in same jar, after restart able find. also, before copying jar, old c.jar working fine class , class b loaded. using 6.1 when application server start creates class files of application deployed in jvm instance make available in runtime. explore application other classes gets loaded. when deleting/overwriting jar file breaking link , thats reason other classes not find classes there in c.jar. when restart jvm new class files gets loaded in jvm runtime , find available.

Search a list of names in Neo4J -

i have neo4j database contains large number of user objects each user having fields name, contact, email etc. suppose there list contains values "aa","bb","cc"... i want retrieve users name contains letters of strings in above mentioned list what cypher ? i able write cypher "=~ (?i). "+searchtext+". " worked single string seach. problem when there list of strings search. i can iterate on each string in list not idea if search list contains large number of search strings. in 3.0 contains (see http://neo4j.com/docs/stable/query-where.html#query-where-string ) utilize indexes. reference here's pull request this: https://github.com/neo4j/neo4j/pull/6233 for doing in 2.3.x (or earlier) suggest use manual indexes regexquery written in java , deployed unmanaged extension. details on take @ blog post @ http://blog.armbruster-it.de/2014/10/deep-dive-on-fulltext-indexing-with-neo4j/

java - Android: Access SharedPreferences from a home widget in another class -

i have activity runs method in class access sharedpreferences. want make widget can run same method button click. works long app open in background, if closed, app crashes when press button on widget. i because of context need access sharedpreferences, , tried passing context through activity , widget separately not working. basically, how can access sharedpreferences widget when method in class? activity code: public class mainactivity extends appcompatactivity { protected static context context; sharedpreferences prefs; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mainactivity.context = getapplicationcontext(); } public void panicfromview(view view){ prefs = preferencemanager.getdefaultsharedpreferences(context); methods.panic(prefs); } } widget code: public class panicwidget extends appwidgetprovider {

python - Calculate average tuples in one million dataset scenario -

given dataset of 1 million data, wish calculate average price of items. of itemid replicated, , that's key. for instance, given following dictionary: res = { '155': ['3','4','5'], '222': ['1'], '345': ['6','8','10'] . (+ 1 million more lines) .} i wish calculate average price each itemid , return dictionary. expected output be: {'155': ['4'], '222': ['1'], '345': ['8'] . . .} , integer next itemid average price. i wish unpack res list , calculate average price before returning result dictionary. for x, y in res: // calculate average , add new dictionary however, terminal shows there problem: ----> 9 k, l in res: 10 print(k) 11 valueerror: many values unpack (expected 2) am supposed iterate through 1 million datasets average price? great! the __iter__ attribute of dictionary object it

Spring oauth2 add tables prefix name -

spring default oauth2 create 5 tables : oauth_access_token oauth_approvals oauth_client_details oauth_client_token oauth_code oauth_refresh_token i need add prefix tables example adm_ oauth_refresh_token option ? you didn't mention lot configuration (in fact didn't mention lot in general), can set sql statements respective setters following classes (follow link source code): jdbctokenstore jdbcapprovalstore jdbcclientdetailsservice jdbcauthorizationcodeservices jdbcclienttokenservices

iphone - Facebook error while login the facebook -

i need post details on wall, when login facebook got following error, - (void)dialog:(fbdialog*)dialog didfailwitherror:(nserror *)error { nslog(@"error message: %@", [error localizeddescription]); } operation couldn’t completed. (nsurlerrordomain error -999.) first time got error, next time shared perfectly. sharing using this, [[delegate facebook] dialog:@"feed" andparams:params anddelegate:self]; how can fix error. why error occurred. thank you.

jquery - Check if window pathname(url) has specific value -

good day. i want check if current browser window pathname has specific value or not... but code not working...any help? jquery(function($){ var pathname = window.location.pathname; if ($pathname == 'http://google.com') { alert($pathname); } }); thank you if ($pathname == 'http://google.com') { should be if (pathname == 'http://google.com') { //no $ because declared as var pathname = window.location.pathname;

Java- Builiding a recursion that replace even digits with zero -

hello need build recursion replace digits zero: exmaple - number 1254 1050 number 332- 330 , number 24 - 0 i started working on got pretty clueless after while public static int replaceevendigitswithzero(int number){ if(number<1) return number; if(number%2==0 && number%10!=0){ int temp=number%10; return(number/10+replaceevendigitswithzero(number-temp)); } return(replaceevendigitswithzero(number/10)); } public static void main(string[] args) { int num1 = 1254; system.out.println(num1 + " --> " + replaceevendigitswithzero(num1)); int num2 = 332; system.out.println(num2 + " --> " + replaceevendigitswithzero(num2)); int num3 = 24; system.out.println(num3 + " --> " + replaceevendigitswithzero(num3)); int num4 = 13; system.out.println(num4 + " --> " + replaceevendigitswithzero(num4)); } } since metho

php - onclick change css -

i making simple calendar app in php , want change <td> block style depending on user does. want when "menuclick" class on, other classes stop working until click block. previous block should turned off well. in advance. echo'<td onclick=classname="menuclick"; onmouseover=classname="menuon"; onmouseout=classname="menuoff";>' . $countday++ . "</td>" i think can achieve want using following: echo '<td onclick="this.classname=\'menuclick\';" onmouseover="this.classname=\'menuon\';" onmouseout="this.classname=\'menuoff\';">' http://jsfiddle.net/wdu9v/ seeing though giving jquery answer , jbabey complaining inline js: $('td').each(function() { $(this).mouseenter(function() { $(this).removeclass().addclass('menuon'); }); $(this).mouseleave(function() { $(this).removeclass().addclass(&

Find And Replace with Multiple Words -

i trying replace same word in multiple files different words. for instance, document 1 should search word x, , replace word 1 list. document 2 replaces word x word 2 list document 3 replaces word x word 3 list etc. etc. i have tried textcrawler, , macros - don't know if possible or best way start.

module - Create table with colspan in drupal 7 -

may know how create table can add colspan in table ? module can ? been search hours table field plugin far found. cannot add colspan within. is there anyway ?

c# - Binding DataTable object with ListBox in WPF vs Binding DataTable object with ListBox in Windows Form Application -

i learned in windows forms application following youtube tutorial i'm having hard time implementing same approach in wpf. private void populatenames() { using (connection = new sqlconnection(connection_string)) using (sqldataadapter adapter = new sqldataadapter("select * namestable", connection)) { datatable namestable = new datatable(); adapter.fill(namestable); debug.write(namestable.asdataview()); nameslistbox.displaymemberpath = "name"; nameslistbox.selectedvaluepath = "id"; nameslistbox.itemssource = namestable.asdataview(); } } and xaml listview is <grid> <listbox itemssource="{binding}" displaymemberpath="name" x:name="nameslistbox" horizontalalignment="left" height="209" margin="90,59,0,0" verticalalignment="top" width="341" selectionchanged="lis

java - android take multiple image with camera -

Image
i've made code capturing image using device built-in camera , archiving in database server. each time captures image , views it, make imageview layout dynamically (ex: image ic_launcher ) . whenever ic_launcher image clicked, go mainactivity.java page, use of intent, take image. my question is, how can view of captured images / archived images in uploadactivity.java ? note : image viewed in uploadactivity.java mainactivity.java private void captureimage() { intent intent = new intent(mediastore.action_image_capture); fileuri = getoutputmediafileuri(media_type_image); intent.putextra(mediastore.extra_output, fileuri); // start image capture intent startactivityforresult(intent, camera_capture_image_request_code); } @override protected void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); // save file url in bundle null on screen orientation // changes outstate.putparcelable("file_uri", fi

php - How to handle user_row_actions in WordPress? -

Image
first of all, have not find solution problem. have read few articles , thread create user actions , , tried following code. function kv_admin_deactivate_link($actions, $user_object) { $actions['deactivate_user'] = "<a href='" . admin_url( "users.php?action=deactivate&amp;user=$user_object->id") . "'>" . __( 'deactivate', 'kvc' ) . "</a>"; return $actions; } add_filter('user_row_actions', 'kv_admin_deactivate_link', 10, 2); after using above code gets me additional action users list in below screenshot. now, problem is, don't know how proceed write codes deactivate user. can me write function handle /wp-admin/users.php?action=deactivate&user=41 . here writing these function wordpress theme , how can write function it. this perform deactivate operation function. create admin menu following code. function xxxadmin_submenu_email() {

javascript - angular controllers - two way broadcasting -

i have controller wraps ui-router , control flow (like menu bar). when user press on menu item, there function changes ui-router state , broadcast event inner controllers. every inner controller inside ui-router can listen , act event. inner controllers making validation on event if validation fails cannot undo state change. idea how solve problem? thanks update : using ui-router $statechangestart event approach still incomplete. problem is, main controller hosts ui-router , menu bar has progress bar. main controller registered $statechangestart , taking care of progress bar, child view register event preventing default. means controllers in inconsistent mode. main controller has took care of progress bar , view did not changed. please advise the ui-router issues $statechangestart event. your controllers can use event.preventdefault() prevent transition happening. $scope.$on('$statechangestart', function(event, tostate, toparams, fromstate, fromparams

Easiest way to cast pivot table in Laravel Eloquent? -

what easiest way cast pivot table in laravel? class product{ public function sales(){ return $this->belongstomany(sale::class) ->withpivot('qty', 'price'); } } when return price string, need change int.

C++ - WINAPI - Object-oriented approach to closing a window -

while trying create nice wrapper around win32 specific gui components, ran problem. problem i'm unable close application after windows created no longer exist. my api works this: /// ---------------------------- /// @author god /// @project helixirr widgets /// ---------------------------- #include <helixirrwidgets/helixirrwidgets.hpp> int main(void){ helixirrwidgets::window __windows[2] = {helixirrwidgets::window("big window"), helixirrwidgets::window()}; __windows[0].position(200, 200); __windows[0].size(800, 600); __windows[0].visible(true); __windows[0].save_changes(); __windows[1].name("tiny window"); __windows[1].position(10, 100); __windows[1].size(400, 200); __windows[1].visible(true); __windows[1].save_changes(); while(__windows[0].active() || __windows[1].active()){ if(__windows[0].visible()){ __windows[0].show(); } if(__windows[1].visible()){

multithreading - Running C++ threads from different scope using join() -

let's assume situation have 2 functions: void foo1 () { while (true) { std::cout << "foo1" << std::endl; std::this_thread::sleep_for (std::chrono::milliseconds {100}); } } void foo2 () { while (true) { std::cout << "foo2" << std::endl; std::this_thread::sleep_for (std::chrono::milliseconds {100}); } } and want start them in different threads whether started dependent on condition, example execution of them below: bool c1 {true}; bool c2 {true}; if (c1) { std::thread th1 {&foo1}; th1.join (); } if (c2) { std::thread th2 {&foo2}; th2.join (); } i know here in situation foo1() invoked , foo2() never. my first thought use unique_ptr this: bool c1 {false}; bool c2 {false}; std::unique_ptr<std::thread> pth1 {}; std::unique_ptr<std::thread> pth2 {}; if (c1) { pth1 = std::unique_ptr<std::thread> {new std::thread {&foo1}