Posts

Showing posts from August, 2015

curve fitting - how to use cftool non-interactively in matlab -

is there way use cftool non-interactively. example, given x, y , fitting function, calling cftool generate , returned fitted data without using opening toolbox gui. thanks you can use fit function comes curve fitting toolbox. find out more, type doc fit . or can use cftool interactively, use generate code file menu create function uses fit command repeat interactive work programmatically. use template example.

mysql - mysql_real_connect call from within daemon plugin -

i want write mysql daemon plugin monitors queries on other mysql servers , compares them queries running on daemon running. in spider engine setting, query initiated on head node run on shards. whenever query killed on head, want have daemon on shard nodes kill associated query there. the idea initiate pthread uses mysql_real_connect , mysql_real_query ... access "show processlist" on head node , compare them local thread list. if issue mysql_real_connect in thread of daemon, segmentation fault. think due threading issue in mysql_real_connect . i've used #define mysql_server 1 , follow approach taken in ha_federated::real_connect() . is possible run mysql_real_connect within daemon plugin? thanks hints. after meditating on handlersocker daemon plugin realised in order mysql_real_connect , friends work in daemon thread, mysql internal thread environment needs set , registered server. this involves calling following in daemon thread: my_thread_ini...

MySQL Many for Many table: getting number of results -

i have database of 3 tables: users photos likes , basic outline so: users: user_id name photos: photo_id title url user_id likes: user_id photo_id what want enable user many photos , have photos liked many users. obviously, want order these photos number of likes, can join , count() what need can't figure out return number of 'likes' each photo has. how this? my current sql is: select photos.photo_id, photos.title, photos.url, users.name photos left outer join users on users.user_id = photos.user_id left outer join likes on likes.photo_id = photos.photo_id group likes.photo_id order count(*) desc limit 20 just add count(*) select list: select photos.photo_id, photos.title, photos.url, users.name, count(*) photos left outer join users on users.user_id = photos.user_id left outer join likes on likes.photo_id = photos.photo_id group likes.photo_id order count(*) desc limit 20

C# Facebook SDK and automatic paging -

if make request has large number of objects (like if had 10000 friends or 10000 photos in album), c# facebook sdk automatically follow "paging:next" links me, or there need do? i looked through code , don't see mention of paging, have missed it. note i'm -not- talking batch requests; i'm speaking of simple api.get("/me/friends") facebook decides there many objects put in single response. unfortunately don't have account enough of test results... pagination user of sdk, no matter sdk facebook. don't think they've gotten creative in adding in, or maybe there's legal reasons have not.

c# - LINQ query to select range of values in a broken sequence -

given entity, 2 fields, int? , string : entityid name -------- ----- 1 name1 2 name2 3 name3 4 name4 (null) name5 6 name6 7 name7 using linq, how select first 4 entities, before null value? seems case takewhile : var query = entities.takewhile(x => x.entityid != null); (add tolist() or toarray() appropriate).

How to print a board in python? -

i trying program game called triple triad on python, have problem output of board, has every square, each number represents cardinal point,there 9 squares, 3 every line. | 1 | 1 | 9 | |2@3|1*6|7*2| | 4 | 1 | 2 | i thought doing list every line , start board numbers every cardinal point, example, "0" if north or that, when have replace numbers of card, know put every cardinal point, suggestions? thanks in advance here simple way format looking for: def format_row(row): return '|' + '|'.join('{0:^3s}'.format(x) x in row) + '|' def format_board(board): # single list 9 elements uncomment following line: # return '\n\n'.join(format_row(row) row in zip(*[iter(board)]*3)) # 3x3 list: return '\n\n'.join(format_row(row) row in board) example: >>> print format_board([['1', '1', '9'], ['2@3', '1*6', '7*2'], ['4', '1', ...

ruby on rails - How to use has_secure_password with field_with_errors -

i using has_secure_password verify user password , confirmation. problem have when there errors, fields not being wrapped field_with_errors div. know can add validates_presence_of :password, :on => :create validates_presence_of :password_confirmation, :on => :create but creates following error message: password digest can't blank. password can't blank. password confirmation can't blank i either make has_secure_password wrap fields errors field_with_errors div or remove "password digest can't blank." error altogether. thanks. the securepassword module has functionality quite simple , worth look. news in the master branch (rails 4) validates_presence_of :password, :on => :create solve problem, in meantime might want mimic has_secure_password method on user model yourself. class user < activerecord::base attr_reader :password attr_accessible :password # ... validates_confirmation_of :password validates_...

Parsing XML into multiple form fields using Jquery -

what want do: i) parse xml data select option field ii) when user makes selection using option box, many more form fields populated relevant xml data based on user selection. i have working adobe spry (what hear cry!!!) - currently, user selects option box contains data xml , example "american wigeon" when selected populates other form fields rest of xml, such "turdus migratorius" , on. if user changes mind , selects another, example "american robin", relevant xml bird populate form fields. i have found answers on here getting parsed data select option, cannot work out next bit of using multiple fields. my xml file looks (edited down 2 entries, approx 300 normally): <?xml version="1.0" encoding="utf-8" ?> <bird> <result> <name>american wigeon</name> <latin>anas americana</latin> <rare>1</rare> <id>68</id> <breed>0</breed> <winter>0</win...

android - get the size of data partition by coding -

i have test code using : $ adb -s emulator-5554 shell # df df /dev: 47084k total, 0k used, 47084k available (block size 4096) /sqlite_stmt_journals: 4096k total, 0k used, 4096k available (block size 4096) /system: 73600k total, 73600k used, 0k available (block size 4096) /data: 65536k total, 18464k used, 47072k available (block size 4096) /cache: 65536k total, 1156k used, 64380k available (block size 4096) you see data have total 65536k , on,my question how size coding?if need root right?can give me advice? try { runtime rt = runtime.getruntime(); process pcs = rt.exec("df /data"); bufferedreader br = new bufferedreader(new inputstreamreader(pcs .getinputstream())); string line = null; while ((line = br.readline()) != null) { log.e("line","line="+line); } br.close(); pcs.waitfor(); or file path = environment.getdatadirectory(); android.os.statfs stat = new android.os.statfs(path.getpath()); lo...

array flip - PHP array_flip() function -

i updated server on work. have got error : "warning: array_flip() expects parameter 1 array, null given in..." know how fix ? thanks lot contribution. most updated server magic quotes set on off this id because returning value false or not returning true or 1 debug code .you not suplling array_flip() have supply array example: $arr = array("a" => 3, "b" => 1, "c" => 2); $arr = array_flip($arr); print_r($arr);

javascript - How to disable google chrome blocking scripts over https? -

i have site , need upload script in head section like: <script src="http://api-maps.yandex.ru/2.0/?load=package.full&mode=debug&lang=ru-ru" type="text/javascript"></script> google chrome browser pops message "there content on site may offencive bla bla bla", i`ve tried set script through https protocol, same thing heppens. how avoid feature in chrome? locally mirror script own site , reference way. getting "offensive" warning based off of url of script. if need several versions of script write shell script synchronize of versions need on regular basis. your new script reference should this: <script src="js/yandex.api.package.full.debug.ru-ru.js" type="text/javascript"/>

sql server - SSRS webpage error status code 500 -

have deployed numerous report parts reference same view 1 of them failing run on server, think may due having parameters in place sorts of characters in them. error message get: does have suggestions on how around this. webpage error details user agent: mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0; .net clr 2.0.50727; .net clr 3.0.4506.2152; .net clr 3.5.30729; .net4.0c; .net4.0e) timestamp: wed, 6 jun 2012 08:34:05 utc message: sys.webforms.pagerequestmanagerservererrorexception: unknown error occurred while processing request on server. status code returned server was: 500 line: 5 char: 62099 code: 0 uri: http://mysqlserver/reports/scriptresource.axd?d=xwww1tmwtfzdbq9-6krioz3q0wkgg-xpb7ewt8huhjxnf8sz46fbnrio5guvnx1jc-qfapcz-oqvtrpjjwxfyypy46ebyjbsdv8_0qbsvijeeyddkzolftjt35qxegtesgskcpzrb-zjiu83pmybwojrroq1&t=ffffffffb868b5f4 this problem being caused sql server stopping report being run because request length exceeds amount. the solution fo...

php - wordpress custom - add class to the first blog -

here blog page template: <?php /** * template name: blog * * standard blog template, create static page blog , select template. * * "template name:" bit above allows selectable * dropdown menu on edit page screen. */ get_header(); ?> <div id="main_container"> <!-- ie7 float fix --><!--[if lt ie 7]><span class="iefix">.</span><![endif]--> <div class="main"> <div class="entries_full"> <div class="entry_full"> <div class="box_twothirds mt30 pr60"> <!-- blog posts begin --> <?php $exclude_cat = get_option('bb_exclude_cat'); $exclude_temp = str_replace(",", ",-", $exclude_cat); $exclude_cats = "-" . $exclude_temp; $blog_posts = get_option('bb_blog_posts'); if($blog_posts == null) {$blog_posts = '5';} $temp = $wp_query; $wp_query= null; $wp...

java - Need to add SOAP security token -

i need set custom soap header attribute on jax-ws generated webservice client. case webservice calls must go through proxy server requiring specific token (recieved web request header) present in soap request header. e.g.: 1 carserviceservice service = null; 2 service = new carserviceservice(new url(url), new qname(qname); 3 carserviceendpoint port = service.getcarserviceport(); it seems in line 3 wsdl retrieved , call fails due missing security token. 1 point direction on how done? a detailed example has been mentioned here: creating , deploying jax-ws web service on tomcat 6 this article shows how create , use security token .

apache - Unable to find httpd.conf -

i'm running tomcat , want change default webroot points location. there way find out what's running tomcat or default webroot set can't find httpd.conf believe it's set? cheers, alexei blue. **update:** it's been long time since looked @ question forgot it. in end turned out using apache httpd accept requests port 80. there had webroot , proxypass rules set in /etc/httpd/conf/virtual-hosts/default.conf file (these can set in /etc/httpd/conf/httpd.conf ). there had several tomcat instances running, hosted on different ports setup in apache-tomcat-x/conf/server.xml . when wrote question trying setup new tomcat instance run application in development , told need change webroot access application, incorrect. instead needed include proxypass rule when application name recognised in url, httpd send request correct tomcat instance processed. e.g. www.domain.com/myapplication in /etc/httpd/conf/virtual-hosts/default.conf proxypass /myapplication...

polygon - Point inside rotated 2D rectangle (not using translation, trig functions, or dot product) -

Image
i wondering if following algorithm check if point inside rectangle valid. i've developed using own intuition (no strong trig/math basis support it), i'd love hear more experience in matter. context: the rectangle defined 4 points. rotated. coordinates positive. by definition, point considered inside rectangle if intersects it. hypothesis: use distance between point , rectangle vertices (first diagram below). the maximum possible total distance when point in 1 vertex (second diagram). if point outside rectangle, distance greater (third diagram). diagram link: http://i45.tinypic.com/id6o35.png algorithm (java): static boolean pointinsiderectangle(point[] rect, point point) { double maxdistance = distance(rect[0], rect[1]); maxdistance += distance(rect[0], rect[2]); maxdistance += distance(rect[0], rect[3]); double distance = 0; (point rectpoint : rect) { distance += distance(rectpoint, point); if (distance ...

c# - Coverting INT to decimal following mm.ss format -

i may being stupid here, brain's gone blank. i've got slider bar (which uses int32 values) want use select position in music song (mm.ss) i want output value slider displaying in label above it, it's easier see slider set to. anyone have suggestions? i thought of trying convert int value in decimal dividing 60. i'm doing in c# way. what int value represent? if it's number of seconds through song, should use: timespan time = timespan.fromseconds(seconds); string text = time.tostring(@"mm\.ss"); using decimal bad idea - format number of seconds isn't same fractional number of minutes. example, 10.50 minutes as fractional number of minutes 10 minutes , 30 seconds, not 10 minutes , 50 seconds, want far can tell. timespan natural way of representing time duration in .net... why that's type supports formatting in minutes , seconds .

excel - Gdata package perl issue -

i attempting follow easy 2-minute video tutorial on importing excel spreadsheet r data frame: http://www.screenr.com/qin8 i followed each step, including downloading , installing strawberry perl (32-bit) on win 7 pc, pointing r working directory, , entering following command in r: spreadsheet <- read.xls("targetspreadsheet.xls") i receive error: error in findperl(verbose = verbose) : perl executable not found. use perl= argument specify correct path. error in file.exists(tfn) : invalid 'file' argument update: i reset machine , set path perl: perl <- "c:/strawberry/perl/bin/perl.exe" then entered command: df <- read.xls("spreadsheet.xls", perl = perl) the command line returned error: error in xls2sep(xls, sheet, verbose = verbose, ..., method = method, : intermediate file 'c:\users\aeid\appdata\local\temp\rtmpoxmywa\file18e45ed513c.csv' missing! in addition: warning message: running ...

Grab user input asynchronously and pass to an Event loop in python -

i building single player mud, text-based combat game. not networked. i don't understand how gather user commands , pass them event loop asynchronously. player needs able enter commands @ time game events firing. pausing process using raw_input won't work. think need select.select , use threads. in example below, have mockup function of userinputlistener() receive commands, , append them command que if there input. if have event loop such as: from threading import timer import time #main game loop, runs , outputs continuously def gameloop(tickrate): #asynchronously user input , add command que commandque.append(userinputlistener()) curcommand = commandque(0) commandque.pop(0) #evaluate input of current command regular expressions if re.match('move *', curcommand): moveplayer(curcommand) elif re.match('attack *', curcommand): attackmonster(curcommand) elif re.match('quit', curcommand): ...

How to get Amazon s3 PHP SDK working? -

i'm trying set s3 first time , trying run sample file comes php sdk creates bucket , attempts upload demo files it. error getting: the difference between request time , current time large. i read on question on because amazon determines valid request comparing times between server , client, 2 must within 15 min span of 1 another. now here problem. laptop's time 12:30am june 8, 2012 @ moment. on server created file called servertime.php , placed code in file: <?php print strftime('%c'); ?> and output is: fri jun 8 00:31:22 2012 it looks day correct don't know make of 00:31:22 . in case, how possible make sure time between client , server within 15 minute window of 1 another. if have user in china wishes upload file on site uses s3 cdn. time difference on day. how can make sure user's times within 15 minutes of server time? if user in u.s. time on machine misconfigured. basically how s3 bucket creation , upload work? place ec...

html - How to parse an RSS feed using JavaScript? -

i need parse rss feed (xml version 2.0) , display parsed details in html page. parsing feed with jquery 's jfeed (don't recommend one, see other options.) jquery.getfeed({ url : feed_url, success : function (feed) { console.log(feed.title); // more stuff here } }); with jquery 's built-in xml support $.get(feed_url, function (data) { $(data).find("entry").each(function () { // or "item" or whatever suits feed var el = $(this); console.log("------------------------"); console.log("title : " + el.find("title").text()); console.log("author : " + el.find("author").text()); console.log("description: " + el.find("description").text()); }); }); with jquery , google ajax feed api $.ajax({ url : document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1....

Hide jquery dialogs by id in rails -

i got index page list of objects(@contacts), , need ability edit every @contact entry in popup using ajax. list of objects: <% @contacts.each |contact| %> <div><%= contact.name %> | <%= link_to 'edit', edit_contact_path(contact), :id => "edit_contact_dialog_link_#{contact.id}" %></div> <% @contact = contact %><%= render :template => "contacts/edit" %> <% end %> here i'm adding unique id edit links. doing in edit.html.erb : <div id="edit_contact_dialog_<%= @contact.id %>"> <h1>editing contact</h1> <%= render 'form' %> </div> now on index page have list of contacts(with unique edit links edit_contact_dialog_link_id ), , edit forms(with unique div ids edit_contact_dialog_id ) i need hide edit_contact_dialog_id boxes , on every edit_contact_dialog_link_id click open corresponding dialog window, don't know how. my c...

php - Symfony2 : cannot load resource "." -

i'm having issue assets management in symfony2. keep getting following error : cannot load resource ".". i've been trying fix in config , routing files dev environment, thing did changing use_controller false in config_dev.yml file. i keep summoning resources in templates with {% stylesheets '@mybundle/resources/public/css/style.css' filter='cssrewrite' %} <link rel="stylesheet" href="{{ asset_url }}" type="text/css" /> {% endstylesheets %} and keep getting exception : cannot load resource ".". any tips on go wrong? (i've cleared cache several times) thanks in advance edit : i've tried removing : _assetic: resource: . type: assetic from routing_dev.yml file, , error disappears (with, of course, resources in page) reedit : after complete reinstallation, seems working again. property had changed unvoluntarily... case...

regex - Perl Modifiers /^ AND $ -

somebody please explain me in layman terms use of modifiers /^ , $ in below statement; elsif ($keyword =~ /^verse$/gi) i information ^ matches beginning of line , $ matches end of line, supposed mean? explain me if condition considered above statement. these characters "zero-width assertions". don't stand group of characters, positions in string. ^ means expect pattern @ beginning of line or record. $ means expect pattern @ end of line or record in standard matching mode (without trailing switch /m ), perl considers first record in string total searchable space. /m switch, perl considers records in string, each record delimited current value of $/ (also $rs use english qw($rs); ). so if you're searching through couple of records , know pattern occurs @ beginning or end, can use characters specify that. (absolute start of string \a , absolute end \z place before record separator ends entire string or \z place after every single char...

mysql - How to copy records to a table, but not if they are already there -

i have 3 tables use filing mechanism training documents, document table (a30), training manual table, stores titles , ids of different training manuals (a36trnman), , table store id's of documents associated different manuals (a31). in application, allow user copy training manual, along associated documents , make own. however, run problem because different training manuals may include same documents, , there duplicates of document in training manual(which may have modified, , want preserved). so, need duplicate training manual query checks see if document in manual being copied exists user, , if does, leave in place, , create new record in table a31 associates existing (old) document training manual has been added. my documents create table `a30` ( `docname` varchar(250) not null, `docfile` varchar(300) not null, `docfilepdf` varchar(300) not null, `ctgry` int(8) unsigned zerofill not null, `subctgry` int(8) unsigned zerofill not null, `id` int(8) unsigned ...

php - Allow users to add a webpage within a website -

i'm trying work out if there's way possibly implement feature website allow user/guest create new web page stored on server without needing go through ftp directly. i'm looking basic functionality @ moment, basic form allow submit name of webpage stored in root directory of server. know if possible? appreciated! for automatic html page generation through forms, you'll need learn scripting languages such php.

actionscript 3 - Flex - Calling a public method located outside of the main view -

new flex, i'm trying figure out way call public method declared on view "firstview" of application. how reference? main view <?xml version="1.0" encoding="utf-8"?> <s:viewnavigatorapplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" applicationdpi="160" firstview="views.loaderview" creationcomplete="init()"> <fx:declarations> <!-- place non-visual elements (e.g., services, value objects) here --> </fx:declarations> <fx:script> <![cdata[ private function init():void{ //how access method? loaderview.setloadermsg("my message"); } ]]> </fx:script> </s:viewnavigatorapplication> loader view <fx:declarations> <s:...

objective c - How to add viewcontrollers to my navigation controller? -

i developing application in using uinavigationcontroller in appdelegate . @ launch, initialise uiviewcontroller . self.navigationcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:viewcontroller]; [self.navigationcontroller setnavigationbarhidden:yes]; [window addsubview:self.navigationcontroller.view]; this. however, add other uiviewcontrollers uinavigationcontroller , know isn't practise re-initialise uinavigationcontroller each time use other uiviewcontrollers . please can tell me normal way of doing this? if know want stack of view controllers be, can set them directly. for example, let's want views on navigation controller start out overview > tableview > newitemview. want people create first entry start app. in navigation controller need following in -application:didfinishlaunchingwithoptions: . nsarray *stack = [nsarray arraywithobjects:overviewcontroller, tableviewcontroller, newitemviewcontroller, nil]; navcontroller...

c# - SQL Connection open but not read here -

connection object & ado.net part getting error while insert data,first of here php coding part.here i'm going convert php codings .net openconn(); //<user> slett <slettid> if((sizeof($messagearray)==3) && (strtolower($messagearray[1])=='slett')) { $user_id=$messagearray[2]; if ((int)$user_id > 0) { $username=$messagearray[0]; $querycheckmak = "select count(*) xyz id='$user_id'"; $querycheckmak = odbc_exec($conn, $querycheckmak) or die("query error"); $user_number = odbc_result($querycheckmak, 1); if($user_number=="0") { $message_out = "some error out "; } below coding try convert it.i convert.sizeof part & string lower case part.below here coding part used odbc connection in case sue sql server connection public partial class seensms : system.web.ui.usercontrol { public sqlconnection mycon; sqlconnection con = new sqlconnection(@"data...

python - Understanding the map function -

map(function, iterable, ...) apply function every item of iterable , return list of results. if additional iterable arguments passed, function must take many arguments , applied items iterables in parallel. if 1 iterable shorter assumed extended none items. if function none , identity function assumed; if there multiple arguments, map() returns list consisting of tuples containing corresponding items iterables (a kind of transpose operation). the iterable arguments may sequence or iterable object; result list. what role play in making cartesian product? content = map(tuple, array) what effect putting tuple anywhere in there have? noticed without map function output abc , it, it's a, b, c . i want understand function. reference definitions hard understand. fancy fluff. map isn't particularly pythonic. recommend using list comprehensions instead: map(f, iterable) is equivalent to: [f(x) x in iterable] map on own can't cartesian product...

variables - Update parameter based on random time vector matlab -

i have non ode function calculates based on previous time step of time vector , spatial variable vector. one of parameters in function constant. however, want make parameter variable, change based @ given time. here example code make clear. nstrains = 10; param = .3*rand(1,nstrains); strtime = rand(1,nstrains); strtime = round(strtime); strtime = sort(strtime); initialconds = .5 t=0:.1:10; %time vector x=1:.1:10; %spatial vector k = zeros(numel(x),numel(t)) k = zeros(numel(x)/2,1) = initialconds = 1:(numel(t)-1) j = 2:(numel(x)-1) k(j,i+1) = 5*2+c(j+1,i)+param*c(j,1)+param end end if param held constant, no problem. want have vector of random numbers param, enter random number param @ random times. random time determined strtime. so example, if strtime vector = [2 4 9 10], , param vector = [.21 .01 .25 .05] first, want initial param value @ time 0 = .2 (arbitrary). time vector matches strtime vector, in example 2, param value updated .21. .21 used @ each time s...

How to make fast performance & Optimization in Silverlight and Windows Phone 7 Game + Memory Menegment? -

i developing 1 game , love know tips best memory management , performance optimization in windows 7 phone + silverlight coding. my game getting leg during game play. game gets paused few seconds before responds. is related above or else? i having google admob + microsoft ad sdk working above issue due that? i have used gc.collect() in project not seem work properly. there missing? i searched , tried find official link or content can guide me throgh best memory , performance management not able find so? if has link or idea, please share along above questions. thanks in advance. i'd recommend starting understanding http://msdn.microsoft.com/en-us/library/ff967560(v=vs.92).aspx , doing profiling http://msdn.microsoft.com/en-us/library/hh202934(v=vs.92).aspx

java - mapping resultset to json -

i have resultset data follows : +-------+-------+-------+-------+ | code1 | code2 | code3 | code4 | +-------+-------+-------+-------+ | 1 | 11 | 111 | 1111 | | 2 | 21 | 211 | 2111 | | 2 | 22 | 221 | 2211 | | 2 | 21 | 212 | 2121 | +-------+-------+-------+-------+ i need above result set converted following 2 jsons. code1_code2 = { 1 : [11], 2 : [21, 22, 21] }; code2_code3 = { 11 : [111], 21 : [211, 212], 22 : [221] }; i have tried parsing result set , 1st column ordered 1st json. second column not ordered couldnot 2nd json. (note:- not getting 2nd column ordered) note the name in name/value pair of json should string (not number in question). json object http://www.json.org/object.gif sample code as mentioned in @josnidhin 's comment, can use map store these data no matter if result set ordered or not. her...

Python image resizing, installing PIL -

i want image resizing python. trying python image library. barking right tree? i tried install pil on mac source http://www.pythonware.com/products/pil/ , has not been updated since 09. there newer should into? installing gives me error: unable execute gcc-4.0: no such file or directory error: command 'gcc-4.0' failed exit status 1 i tried installing gcc think have 4.2.1 any help? yes pil right module. can try imagemagick http://www.imagemagick.org/script/index.php no pil 1.1.7 latest, nov 15th 2009 you can check http://passingcuriosity.com/2009/installing-pil-on-mac-os-x-leopard/

Create a virtual machine in windows azure programmatically with C# code or .net -

as know new feature called virtual machine has been added in windows azure portal. want create virtual machine in windows azure programmatically c# or . net. can 1 please in this... api shoud use or yet api .net need published azure people? please 1 guide me task. you'll want use azure's rest service management apis. example, apis creating , managing vms here: create virtual machine deployment . the overall api documented here. since you're in .net seems there service management apis in managed sdk , didn't see service management api references there.

php - GD lib text placement in y ordinate -

i placing text on image using gd. gd places text on baseline. using imagettfbbox height of box , able calculate bottom of text is. since gd uses baseline place text. how can figure out baseline is? text , placement , size dynamic. i using giddyup 52px font , placing in top left corner, no margins/padding, example. text height using imagettfbbox , 54px. place text @ 0,54px using imagettftext(). the text going 12px far down, because baseline of text box @ 54 px not bottom of text ends being @ 66px. thank time, todd

atomicity - .net System.MemberwiseClone and interlocked writes -

when performing memberwiseclone of array of value types: var arr = new double[100]; if these doubles being modified using interlocked write on other threads, memberwisecloned copy @ risk of having torn doubles in it? i'm not concerned having stale values, tearing , interaction between interlocked , memberwiseclone (which guess translates memory blit type operation?) yes. on 32bit operating systems guaranteed have risk of tearing. on 64bit implementation defined. wouldn't lightly risk because if test doesn't happen test on particular .net version , on particular hardware. you can't make sure. on 64bit can reliably prevent tearing implementing own version of clone (which not slower).

bash - Incremental number in shell script on each loop -

#!/bin/bash echo script: $0 echo "enter customer order ref (e.g. 100018)" read p_cust_order_ref echo "enter du id (e.g. 100018)" read p_du_id p_order_id=${p_cust_order_ref}${p_du_id} #loop through xml files in current directory f in *.xml #increment p_cust_order_ref here done inside loop how can increment p_cust_order_ref 1 every time loops so reads 10000028 uses on first loop 2nd 10000029 3rd 10000030 4th 10000031 ((p_cust_order_ref+=1)) or let p_cust_order_ref+=1

regex - Replace all occurrences except the first in Ruby. The regular expression spans multiple lines -

i trying down last 3200 tweets in groups of 200(in multiple pages) using restclient gem. in process, end adding following lines multiple times file: </statuses> <?xml version="1.0" encoding="utf-8"?> <statuses type="array"> to right(as xml parsing goes toss), after downloading file, want replace occurrences of above string except first. trying following: tweets_page = restclient.get("#{get_statuses_url}&page=#{page_number}") message = <<-msg </statuses> <?xml version="1.0" encoding="utf-8"?> <statuses type="array"> msg unless page_number == 1 tweets_page.gsub!(message,"") end what wrong in above? there better way same? i believe faster download whole bunch @ once , split body of response message , add first entry. this, can't try out consider idea. tweets_page = restclient.get("#{get_statuses_url}")...

How to convert array values to lowercase in PHP? -

how can convert values in array lowercase in php? something array_change_key_case ? use array_map() : $yourarray = array_map('strtolower', $yourarray);

jQuery Tooltip plugin disabled after javascript load function -

this code used apply " jquery tooltip plugin " ajax loaded elements. example opencart cms: /* ajax cart */ $('#cart > .heading a').live('click', function() { $('#cart').addclass('active'); $('#cart').load('index.php?route=module/cart #cart > *'); $('#cart').live('mouseleave', function() { $(this).removeclass('active'); }); }); but after using .load function (after pressing @ link #cart > .heading a ) tooltip link element in #cart class disabled, , see usual windows popup tooltip. after refreshing page works correctly, if press @ link (at least 1 time), tooltip plugin link disabled again. other links works fine (because dont use .load function, think) how can solve problem?

jquery templates - What is the difference between "JavaScript Micro-Templating" and mustache.js/handlebars.js? -

first, apologize such novice question again, , if has been answered elsewhere. there many template engine,i not know how choose!i study this , still @ loss. i want know advantages of mustache.js/handlebars.js? compared javascript micro-templating please give examples explain, thank much! for pretty well-rounded comparison see http://engineering.linkedin.com/frontend/client-side-templating-throwdown-mustache-handlebars-dustjs-and-more it includes lot of considerations , 'in-the-field' approach. moreover, it's linkedin can trust it's pretty thorough. edit: only real omission hogan twitter, because (and still is) new kid on block . http://twitter.github.com/hogan.js/ ) handlebars based on mustache. functionality in between mustache , handlebars. performance 5/5. i use hogan both on client-side , nodejs on server-side , it's great working once hang of it. hth

java - How to extract the ObjectMapper used by RestEasy's JacksonProvider to parse a .json file? -

in resteasy (with spring) app, have extended resteasyjacksonprovider (provided resteasy), customize configuration of objectmapper little bit below public class jacksonprovider extends resteasyjacksonprovider{ public jacksonprovider(){ super(); objectmapper mapper = locatemapper(object.class, mediatype.application_json_type); mapper.configure(serializationconfig.feature.write_dates_as_timestamps, false); mapper.getdeserializationconfig().addhandler(new deserializationproblemhandler() { @override public boolean handleunknownproperty(deserializationcontext ctxt, jsondeserializer<?> deserializer, object beanorclass, string propertyname) throws ioexception, jsonprocessingexception { logger.warn(string.format("could not deserialize property name '%s' on object of type '%s'", propertyname, beanorclass.getclass().getname())); return true; } ...

c# - DotNetOpenAuth and Hotmail Sign In -

how retrieve signin email id of hotmail using dotnetopenauth i have tried code sample gives name , not email id iauthorizationstate authorization = client1.processuserauthorization(null); if (authorization == null) { // kick off authorization request client1.requestuserauthorization(new[] { windowsliveclient.scopes.basic, "wl.emails" }, new uri("http://localhost/signin.aspx")); // scope isn't required log in } else { var request = webrequest.create("https://apis.live.net/v5.0/me?access_token=" + uri.escapedatastring(authorization.accesstoken)); using (var response = request.getresponse()) { using (var responsestream = response.getresponsestream()) { var graph = windowslivegraph.deserialize(responsestream); //this.namelabel.text = httputility.htmlencode(graph.name); } } } you need add item scope cl...

linux - perl while loop -

in code parse file (containing output ls -lrt ) log file's modification date. move log files new folder modification dates added filenames, , making tar of files. the problem getting in while loop. because it's reading data files while loop keeps on running 15 times. understand there issue in code can't figure out. inside while loop splitting ls -lrt records find log file modified date. $file output of ls command storing in text file /scripts/yagya.txt in order modification date. while loop executing 15 times since there 15 log files in folder match pattern. #!/usr/bin/perl use file::find; use strict; @field; $filenew; $date; $file = `ls -lrt /scripts/*log*`; $directory="/scripts/*.log"; $current = localtime; $current_time = $current; $current_time = s/\s+//g; $freetime = $current_time; $daytime = substr($current_time,0,8); $seconddir = "/$freetime/"; system ("mkdir $seconddir"); open (myfile,">/scripts/yagya.txt...

c - Can't round number to two decimal places using floorf -

i found formula here: podrucje[i][j] = floorf(podrucje[i][j] * 100 + 0.5)/100; where podrucje[][] float matrix. floorf returns correct value ( desired * 100 ) problem /100 . example if have 49.599998 , floorf returns 4960.000 , after dividing 100 result again 49.599998 . where problem? i know can round while printing i'm going use matrix in excel converted range can't influence on representation. most decimal numbers aren't representable floats. you need either store them integers, or rounding when converting humanly visible (i.e. printing number out). if want use number further calculations , need rounded first, use different representation.

winapi - How to use IsNetworkAlive function (Win32API) in Ruby? -

i need use function watir, returns 1, if manually cut off connection. require 'win32api' isnetworkalive = win32api.new('sensapi.dll','isnetworkalive', nil, 'i') boolean = isnetworkalive.call() not sure if parameters given though... 1st required dll , according bill gates' site , sensapi.dll. 2nd name of function want instantiate. isnetworkalive, is. 3rd type of function's parameter. none, hence nil. 4th type of return value. um, it's boolean, ruby have it. should either 0 or 1, use int, perhaps.

how to create a new file in selenium? -

how create new file in selenium ? and how can write data newly created file ? how selenium ide & selenium rc differs ? assuming last question , comments there , want text page , save in file. i might wrong, think can't in selenium ide , need full power of programming language in selenium rc (which has been officially deprecated year ago) or selenium webdriver. once you're using 1 or in language (currently c#, java, ruby, perl , php supported), can use language's standard tools to write file.

c++ - Determine the argument and result Type of a functor -

how can test whether functor callable object takes reference int , returns bool? template<typename functor> void foo(functor f) { static_assert('functor == bool (int&)', "error message"); int x = -1; if (f(x)) std::cout << x << std::endl; } bool bar(int& x) { x = 4711; return true; } struct other { bool operator()(int& x) { x = 815; return true; } }; looks me don't want check signature of functor, want restrict user can pass in, in first place: if have access std::function can this: void foo(const std::function<bool(int&)>& f)

javascript - node-mysql timing -

i have recursive query (note: example): var user = function(data) { this.minions = []; this.loadminions = function() { _user = this; database.query('select * users owner='+data.id,function(err,result,fields) { for(var m in result) { _user.minions[result[m].id] = new user(result[m]); _user.minions[result[m].id].loadminions(); } } console.log("loaded minions"); } } currentuser = new user(id); (var m in currentuser.minions) { console.log("minion found!"); } this don't work because timmings wrong, code don't wait query. i've tried this: var myquery = function(querystring){ var data; var done = false; database.query(querystring, function(err, result, fields) { data = result; done = true; }); while(done != true){}; return data; } var user = function(data) { this.minions = []; this.loadminions = function() { _user = thi...