Posts

Showing posts from September, 2013

c# - Function Running Sync When VS Says it should be running async -

why b run sync? vs says ."because call not awaited, execution of current method continues before call completed." ; a) task.factory.startnew(() => funcation(1, 1)); //runs async b) funcation(1, 1); // says runs async in vs, runs sync. c) var handleone = task.run(() => { funcation(1, 1); }); // runs async d) await task.factory.startnew(() => funcation(1, 1)); //awaits correctly e) await funcation(1, 1); //awaits correctly static private async task<int> funcation(int x, int y) { task.delay(1000).wait(); } the funcation using async keyword not await in it's body run synchronously. function not compile. a) task.factory.startnew(() => funcation(1, 1)); //runs async here create thread , on thread call function asynchrounsly because running on thread. b) funcation(1, 1); function marked async not await ed invoked. in case compiler not check whether function using await in it's body...

express - How to check & confirm if dropzone is actually sending file to server -

i using dropzonejs , using following code initialize dropzone: var mydropzone = new dropzone("div#myid", { url: "/file/post"}); on server side, using expressjs\nodejs & using following code: fs.readfile(req.files.displayimage.path, function (err, data) { // ... var newpath = __dirname + "/uploads/uploadedfilename"; fs.writefile(newpath, data, function (err) { res.redirect("back"); }); }); problem req.files coming undefined. i want know when upload file, there way through developertoolbar check payload & confirm whether file been sent or not?

ExpressJS Fetching value from nested JSON Object -

i using expressjs..when trying fetch value req.body, in console.log(req.body[ndx])(it prints { " c o..... single character) for (var ndx in req.body){ console.log(req.body[ndx]); } my req.body has below nested json object: how extract count? req.body["count"] outputs undefined {"count":1,"totalcount":38,"node":[{"categories":[],"foreignsource":null,"foreignid":null,"label":"172.20.96.20","assetrecord":{"description":null,"operatingsystem":null,"category":"unspecified","password":null,"id":2655,"username":null,"vmwaremanagedentitytype":null,"vmwaremanagementserver":null,"numpowersupplies":null,"hdd6":null,"hdd5":null,"hdd4":null,"hdd3":null,"hdd2":null,"hdd1":null,"storagectrl":null,"thresholdcateg...

android - Why doesn't the subtype of this custom MIME type specify the particular row (from Content URI) in the table? -

at end of the developer guide , have described vnd.android.cursor.dir type part of every custom mime type, multiple rows; , vnd.android.cursor.item single row. then there example of content provider contains train timetables. it's authority com.example.trains , has tables line1 , line2 , , line3 . , it's content uri content://com.example.trains/line2/5 which pointing " 5th row in line2 table ", mime type returned be: vnd.android.cursor.item/vnd.example.line2 which not indicate row is. questions: i think should be like: vnd.android.cursor.item/vnd.example.line2.5 because type part describe mime type particular row, subtype should describe row is. isn't it? if vnd.android.cursor.item/vnd.example.line2 correct, means not matter if mime type of particular row. does mean rows in table have same mime type? because mime type type of files on internet. ( reference ) think since rows have same "types" of data (or in other words r...

php - How to add an image in a section of a one-page website -

Image
this question has answer here: php parse/syntax errors; , how solve them? 11 answers i'm building one-page theme on wordpress. i have text on left hand side , insert picture on right when tried add picture in through code error message: parse error: syntax error, unexpected 'template_directory' (t_string), expecting ',' or ';' in /var/www/wordpress/wp-content/themes/cvtheme2015/front-page.php on line 21 is there forums or video tutorials me ? <div class="indent"> <section id="meet"> <?php $query = new wp_query('pagename=about-us-single'); //the loop if ($query ->have_posts()){ while ($query->have_posts() ) { $query->the_post(); echo '<h1 class="section-title"...

c++ - Why do the const accessors of std::string return a reference? -

the std::string accessors ( back , front , at , , operator[] ) have const , non- const overloads, below: char& x(); const char& x() const; why second version return const reference , opposed returning char by value (as copy)? according rules of thumb on how pass objects around , shouldn't small objects passed value when there's no need modify original? because caller might want reference char, reflects changes made through non-const avenues. std::string str = "hello"; char const& front_ref = static_cast<std::string const&>(str).front(); str[0] = 'x'; std::cout << front_ref; // prints x

Xml Configuration File Reader in Java -

i wanted read xml configuration file in java , found library - commons-configuration . task me. wondering why implementations tries use either jaxb or stax parse xml , reinvent wheel above library task easily. i wanted know pros of using jaxb or stax against library read xml configuration file.

jquery - How can I use this JavaScript to have one select option be dependent on the previous select option? -

here problem. trying have second select option dependent on previous select option. first select option determines color of shoe. second select option, size, based on color of shoe. how can make dynamic enough change available sizes based on color? here code: <script type="text/javascript"> $(document).ready(function() { $("#color").change(function() { var element = $(this); if(element.val() === "brn") { $("#size").append('<option value="5">5</option>'); $("#size").append('<option value="6">6</option>'); $("#size").append('<option value="7">7</option>'); $("#size").append('<option value="8">8</option>'); $("#size").append('<option value="9...

docker - ubuntu 14.04 SuperDesk Raven not configured (logging is disabled) -

i installed clean ubuntu 14.04 x64 server machine on vmware esxi5.5 inside followed installation procedure sourcefabric's superdesk software described in https://github.com/superdesk/superdesk/blob/master/readme.md after running 'local demo' , 'create user' script @ end of readme.md file, following output: warning:elasticsearch:put /superdesk [status:400 request:0.064s] raven not configured (logging disabled). please see documentation more information. info:raven.base.client:raven not configured (logging disabled). please see documentation more information. command finished with: {'password': '$the_password_hash.', 'is_active': true, 'user_type': 'administrator', 'needs_activation': false, 'session_preferences': {}, '_etag': 'acc4fd0363d32c1e3c283662ea6c0a8411044773', 'email': 'admin@example.com', '_updated': datetime.datetime(2015, 6, 13, 15, 30...

html - Fixed navigation bar overlap issue -

i have 2 navigation bars: 1 shows on 1 set of pages , shows on different set of pages (using if... else statement in application.html.erb.) 1 of 2 navigation bars has fixed position @ top , result overlaps following text. solve adding body {margin-top: 25px;} stylesheet. however, problem pages have different navigation bar, has not fixed position resulting in 25px high white bar top of pages. how include margin-top body pages specific navigation bar used? what adding margin-bottom specific navbar? edit: can wrap content in div , , add dynamically class (same condition have in navbar). <div class="<%= condition ? first_class : second_class %>"> and add appropriate margins clsass.

Delphi Indy HTTP.GET high cpu usage -

on first download there high cpu usage, later ok. problem exists since delphi xe7 , in xe8. in earlier versions think there low cpu usage. tested latest ssl files https://indy.fulgan.com/ thanks help. procedure tform1.button1click(sender: tobject); var idhttp: tidhttp; idssl: tidssliohandlersocketopenssl; dane: tmemorystream; begin idhttp := tidhttp.create; idopensslsetlibpath(extractfilepath(paramstr(0))); idssl := tidssliohandlersocketopenssl.create(); idhttp.request.accept := 'application/vnd.twitchtv.v3+json'; idhttp.iohandler := idssl; idhttp.request.customheaders.addvalue('client-id', 'smb61nyd0vxmqdn9d3k735qbx41cdyg'); dane := tmemorystream.create; try idhttp.get('https://api.twitch.tv/kraken/streams?game=starcraft:%20brood%20war', dane); dane.free; end; end;

emulation - How to setup an Android Virtual Device with a data partition larger than 200 MB? -

Image
whatever do, can't setup virtual android device /data partition larger 200 mb. what's proper/definitive way setup or grow /data partition? i assuming there bug somewhere in 1 of tool, looking workaround. using avd tool creates new avd doesn't seems setup value entered in 'internal storage' field although 'disk.datapartition.size' parameter appropriate value: $ grep "size" *.ini config.ini:disk.datapartition.size=1024m config.ini:sdcard.size=512m hardware-qemu.ini:disk.cachepartition.size = 66m hardware-qemu.ini:disk.systempartition.size = 550m hardware-qemu.ini:disk.datapartition.size = 1g just listing files ... $ ls -alsh total 979m 0 drwxr-xr-x 12 user staff 408 jui 13 11:35 . 0 drwxr-xr-x 7 user staff 238 jui 13 11:38 .. 66m -rw------- 1 user staff 66m jui 13 11:38 cache.img 4,0k -rw-r--r-- 1 user staff 668 jui 13 11:34 config.ini 4,0k -rw-r--r-- 1 user staff 1,8k jui 13 11:35 hardware-qemu.ini 512m -rw-r--r-- 1 use...

ios - Get attibuteDict of a subclass Xml parsing - Swift -

i want attribute of subclass of item : <pdv id="1000002" latitude="4621842" longitude="522767" cp="01000" pop="r"> <adresse>16 avenue de marboz</adresse> <ville>bourg-en-bresse</ville> <ouverture debut="01:00" fin="01:00" saufjour=""/> <services> <service>automate cb</service> <service>vente de gaz domestique</service> </services> <prix nom="gazole" id="1" maj="2015-05-30 11:30:17" valeur="1206"/> <prix nom="sp95" id="2" maj="2015-05-30 11:30:17" valeur="1398"/> <prix nom="sp98" id="6" maj="2015-05-30 11:30:17" valeur="1434"/> <rupture id="3" nom="e85" debut="2009-11-03 12:19:00" fin=""/> <fermeture/></pdv> i know how <pdv id=...

mongoose - Receiving "TypeError: Object #<EventEmitter> has no methods 'updateMyField'" in a post-save hook -

this relevant part of code think i'm getting error in - says "if (this.ended && !this.hasrejectlisteners()) throw reason; typeerror: object # has no methods 'updatemyfield'" fieldschema .post('save', function () { var self = this; self.updatemyfield(); }); fieldschema.methods = { updatemyfield: function() { var deferred = q.defer(); // things here return deferred.promise; } }; i'm pretty confused why claims there's no method - love kind of give! the issue post hooks require use doc access object, explained , answered in why "this" keyword different in mongoose pre-save hook versus post-save hook? .

c# - Retrieve Specific Data from Session List -

i stored list in session. able username list accessing userinfo[1] . after stored in session, unable session["userinfo"][1] . it gave me error "cannot apply indexing [] expression of type object. any idea/hints me this? list<string> userinfo = new list<string>(); userinfo.add(userid); userinfo.add(username); userinfo.add(role); session[userinfo"] = userinfo; you need cast list first because default session return type object, this: var theuserinfo = session["userinfo"] list<string>; // checking if indeed list of string if(theuserinfo != null) { // here list.. } or can implicitly cast this: userinfo = (list<string>) session["userinfo"] as additional notes, if explicitly cast object, there's chance can invalid cast exception . so, recommend use "classic" approach use as syntax, because return null rather throw exception.

d3.js - D3: update data with multiple elements in a group -

i have combined bar / line chart. each row in input file, create group contains multiple elements (lines, rectangles, texts): var mygroups = svg.selectall('g').data(mydata) mygroups.enter().append('g') ... mygroups.append('line') ... mygroups.append('polygon') ... mygroups.append('text') ... i just svg.selectall('*').remove() and create scratch every time data updated. however, i'd have smooth transition elements. i've gone through this tutorial several times, still don't understand how can in case. the key handle selections, not enter selection: var mygroups = svg.selectall('g').data(mydata); // enter selection var mygroupsenter = mygroups.enter().append("g"); mygroupsenter.append("line"); mygroupsenter.append("polygon"); // ... // update selection -- contain newly appended elements mygroups.select("line").attr(...); // ... // exit selection mygroups...

javascript - How to make multiple counters using HTML data -

i trying create similar this: http://pennystocks.la/internet-in-real-time/ here there at: https://jsfiddle.net/t44qsb9d/ jquery('document').ready(function() { var count = 0; var counter = document.queryselector('#foo'); var countnum = parseint(counter.dataset.counter,10); setinterval(function() { count += countnum; jquery('#foo').html(count); }, 1000); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <div style="background-color:#359bed;color:#ffffff;font-size:30px;padding:40px;"><div style="padding-left:300px;"><div id="foo" data-counter="11">0</div><span style="color:#ffffff;line-height:40px;">accounts created</span> </div> </div> i need update script update multiple counters work on single counter. appreciated. thanks, lewis...

SSAS: creating a relation between my dimension table and existing time dimension -

i have dimension table has 2 date fields. need create relation time dimension both of these fields in order filter data year/quarter/date (hierarchy defined in time dimension). i'm new @ , bit lost, can please me? link both columns of dimension table existing time dimension table in dsv. create measure group dimension table. existing time dimension act role playing dimension in ssas cube. can pick 2 dates 2 time dimensions filter data. you can avoid role playing dimension doing changes in design.

python - scipy fftconvolve claims input parameters don't have same dimensionality. What am I parsing? -

i'm trying create class uses fftconvolve scipy.signal convolve data gaussian inside method of class instance. every time create instance , call method enlarge_smooth (which happens upon right arrow key press), error fftconvolve stating: valueerror: in1 , in2 should have same dimensionality . happens in function def fftconvolve(in1, in2, mode="full"): when line elif not in1.ndim == in2.ndim: evaluates true . line print vals.ndim == gs.ndim prints true before call fftconvolve , , both vals , gs have dimensions (101,) . if not parsing vals , gs fftconvolve parsing? , why doesn't work? class smoother(object): import sys sys.path.append("/data/pythonfunktioner") scipy.signal import fftconvolve import pyximport; pyximport.install() fitting6 import gs_smooth1 """ class allows user smooth function of 1 variable gaussian using fftconvolve while looking @ smoothed function. smoothing parameter changed arrow...

jquery - Initiate css animation once background image of div is loaded. -

i want make sure background image of text animation take place loaded before starts. doesn't have check if background images or images on page loaded, specific one, animation doesn't take place on body's background. image loaded data attribute via parallax script. i have tried add image inside load function, doesn't seem load @ all. all of inside document ready. html: <div id="mydiv" class="parallax-window" data-parallax="scroll" data-image-src="http://s27.postimg.org/ya4yhbmzn/image_example1.jpg"> <h1>first title</h1> <h2>second title</h2> </div> css: #mydiv{ width: 100%; padding: 80px 0; text-align: center; } h1, h2{ opacity: 0; } javascript not working: $(window).load(function(){ $('#mydiv').attr('data-image-src', 'http://s27.postimg.org/ya4yhbmzn/image_example1.jpg').load(function() { $('h1').css(...

How to plot event frequency using datetime array in matlab -

i have array of values in datetime format. each value represent event happening @ specified date , time. how can plot event frequency in events per day, events per month, etc? i managed plot events per hour of day using histogram(mydata.hour) thank answers! edit: precisions after first answer below: yes, that's i'm doing using histogram , data.hour. however, want compute the average number of event per day , , plotting along time period events are. here working example: % generating 500 random events dates = datetime(now-1000*rand(500,1),'convertfrom','datenum'); figure; edges = -0.5:23.5; histogram(dates.hour,edges) title('events per hours of day') xlim ([-0.5 23.5]) ax1 = gca; ax1.xtick = 0:2:23; ax1.xticklabel = {'midnight','2','4','6','8','10','noon','14','16','18','20','22'}; ax1.xticklabelrotation = 45; figure; daynumber = weekday(dates...

RethinkDB Map/Reduce examples -

i running through map/reduce examples in rethinkdb docs. have documents this: { "category": "fiction" , "content": "this far, no further!" , "id": "0fc5339b-8139-4996-8979-88a0051195e3" , "title": "the line must drawn here" } when follow examples using data explorer. e.g. r.table('posts').map(lambda post: 1) i error: syntaxerror: missing ) after argument list this because data explorer allows javascript input. need switch make work: r.table('posts').map(function(post){return 1})

android - Posting savescreen to FB -

i need solve problem: want post on fb save screen app (i got save screen using display.save function). works fine on android while on ipad crashes! please find function code below: local function postonfb( event) display.save( tab3fields, { filename="ticket.jpg", basedir=system.documentsdirectory, isfullresolution=true, backgroundcolor={0, 0, 0, 0} } ) local fbappid = "4531113981xxxxx" local function fblistener( event ) if event.phase == "login" local attachment = { message="i champion!", source= {basedir=system.documentsdirectory, filename="ticket.jpg", type="image"} } facebook.request("me/photos", "post", attachment) native.showalert("facebook", "submitted!") end end -- photo uploading requires "publish_actions" permission facebook.login( fbappid...

python - compiling libtorrent Rasterbar for mavericks -

i compiled , installed boost source using $pwd /downloads/boost_1_58_0 ./b2 threading=multi link=static runtime-link=static cxxflags="-stdlib=libstdc++" linkflags="-stdlib=libstdc++" and got message after build completed, the boost c++ libraries built! the following directory should added compiler include paths: /downloads/boost_1_58_0 the following directory should added linker library paths: /downloads/boost_1_58_0/stage/lib now trying install lib torrent's python pending using sudo pip install . i got error message b2: command not found since knew b2 command in location build boost, updated setup.py specific path, but still when try sudo pip install . python binding of lib torrent below message. complete output command python setup.py egg_info: unable load boost.build: not find "boost-build.jam" --------------------------------------------------------------- boost_root must set, either in environment, or ...

angularjs - How can i put html inside javascript varaible -

currently have dirty way of coding function returns html. is there better way can it. i having hard time in inserting variables inside , looks dirty function gettemplate (model, id) { model = "test"; id = 5; return '<div>' + '<button class="btn btn-xs btn-info" title="view"' + 'ng-click="opentab(panes[1], "' + model + '", "' + id + '")">' + '<span class="glyphicon glyphicon-cog"></span>' + '</button>' + '<button class="btn btn-xs btn-info" title="edit"' + 'ng-click="editmodal(model, id)">' + '<em class="fa fa-pencil"></em>' + '</button>' + '<button class="btn btn-xs btn-danger" title="delete"...

ios - How to fix table view's search bar overlapping with status bar -

Image
i have uitableviewcontroller inside navigation controller, search bar. how add search bar in viewdidload: let resultscontroller = searchtableviewcontroller() resultscontroller.people = people searchcontroller = uisearchcontroller(searchresultscontroller: resultscontroller) let searchbar = searchcontroller.searchbar searchbar.placeholder = "search person" searchbar.sizetofit() tableview.tableheaderview = searchbar searchcontroller.searchresultsupdater = resultscontroller this result: i tried editing table view in storyboard add constraint make further top view's margins, can't add contraints, because table view inside uitableviewcontroller. i think need code. in viewdidload method add code: self.tableview.contentinset = uiedgeinsetsmake(20, 0, 0, 0) and tableview this: edit: you can forcely scroll table code: tableview.scrolltorowatindexpath( nsindexpath(index: 0), atscrollposition: uitableviewscrollposition.top, animated: false) ...

java - JavaFX. Where to put service class reference? Controller or Main app starter class? -

i work javafx application , use fxml implement mvc pattern. make proof of concept, , start create javafx user interface. in previous experience spring mvc, there usual create service , inject them in controller class via annotations. javafx cannot find recommendations how that. not sure have put services controller, or call main class method controller. second solution holds service reference in main application class. please note application runs service classes in concurrent threads. of them implements runnable interface i avoid having controllers needing refer main application class introduces dependency not necessary. have each controller keep reference service object. to provide service controllers, can use 1 of techniques outlined in this question . there 3 ways this: creating controller , setting in fxmlloader directly in version, do not use fx:controller attribute in root element of fxml file (doing cause exception thrown). given public interface...

java - Collatz and other sequences: how to get more precision easily and avoid segfault? -

here's simple c program created old java code (my first c program, nice ;) ). runs faster corresponding java code, java allows me more precise (i'm using longs in java, too) before crashes. to surprise, java code doesn't crash until input exceeds 170,000,000. c code can't handle on 1,050,000. suggestions on making c code run better without needing crazy libraries? thanks! #include <stdio.h> #include <string.h> /* lets me use memset */ #include <stdlib.h> /* home of strtoull */ /* segfault 11 after 1047993 (not anymore!!) */ unsigned long long getnext( unsigned long long x ); unsigned long long getnext( unsigned long long x ) { if (x == 1) { return 1; } if (x % 2 == 0) { return x/2; } return (3 * x + 1); } int main(int argc, char *argv[]) { int argind; ( argind = 0; argind < argc; argind++ ) { unsigned long long intrange; intrange = strtoull(argv[argind], null, 10); /** improper allocation ...

ios - Swift - Run Code Stored Online -

i know long shot wanted know if there relatively easy way run swift code stored on server or hosted somewhere other application bundle. able change single lines of code without having publish update app. if or has work around great. thanks no it's both not possible (there no compiler on ios device) , not allowed (downloading code expressly forbidden apple's app store guidelines.) so both cannot , may not this.

javascript - Bootstrap - how to make vertical sidebar with fixed width/not scrollable but still responsive? -

i new bootstrap , trying figure out how could: have vertical sidebar fixed width, doesnt scroll content still responsive(if screen width small, become top bar hamburger menu used to) have main content div take 100% of remaining width(minus sidebar fixed width) here have far(codes found somewhere accomplish want, sidebar scroll content , content div doesnt take 100% remamining width): imports: <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <link rel="stylesheet" type="text/css" href="scripts/css/bootstrap.css" /> <script type="text/javascript" src="scripts/js/bootstrap.min.js"></script> js <script type="text/javascript"> $(document).ready(function () { $('[data-toggle=offcanvas]').click(function () { $('.row-offcanvas').toggleclass('active'); }); }...

class - how to access values of nested dictionary keys in python? -

i have nested dictionaries, , want update values of second dictionaries' keys' value such should reflect dictionary value also. class screen_seat: def __init__(self,screen,show,num_seats,day): self.screen_id = screen self.show = show self.num_seats = num_seats self.seats = {('screen1','day4'):{'show1':100,'show2':100,'show3':100,'show4':100}, ('screen1','day5'):{'show1':100,'show2':100,'show3':100,'show4':100}, ('screen1','day6'):{'show1':100,'show2':100,'show3':100,'show4':100}, ('screen1','day7'):{'show1':100,'show2':100,'show3':100,'show4':100},} i update value of below keys self.seats['screen1','day4','show4'] =90 so that: self.seats = {('screen1','day4...

sql server - Intermittent database connection issue but only with certain sites -

i have freaky issue i'm struggling find solution to. i have windows 2012 web server , separate windows 2012 server running sql server 2012. installed. the servers have 2 network cards - 1 public other direct connection between two. i have number of database driven websites on web server. connecting same database , in many case using identical connection string. my code asp , in cases using connection string: mydbconn_string = "provider=sqloledb; network library=dbmssocn; data source=169.254.210.158; initial catalog=mydatabase; user id=database_user; password=mypassword" this works fine. indeed had been running , working fine few days. when start seeing these errors in logs: [dbnetlib][connectionopen (connect()).]specified sql server not found.. . re-starting server fixes problem involves downtime , hardly viable solution. what odd although websites using same connection string - 1 website suffered issue - others continued connect fine. ...

css - Bootstrap form-group for Radio Buttons -

can please shed light on how format radio buttons in bootstraps form-group? it gets problem if there many radios control , wrap around next line. bootstrap control box not expend fit everything. attached sample below had been simplified illustration purposes. <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" /> <div class="form-group has-feedback"> <label class="control-label" for="mradio">radio test</label> <div id="mradio" class="form-control"> <label class="radio-inline"> <input type="radio" name="optradio">option 1</label> <label class="radio-inline"> <input type="radio" name="optradio">option 2</label> <label class="radio-inline"> <input type="radio" name=...

mysql - Update column value based on PHP variable which is equal to a column name -

$rating = mysqli_real_escape_string($conn,$_post['rating']); $id = mysqli_real_escape_string($conn,$_post['id']); mysqli_query($conn,"update table set $rating=$rating+1 id='$id'"); is there way update column based on php variable $rating ? $rating column name. also, may prone security risks etc, i'd know if way go it. yes can use variable name field name in sql. must validate first before putting sql string. since not field value, cannot "quote" it. $rating = $_post['rating']; // define list of valid "rating" db field names here $valid_fields = array('rating_a', 'rating_b', 'rating_c'); if (in_array($rating, $valid_fields)) { $id = mysqli_real_escape_string($conn,$_post['id']); mysqli_query($conn,"update table set $rating=$rating+1 id='$id'"); }