Posts

Showing posts from July, 2013

python - How to highlight a specific word in tkinter? -

i need highlight specific word in text within tkinter frame. in order find word, put balise in html. in text "hello i'm in |house|" want highlight word "house". my frame defined that: class framecodage(frame): self.t2codage = text(self, height=20, width=50) and insert text code: fenetre.fcodage.t2codage.insert(end, res) , res being variable containing text. i saw code on other post: class customtext(tk.text): '''a text widget new method, highlight_pattern() example: text = customtext() text.tag_configure("red", foreground="#ff0000") text.highlight_pattern("this should red", "red") highlight_pattern method simplified python version of tcl code @ http://wiki.tcl.tk/3246 ''' def __init__(self, *args, **kwargs): tk.text.__init__(self, *args, **kwargs) def highlight_pattern(self, pattern, tag, start="1.0", end="end", regexp=false): ...

servicebus - Trying to communicate with azure service bus from android device using proton-j -

i trying make android app talk azure service bus using proton-j library when try add proton-j-0.11.1 jar file library on android project. try send azure service bus end exception broken epipe broken: 01-15 19:37:02.165: e/proton.messenger(822): error processing connection 01-15 19:37:02.165: e/proton.messenger(822): java.net.socketexception: sendto failed: epipe (broken pipe) 01-15 19:37:02.165: e/proton.messenger(822): @ libcore.io.iobridge.maybethrowaftersendto(iobridge.java:506) 01-15 19:37:02.165: e/proton.messenger(822): @ libcore.io.iobridge.sendto(iobridge.java:489) 01-15 19:37:02.165: e/proton.messenger(822): @ java.nio.socketchannelimpl.writeimpl(socketchannelimpl.java:378) 01-15 19:37:02.165: e/proton.messenger(822): @ java.nio.socketchannelimpl.write(socketchannelimpl.java:336) 01-15 19:37:02.165: e/proton.messenger(822): @ org.apache.qpid.proton.driver.impl.connectorimpl.write(connectorimpl.java:168) 01-15 19:37:02.165: e/proton.messenger(822): @ o...

java - Mail form in Play Framework 2.0.X -

i'm using play framework (2.0.4) , wonder best way create page form sending email. know there plugin sending email, isn't problem - can write controller method sends email. my question more action should provide (in routes file). should create post action takes arguments (sender name, sender email, subject, body)? or should somehow create model object filled in form , pass action in controller? best practice? , how glue (how should action in routes file, how should view like)? you need 2 views - 1 form (let's call mailform ), second - body ( bodyhtml ) of mail. (optionally can create bodytxt if want send html , txt version. dedicated model helper, use play's form<t> , if required able store sent messages in db. anyway can operate on map of strings - if plan make many dynamic forms (with unknown number of fields). after filling form go example sendemail() action, need fill form ( bindfromrequest ) create object , save db , pass bodyhtml view ...

Unicorn + Nginx Rails production error -

i'm following this tutorial deploy ror app capistrano i'm getting error in production server [error] 28314#0: *1 connect() unix:/tmp/unicorn.myapp.sock failed (111: connection refused) while connecting upstream, client: xx.xxx.xx.xx, server: , request: "get / http/1.1", upstream: "http://unix:/tmp/unicorn.myapp.sock:/", host: "myapp.cloudapp.azure.com" my /etc/nginx/sites-available/default upstream app { # path unicorn sock file, defined server unix:/tmp/unicorn.myapp.sock fail_timeout=0; } server { listen 3000; server_name localhost; root /home/deploy/apps/myapp/current/; try_files $uri/index.html $uri @app; location @app { proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_redirect off; proxy_pass http://app; } error_page 500 502 503 504 /500.html; client_max_body_size 4g; keepalive_timeout 10; } i changed server many different things, exac...

javascript - Promise inside a settimeout -

i'm trying run promises in 1 second delay each other, api server i'm working has 1 request per second limit. here code currently var delay = 0; return categories.reduce(function(promise, category) { var id = settimeout(function() { promise.then(function() { return client.itemsearch({ searchindex: configuration.searchindex, categoryid: category.id, keywords: currentkeyword }).then(function(results) { var title = results[0].title; var cat = category.name; var price = results[0].price; return db.insertproduct(title, cat, price); }); }).catch(function(err) { console.log("error", err); }); }, delay * 1000); delay += 1; }, promise.resolve()); for every time loops over, increases delay one, next item start delay of 1 second. so if first item, 0*1 = 0, 1*1 = 1, 2*1 = 2... on for reason, doesnt work, without settimeout works perfectly. as far can tell, there s...

javascript - Looping Through Array Until Solution Found -

so have array below first value of each array being road name, second value being connections road , third can ignore (all fake roads). trying find quickest route (least steps) 1 road looking @ connections.. code looking through phases defined myself, add further connections i'll have add further logic - there anyway of looping through undefined amount until finds best route (there no point can't find route)? array: var road = [ //name, connection, [left, middle, right] ["upper-g", ["lower-g", "left corner", "top corner"], []], ["upper-tw", ["lower-tw", "left corner", "right corner"], []], ["upper-rg", ["lower-rg", "upper-rg", "top corner", "right corner"], []], ["lower-g", ["upper-g", "left corner", "top corner"], [] ], ["lower-...

c# - Proper Architecture: Adding Attributes to Domain Model in .NET -

Image
background i jeffrey palermo's onion architecture model (similar hexagonal architecture ) prescribes domain model @ 'center' , concrete implementations of infrastructure, concrete repositories on periphery. so have domain model : //https://libphonenumber.codeplex.com/ using libphonenumber; namespace myapplication.domain { public class speaker { public virtual string name {get;set;} public virtual phonenumber phonenumber {get;set;} } } now need expose domain model other teams: the ui team hypothetically wants add several data validation attributes , custom json serialization attributes. the infrastructure team hypothetically wants add xml serialization attributes , custom attributes 3rd party database implementation. the public api team hypothetically wants add wcf attributes. i don't want give every team carte blanche add attributes domain model and don't want them adding of "layer specific" depend...

javascript - Regex: Replace foo if it's a word or inside a URL -

given this: str = "foo myfoo http://thefoobar.com/food awesome"; str.replace(magicalregex, 'bar'); the expected result is: "bar myfoo http://thebarbar.com/bard awesome" i \b(foo)\b part, can't figure out how match , capture foo within url. these purposes, assume urls start http . any help? you can use code (works example haven't tried more complex inputs): str = 'foo myfoo http://thefoobar.com/food awesome'; str = str.replace(/\bfoo\b/g, 'bar'); while (/http:\/\/[^\s]*?foo/.test(str)) str = str.replace(/(http:\/\/[^\s]*?)?foo/g, function($0, $1) { return $1 ? $1 + 'bar' : $0; }); console.log(str); output: bar myfoo http://thebarbar.com/bard awesome live demo: http://ideone.com/8xgy2h

c++ - Loading a text file in to memory and analyze its contents -

for educational purposes, build ide php coding. i made form app , added openfiledialog ..(my c# knowledge useful, because easy ... though without intelisense!) loading file , reading lines same in every language (even perl). but goal write homemade intelisense. don't need info on richtextbox , events generates, endline, eof, etc, etc. the problem have is, how handle data? line line? a struct each line of text file? looping structs in linked list? ... while updating richtextbox? searching opening , closing brackets, variables, etc, etc i think microsoft stores sql type of database in app project folders. how keep track of variables , simulate them in sort of form? i know how handle efficiently on dynamic text. having never thought through before, sounds interesting challenge. personally, think you'll have implement lexical scanner, tokenizing entire source file source tree, each token having information mapping token line/character inside of so...

Linux PCIe Driver: What to use for private data structure? -

i'm creating first pcie driver linux , have question regarding structure use pci_set_drvdata() function. the pcie hardware built in house , using dma send data , device. not sound card or other subsystem needs plugged kernel. when @ examples there seems specific struct fill in , send pci_set_drvdata() . what fill in case? ignore , send in blank structure? line referring in pcie driver is: struct structure_in_question *my_struct; my_struct = kzalloc( sizeof(*my_struct), gfp_kernel) ); this found in probe() function. that function used associating device private data cannot supplied other way. if there no such data function should not used.

java - I want to search a specific element of an array and if it exists to return its index -

i have created array of type savings contains string (name) , double (account number). want search using account number , see if exist , return elements (name + account number) , index of array contain these elements. tried not work. import java.util.arrays; import java.util.scanner; public class main { public static void main(string[] args){ savings[] arrayofsavings = new savings[5]; system.out.print("enter account number: "); scanner scan = new scanner(system.in); double ms = scan.nextdouble(); //loop until length of array for(int index = 0; index<= arrayofsavings.length;index++){ if(arrayofsavings[index].equals(ms)){ //print index of string on array system.out.println("found on index "+index); } } arrayofsavings[0] = new savings("giorgos",87654321); arrayofsavings[1] = new savings("panos",33667850);...

angularjs - Problems loading module when separating files into directories -

i'm working on angularjs 1 , rails 4.2 application. i'm using angularrailstemplates load angularjs templates. i have of angularjs controllers, config, routing, , factories in one single file . i'm trying separate these entities designated directories (i.e. see below). | application.js | controllers | guest.js | user.js | factories | lists.js | templates | home.html | dashboard.html i have separated controller , factory files modules. example, in controller directory, have 2 controller files: controllers/guest.js angular.module('diction.controllers') /* guest controller * controller static clientside guest users * */ .controller('guestctrl', ['$scope', '$stateparams', 'auth', '$http', '$window', // logic }]); controllers/user.js angular.module('diction.controllers') /* user controller * controller users * */ .controller(...

Issue Using VideoView in Android -

i'm having similar issue.i'm newly working genymotion , android studio , trying implement video view showing errors e/mediaplayer: error (1,-2147483648) , w/egl_genymotion: eglsurfaceattrib not implemented the code share bellow working in eclips not android studio here xml file <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#fff" > <videoview android:id="@+id/video_view" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </relativelayout> and java code is import android.app.activity; import android.content.intent; import android.net.uri; import android.os.bundle; import android.view.keyevent; import android.view.window; ...

Wordpress Search Query not returning User -

when search user first name, of posts show in dashboard. when search same user , add last name, not show @ all. not sure why happening author. have made settings same other users have written posts well. here's first search url , query, returns posts written user. http://trochia.org/?s=dani when add last name, there no results. http://trochia.org/?s=dani+nichols here's user, no issue first name or combination of first , last name. http://trochia.org/?s=fred http://trochia.org/?s=fred+gladney figured out. function atom_search_where($where){ global $wpdb; if (is_search()) $where .= "or (t.name '%".get_search_query()."%' , {$wpdb- >posts}.post_status = 'publish')"; return $where; } function atom_search_join($join){ global $wpdb; if (is_search()) $join .= "left join {$wpdb->term_relationships} tr on {$wpdb->posts}.id = tr.object_id inner join {$wpdb->term_taxonomy} tt on tt.term_taxonomy_id=tr.term_taxon...

apache pig - Looking up variable keys in pig map -

i'm trying use pig break text lowercased words, , each word in map. here's example map, have in map.txt (it 1 line long): [this#1.9,is#2.5my#3.3,vocabulary#4.1] i load so: m = load 'mapping.txt' using pigstorage (mp: map[float]); which works fine. following load text , break lowercased words: lines = load 'test.txt' using textloader() (line:chararray); tokens = foreach lines generate flatten(tokenize(lower(line))) (word:chararray); now, i'd this: results = foreach tokens generate m.mp#word; so if have line "this my vocabulary", i'd following output: 1 3 3 4 , keep getting various errors. how can variable values in map? i've looked @ how can use map datatype in apache pig? , http://pig.apache.org/docs/r0.10.0/basic.html#map-schema , these if i'm looking fixed value in map, example m.mp#'this', not want here. you can flatten m , join m , lines based on token/word (you can 'replicated' join...

javascript - Inject JS function with Greasemonkey -

i have pretty simple html code displays browsers current working area: <html> <head> </head> <body> <script type="text/javascript"> wwidth = document.body.clientwidth; wheight = document.body.clientheight; alert("working area is: " + wwidth + "x" + wheight); </script> </body> </html> i trying tamper these values own ones using following greasemonkey script (i have used following topic reference) not seem work: // ==userscript== // @name resolution // @namespace 1 // @include * // @version 1 // @grant none // ==/userscript== function main () { object.defineproperty(body, "clientwidth", {value: '1000'}); object.defineproperty(body, "clientheight", {value: '1000'}); } var script = document.createelement('script'); script.appendchild(document.createtextnode('('+ main +')();')); (document.body || document.head ||docume...

Can I highlight the prompt line in the Rails console? -

working more in rails console these days , helpful if somehow highlight (color, bold , anything) lines i'm typing command stand out rails output. could highlighting prompt somehow. possible? if want customize prompt in rails console, looking pry gem lets customize prompt, including adding colors: https://github.com/pry/pry/wiki/customization-and-configuration#config_prompt to use automatically rails, include pry-rails gem well. if want syntax highlighting type in pry console you'll want pry-coolline gem.

java - "streaming" localy : UDP, TCP, something else? -

i'm trying work on code of mixing console , need advices before coding (hoping question won't "off topic"). in project, on each "stripe" of mixing console, i'll can enter source : audio file player, microphone... succed first part. in last stripe called "master", have collect sound signals mix them together. first test, i'll try add them (and see happens). but question : what's best way send sound stripe master ? lag have short : if sing in microphone while music playing, voice collected in microphone have arrive in master "immediatly" mixed, , not 15 seconds later... so, thought using simple udp transfert : it's fast comparated tcp. i'll "stream" each stripe on local address 127.0.0.1 (and not on whole internet), consider "datagram losses" insignificant ? or shall try implement rtp (really heavier...) on udp ? or else didn't thought ? i don't post code because aim have advices b...

Java Generics Casting between Interfaces -

this question has answer here: is list<dog> subclass of list<animal>? why aren't java's generics implicitly polymorphic? 12 answers i have question according casting when generics in java used. tried provide small example explains problem. ivariable.java public interface ivariable { } iproblem.java public interface iproblem<v extends ivariable> { } algorithm.java public class algorithm<v extends ivariable, p extends iproblem<v>> { public void dosomething(p problem) { // error: type mismatch: cannot convert p iproblem<ivariable> iproblem<ivariable> genericproblem = problem; } } why need cast variable genericproblem explicitly @suppresswarnings("unchecked") iproblem<ivariable> genericproblem = (iproblem<ivariable>) problem; and warning? the method has...

c# - How to get list of SQL Servers 2016 on local machine ( in the most correct way )? -

unfortunately old ways listed in topic how list of sql server instances on local machine? seems working new versions of sql servers have. i have sql server 2016. i can server list register don't think can call "correct way". so question correct way list? thank suggestions!

express - AngularJS $resource returns empty object and doesn't update with data -

Image
i have basic get/post api right angularjs , express/node. i'm trying make spa angular can add, get, , delete boards (basically post-it notes web). every time button clicked, fires $scope.addboard, $resource object makes post request. it fires alright, returns empty object updates html automatically empty data only. if want board populated information, have manual refresh of whole page. tried incorporating call , using promise, can't either option work. there way can html update automatically full data after post request made angular way?? services.js krelloapp.factory('boards', ['$resource', function($resource) { return $resource('api/boards/:id', {}, { get: {method: 'get', isarray: true}, add: {method: 'post', transformresponse: []} }); }]); controller.js krelloapp.controller('boardcontroller', ['$scope', '$resource', '$location', '$http', 'boards', function($s...

asp.net - Autogenerated number with the use of date and time c# -

having trouble on how going autogenerate number use of date , time. example, need generate kind of number, 16-9685 with, 16 = year , 9685 randomized , shown in textbox. tried 1 unfortunately, doesn't work. helping var random = new random(system.datetime.now.year); int randomnumber = random.next(-1000, -1); textboxsesid.text = randomnumber.tostring(); // keep _r member, not local random _r = new random(); ... // gen random number int rand = _r.next(1, 10000); // "2016-" prefix string yearprefix = datetime.now.year + "-"; // remove first 2 digits of year prefix, "16-" yearprefix = yearprefix.substring(2); // put year prefix random number textbox textboxsesid.text = yearprefix + rand;

listview - Android #View.getHeight() doesn't return correct value -

i have listview in screen. listview fills 2/3 of screen (so height varies on different devices). have - lets 50 items in array list - need put x number of items in visible user (e.g on small screen 3, on normal screen 5, on tablet 8). so way i'm doing getting height of listview in px, dp size , since know height of each row 60dp divide height of listviwe in dp format height of row (which 60dp). returns number of items visible user , pass number getcount() method of adapter populate amount of items. this code, have observer assigned in oncreate() method this.mlistview.getviewtreeobserver().addongloballayoutlistener(mlistviewgloballistener); viewtreeobserver.ongloballayoutlistener mlistviewgloballistener = new viewtreeobserver.ongloballayoutlistener() { @override public void ongloballayout() { removelistviewlistener(); if (mlistview == null || madapter == null) { ...

Reading data from csv file put into dictionary python -

blockquote help me read csv file. have csv file test8.csv , want read data file , put dict , csv file : 1st row matrices size of value dict create, 2nd row key of dict , next matrix of value of key : file csv: 1,5 offense involving children 95 96 35 80 100 2,2 battery,theft 173,209 173,224 output expectation: dict={['offense involving children']: [(95,), (96,), (35,), (80,), (100,)], ['battery', 'theft']:[(173, 209), (173, 224)]} this piece of code, , don't have idea continue: _dir = r'd:\s2\semester 3\tesis\phyton\hasil' open(os.path.join(_dir, 'test8.csv'), 'rb') csv_file: datareader= csv.reader(csv_file, delimiter=' ', quotechar='|') that isn't csv file , csv module can't you. in csv file, each line has equal number of columnar fields separated known character such comma. need write own parser data. this script build dictionary (except uses tuple k...

jquery - Error in update and insert query in php mysql -

i trying update seen(a bool in database) if seen button clicked , delete row if delete button clicked. doesn't seem work nor data(mysql_error) back. last else part works , data. this php code : if(isset($_post["seen"])){ $fid=$_post["id"]; $sql="update feedback set seen=1 id=$fid"; mysql_query($sql,$con); echo mysql_error($con); } else if(isset($_post["delete"])){ $fid=$_post["id"]; $sql="delete feedback id=$fid"; mysql_query($sql,$con); echo mysql_error($con); } else{ $sql="select * feedback"; $result=mysql_query($sql,$con); while($row=mysql_fetch_array($result)){ $jsondata[]=$row; } echo json_encode($jsondata); } and js code: $("#seen").click(function(){ $.post("main_php.php",{},function(data){ alert(data); }); }); $("#delete").click(function(){ var fid = $('#id').val(); $.post...

excel vba - VBA - Closing or clicking OK in MsgBox from another workbook, -

hi following code in excel vba, sub () workbooks.open ("a.xls") activeworkbook.worksheets("1").select activesheet.commandbutton1.value = true end sub i'm opening workbook (the code inside protected can't modify workbook "b") , clicking run button on worksheet, , returns msgbox ok button. i want know how can use vba close msgbox or clicking "ok" ...i tried use, `application.displayalert = false` before opening workbook "b" not work.. thanks help! there might approach using sendkeys -- sendkeys notoriously temperamental. here more reliable approach: 1) if don't have organized this, have click-event handler of button 1-line sub looks like: private sub commandbutton1_click() process end sub where process sub heavy lifting. in general, think idea have event handlers functioning dispatchers subs. 2) change code process (or whatever choose name it) in following way: a) modify ...

Why is a variable of a predefined type included under "generic"? (Ada) -

i'm in college cs, , started data structures , algorithms class. professor prefers (practically forces us) use ada. in order ahead, started looking things , found snippet of code describing how generic stack might written: generic max: positive; type element_t private; package generic_stack procedure push (e: element_t); function pop return element_t; end generic_stack; what stuck out me variable "max." since of type positive, didn't seem logical generic. perhaps i'm still new idea, thought idea behind generic empty shell , can interchanged different data types upon instantiating. maybe don't understand generics enough. if not, please enlighten me? having variable in formal part of generic way pass constant (at compile time) configure generic. such constant can used define other variables in data structures (like array (1..max)), cannot achieved passing value parameter subprogram. also, ensures both push , pop used same "max...

mysql - INSERT query in PHP Failing (returns blank error) -

this question has answer here: can mix mysql apis in php? 5 answers i'm using following code in attempt insert user-provided values in <form> sql table. when insert query used in phpmyadmin, insertion successful, unsuccessful in following php. connection database successful. <?php $servername = "localhost"; $username = "***"; $password = "***"; $db_name = "my_db"; $trip; $odom; $gals; $ppg; if (isset($_request['trip'])){ $trip = $_request['trip']; $odom = $_request['odom']; $gals = $_request['gals']; $ppg = $_request['ppg']; } // create connection $conn = mysqli_connect($servername, $username, $db_name, $password); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } echo "connected "; here...

sql - How to turn repeated ranking(1-5) row data to column data in TSQL -

i have table data: id sale weekday 1 12 1 2 15 2 3 16 3 4 17 4 5 18 5 6 11 1 7 13 2 8 14 3 9 15 4 10 20 5 11 25 1 12 14 2 13 18 3 14 21 4 15 11 5 .. .. i'd turn into: mo tu th fr 12 15 16 17 18 11 13 14 15 20 25 14 18 21 11 .. thank you! try this select sum(case when weekday = 1 sale else 0 end) mn, sum(case when weekday = 2 sale else 0 end) tu, sum(case when weekday = 3 sale else 0 end) we, sum(case when weekday = 4 sale else 0 end) th, sum(case when weekday = 5 sale else 0 end) fr ( select *, row_number()over(partition weekday order id ) seq_no tablename ) group seq_no as mentioned in sample data if table has 5 days week select sum(case when weekday = 1 sale else 0 end) mn, sum(case when weekday = 2...

PHP comment in array? -

i'm trying comment out snippet between ~/**********/~ in below code inside of php function: $photobody[]="<tr><td colspan=\"".$cols."\"> <table width=\"100%\" border=\"0\"> <tr><td width=\"33%\"> <div align=\"left\" class=\"caption\">".$prev."</div></td> <td width=\"33%\"> ~/***** <div align=\"center\" class=\"caption\">photos <strong>".($photonum-(($rows*$cols)-1))."</strong> <strong>".$endnum."</strong> of <strong>".count($photos)."</strong> <br />".$photopage."</div> ****/~ </td><td width=\"33%\"> <div align=\"right\" class=\"caption\">".$next....

ios - ipa size is increased instead of decreasing Xcode 7.2 -

previously using xcode7.0.1 using xcode7.2 , size of ipa file of project around 44mb . have deleted 22mb of unused images project, size of overall project decreased 22mb , generated ipa file size increased instead of decreasing. size 53mb . ideas possible reason kind of peculiar behaviour? i followed similar discussion on github nothing out of it. for generating ipa file followed following steps: xcode -> product -> archive try disabling bitcode feature of app. enabled default. for disabling feature use link after disabling it, make sure app working fine.. make sure clean project before creating ipa file.

php - Multiple entries in SQL? -

how can store multiple entries in sql in 1 field? example in field phone want let users enter more phones private, home, business etc. any hellp on how can create trat form , how store data in sql? i guess can store them using serialize() function in php how make form , collect information? form: home phone: 321321333 other: 333213213 add also make can edit name field if users want put home tel instead of home phone or pager instead other. any help? please? user serialize() , said. however, working add button need javascript. here form: <form action="action.php" method="post"> <div id="phonenumbers"> <input type="text" value="home phone">: <input type="text" name="0-value" value="(xxx)xxx-xxxx"> </div> <button onclick="addanother();">add phone number</button> <input type="submit> </form> ...

c# - VoIP app on Windows 10 Mobiles got exception The group or resource is not in the correct state to perform the requested operation -

i build voip app on wp 8.0 sdk , deploy on microsoft lumia 535 running windows 10 mobile insider preview build 10586.36. make outgoing call failed, tracing log show reason group or resource not in correct state perform requested operation(hresult = -2147019873) when call function requestnewoutgoingcall of class voipcallcoordinator . after got exception, app can't start outgoing calls when go homescreen, kill app , restart app many times. app can request new incoming call successfully, showing incoming call screen , active call when pressed answer. right still don't know how reproduce bug. have ideas why request new out going call got exception , how working around bug.

node.js - Mongodb db.serverStatus() memory section doesn't show actual value -

i'm trying create chart regarding db.serverstatus() output of remote or local mongodb connections. this command outputs: "mem": { "bits": 64, "resident": 258, "virtual": 4807, "supported": true, "mapped": 2288, "mappedwithjournal": 4576 }, which suits needs. unfortunately i've realized data never gets actual memory data , never change. (i've monitored 10 minutes) am doing wrong ? or there other way actual memory usages ? p.s. i've examined mongostat couldn't make work through meteor-js since it's executable. thanks in advance

navbar - SideNav opening the page in the same window (Yii2) -

Image
i trying use sidenav url open page in same window not redirecting different place. how can ? when click link in sidenav page should open in same window. <?= sidenav::widget([ 'type' => sidenav::type_default, 'heading' => 'dashboard', 'items' => [ [ 'url' => '#', 'label' => 'purchase', 'icon' => 'home', 'items' => [ ['label' => 'suppliers', 'icon'=>'glyphicon transport', 'url'=>'../site/about'], ['label' => 'leaf entry', 'icon'=>'leaf', 'url'=>'#'], ['label' => 'payments', 'icon'=>'phone', 'url'=>'#...

c# - Suggest design: almost every object in app has loggger -

i'm writing application. use nlog logging. in application every object can write log. define protected member that: protected logger logger; protected virtual logger logger { { return logger ?? (logger = logmanager.getlogger(this.gettype().tostring())); } } in case need copy/paste code every base class in application. or see other option: define app-specific root object logger in , subclass it. semantically sounds wrong because not true "is-a" situation me. are there better options? sometimes wish c# support multiple inheritance or mixins.... you write extension method: public static logger logger(this object obj) { return logmanager.getlogger(obj.gettype()); } the drawback bit slower created instance not cached (except internally in nlog, implementation detail), yourself: public static logger logger(this object obj) { logger logger; type type = obj.gettype(); // s_loggers static dictionary<type, logger> if (!s_l...

javascript - Iterate through a hash from the Rails controller in js -

in rails controller have made hash looks this: @data = { term => { node_id => { :name, :matchcode, :credits, :parts => [{ :mp_id, :matchcode, :nr, :selected }] }} now want iterate in js through hash keys , values. @ first need term tried like: for(var s in '#{@data}') { console.log(s); } but seems did wrong it's first time use rails.. passing data server side ruby controller client side javascript code not simple. firstly, javascript has no idea ruby variables, above string '#{data}' evaluates itself. there couple of ways of passing such data: firstly, can set html attribute on dom element server side , read in javascript. might simplest solution when passing string or number, hash quite messy need convert form understandable javascipt - json. though simple do, adds complexity , dirty. second option gon gem. provides object can assign data in controller. handles transf...

php - How to manage a ManyToOne relation with symfony 2 and doctrine -

i’m discovering symfony 2 , training myself on wonderful framework. have newbie questions... i followed tutorial in order manage relations doctrine : http://symfony.com/doc/current/book/doctrine.html well, during tests had question , problem. first question: symphony best practices says it’s better use annotations doctrine mapping instead of yaml in other .orm.yml file. good, totally agree that. "using annotations convenient , allows define in same file". if choose use annotations, guess not need .orm.yml mapping file anymore? suppose have table named usertype. have created entity class usertype.php , added mapping information annotations directly in class. try, adding statement: use doctrine\orm\mapping orm; or not in usertype.php class, symfony display error: no mapping file found named 'usertype.orm.yml' class 'appbundle\entity\usertype if don‘t create usertype.orm.yml file. so question: if choose use annotations, still need .orm.yml mappin...

android - Emulator not installing/running app -

when startup android emulator test application, run problem. i 2 windows open @ bottom of android studio 1 avd:nexus_5_api_23 other 1 app . in avd:nexus_5_api_23 window shows: /volumes/seagate/tools/emulator -netdelay none -netspeed full -avd nexus_5_api_23 haxm working , emulator runs in fast virt mode emulator: emulator window out of view , recentered emulator: updatechecker: skipped version check and app window shows: device connected: emulator-5554 i'm not sure what's going on. i have created other emulators run same issue every-time. my android studio up-to-date. , to test it's not of codes fault. created new project sample code, , still, doesn't run. when run app, should see install command run in app window. effect of device ready: nexus_5_api_23_x86 [emulator-5554] target device: nexus_5_api_23_x86 [emulator-5554] installing apk: /home/username/documents/programming/java/sample/app/build/outputs/apk/app-debug.apk uploading...

how to upload .flv to remote red5 server LIVE in real time? -

i want live webcast of ceremonies. can record .flv files using webcam , ffmpeg software. now, if hire red5 media server hosting company visitors can download website. problem how can upload .flv files live ( when video shooting still in progress ) please how achieve this i assume recording them mean saving them disk , not streaming video? if case need use upload form or have ftp / scp access hosted server. pick 1 of apps installed , place flv files in applications "streams" directory. once files in-place you'll need way play them back, require player (plenty of free ones out there jwplayer). looking for.

python - How to keep track of status with multiprocessing and pool.map? -

i'm setting multiprocessing module first time, , basically, planning along lines of from multiprocessing import pool pool = pool(processes=102) results = pool.map(whateverfunction, myiterable) print 1 as understand it, 1 printed all processes have come , results complete. have status update on these. best way of implementing that? i'm kind of hesitant of making whateverfunction() print. if there's around 200 values, i'm going have 'process done' printed 200 times, not useful. i expect output like 10% of myiterable done 20% of myiterable done pool.map blocks until concurrent function calls have completed. pool.apply_async not block. moreover, use callback parameter report on progress. callback function, log_result , called once each time foo completes. passed value returned foo . from __future__ import division import multiprocessing mp import time def foo(x): time.sleep(0.1) return x def log_result(retval): results.a...

matrix - Android ImageView scale image and center -

i need scale image inside imageview, need use matrix doing so, so do; private void scaleimage(float scalefactor, float focusx,float focusy) { matrix displaymatrix= new matrix(); matrix.postscale(scalefactor, scalefactor); displaymatrix.set(matrix); imageview.setimagematrix(displaymatrix); } the problem no matter not able center image inside imageview, i need put image @ center (leaving white margins if image smaller view) i have been bangin head hours, please help. i have looked extensively @ https://stackoverflow.com/a/6172226/1815311, without success. all have find new x , y coordinates place image , translate matrix, image moves center of imageview. entire scaleimage method can this: private void scaleimage(float scalefactor, float focusx, float focusy) { matrix displaymatrix = new matrix(); matrix matrix = imageview.getimagematrix(); float x = (imageview.getwidth() - imageview.getdrawable().getintrinsicwidth() * scalefactor...

Print character using linux x86 assembly and at&t syntax -

i'm trying print character stdout using write in linux x86 assembly, using at&t syntax. code doesn’t work: .data .text .global main main: movl $4,%eax movl $1,%ebx movl $53,%ecx //'5' movl $4,%edx int $0x80 movl $1,%eax movl $0,%ebx int $0x80 what's problem?

git - Accidentally created new branch with existing name -

i'm starting use branches git, , created yesterday branch foo , pushed remote. today wanted work on home, after running pull typed without thinking git checkout -b foo . i know shouldn't have added -b option, because got message switched new branch 'foo' , none of code wrote yesterday shows in folders figure accidentally messed branch names. i tried renaming branch using git branch -m foo bar hoping deal local branch , deduplicate branch names, alas git checkout foo issued message error: pathspec 'foo' did not match file(s) known git. how can retrieve branch created yesterday? the problem ran created new branch did not track remote branch wanted. i think "right" way correct set branch track intended remote branch: git checkout foo git branch -u origin/foo after doing can move local branch current commit of remote branch git reset origin/foo you can add , commit local changes. pull , push usual. (an alternative reset...

javascript - D3JS : Create distinct arc paths -

Image
i'm trying draw arcs corresponding data. plnkr actually there 2 numbers in data. whenever i'm trying create 2 arcs, merging together. var pi = math.pi, arcradius = 55, arcthickness = 2; var gaugedata = [32, 57]; var svg = d3.select('.circles').append('svg'); var arcfunc = d3.svg.arc() .innerradius(55) .outerradius(57) .startangle(0) .endangle(function(d) { return d * (pi /180); }); svg.attr("width", "400").attr("height", "400") .selectall('path').data(gaugedata).enter().append('path') .attr('d', function(d) { return arcfunc(d); }) .attr('fill', '#555') .attr('cx', function(d, i) { return * 100 + 30; }) .attr('cy', function(){ return 50; }) .attr("transform", "translate(200,200)"); the arcs like: please help. in advance. i'm assuming gaugedata degree value total sweep of arc. so, ...

ios - Search for parse user to return multiple results -

i have uitableviewcontroller , in uisearchbar searches parse.com users. when search type "abc", want users string "abc" not closets match. .h @property (weak, nonatomic) iboutlet uisearchbar *searchbar; @property (nonatomic, strong) pfuser *founduser; @property (nonatomic, strong) pfrelation *friendsrelation; @property (nonatomic, strong) nsarray *allusers; @property (nonatomic, strong) pfuser *currentuser; .m - (void)viewdidload { [super viewdidload]; self.searchbar.delegate = self; } -(void)viewdidappear:(bool)animated{ [super viewdidappear:animated]; pfquery *query = [pfuser query]; [query orderbyascending:@"username"]; [query findobjectsinbackgroundwithblock:^(nsarray *objects, nserror *error){ if (error) { nslog(@"error: %@ %@", error, [error userinfo]); } else { self.allusers = objects; [self.tableview reloaddata]; } }]; self.curre...