Posts

Showing posts from March, 2015

jenkins - Dashing (Ruby) Nokogiri LoadError -

i've been working on dashboard on dashing framework, , i'm trying make little crawler collect specific data on jenkins-ci, , pass number widget. here's crawler (it's stub, counts number of "p" elements on stub html page): require 'nokogiri' require 'open-uri' class activebuilds def initialize() @jenkins_page = nil @build_count = nil end # !stub! gets jenkins page parse xml on nokogiri @jenkins_page = nokogiri::html(open("http://localhost:80")) # !stub! counts number of 'p' items found on page @build_count = @jenkins_page.css("p").length # !stub! returns amount of active builds def amountofactivebuilds return @build_count end end and reference, not necessary, html page: <!doctype html> <html> <head> <meta charset="utf-8"> <title>number stub | project</title>

python - how to deactivate virtualenv from a bash script -

i'm novice in shell scripting, want make bash script activate/deactivate virtual enviroment using virtualenv. want use script service in ubuntu copying inside /etc/init.d folder. in script, have variable this: venv=/opt/odoo/odoo_server/venv_oddo/bin this variable represents bin path in virtual enviroment. inside script, can activate virtual enviroment statement: . ${venv}/activate this possible because activate file inside bin directory in virtual enviroment. but don't know statement use in script deactivate virtual enviroment. can't this: . ${venv}/deactivate the problem doesn't exist file named deactivate, deactivated function inside bin/activate file in virtual enviroment. it'll hard make service useful. . ${venv}/activate # note dot or source ${venv}/activate will source activate script, i.e. run contents as if part of shell or script source them . virtualenvironment 's activate is designed usage . in contrast, executing

javascript - Can't figure out js for customizing google map. -

i'm fresh of boat when comes js. map appears in place, styling doesn't work. it keeps telling me have code , not enough information i'm writing go away. function initialize() { var mapcanvas = document.getelementbyid('map-canvas'); var mapoptions = { center: new google.maps.latlng(34.695301,-82.401196), zoom: 15, maptypeid: google.maps.maptypeid.roadmap } var map = new google.maps.map(mapcanvas, mapoptions) } google.maps.event.adddomlistener(window, 'load', initialize); [ { "featuretype": "landscape.natural", "stylers": [ { "color": "#2e2d2d" } ] },{ "elementtype": "labels.text.stroke", "stylers": [ { "visibility": "off" } ] },{ "elementtype": "labels.text.fill", "stylers": [ {

vagrant - Unusable using conditionals -

i have var defined when running vagrant: is_vagrant: yes when run other playbook it's not defined var not included. when in ansible: when: is_vagrant defined it works charm when it's defined or not defined. but when use this: when: gitclone.changed or is_vagrant defined it skips task when is_vagrant var included. i'm not sure why? i've given trusting ansible right thing when comes variable expansions. when ansible tries misguide me messages " you don't need use {{}} or "" ", still do. did try: when: "{{ gitclone.changed or is_vagrant defined }}" -- edit -- when: "{{ is_vagrant defined or ( gitclone defined , gitclone.changed ) }}" why have check defined. .changed true or false assume? if want task 'fail' when variable not defined, don't have check if it's defined. if don't want undefinederror: 'git_output' error have check. changed inside git_output

udp - WPA shows NIC driver DPC fragment running for 232 milliseconds -

Image
i'm stress testing udp proxy on machine 8 logical cpus. @ around 14 thousand udp clients, 1 of cpus (cpu 4) starts spiking , udp throughput (as shown task manager) plummets zero. used wpr record cpu usage during spike , wpa shows cpu 4 handling twice many dpc/isr fragments (~11k) other cpus (~5k each). longest dpc fragment ran 232 milliseconds, next 5 dpc fragments ran on 100 milliseconds, , next 57 ran between 1 , 90 milliseconds. a fragment defined "a period of time during dpc or isr ran uninterrupted." (see https://msdn.microsoft.com/en-us/library/windows/hardware/jj679884.aspx ) microsoft recommends dpc fragments run no longer 100 microseconds! (see https://msdn.microsoft.com/en-us/library/windows/hardware/ff546551(v=vs.85).aspx ) bxvbda.sys module (broadcom netxtreme ii gige vbd) , um_bdrv_dpc function of these long running dpc fragments. so question is: interpreting wpa data dpcs correctly? i've been analyzing etl traces sometime , yes ap

Add multiple columns using for loop in R and name with row entry -

i have searched , can't find answer this, though seems pretty basic r question. i trying add multiple columns dataframe using loop. each column named row entry corresponds to. here example: > test <- data.frame(cbind(x=1, y=1:10)) > test x y 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 i tried this: y <- test$y (i in y) { test$i <- rep(c(test$y [i]), times=length(test$y)) } which gave me this: > test x y 1 1 10 1 2 10 1 3 10 1 4 10 1 5 10 1 6 10 1 7 10 1 8 10 1 9 10 1 10 10 however, wanted this: > test x y 1 2 3 4 5 6 7 8 9 10 1 1 1 2 3 4 5 6 7 8 9 10 1 2 1 2 3 4 5 6 7 8 9 10 1 3 1 2 3 4 5 6 7 8 9 10 1 4 1 2 3 4 5 6 7 8 9 10 1 5 1 2 3 4 5 6 7 8 9 10 1 6 1 2 3 4 5 6 7 8 9 10 1 7 1 2 3 4 5 6 7 8 9

php - Combine external XML files into one and orderby -

i have following php function combine multiple external xml files 1 file: <?php function combinexml($file) { global $xmlstr; $xml = simplexml_load_file($file); foreach($xml $element) $xmlstr .= $element->asxml(); } $files[] = "file1.xml"; $files[] = "file2.xml"; $xmlstr = '<productitems>'; foreach ($files $file) combinexml($file); $xmlstr .= '</productitems>'; $xml = simplexml_load_string($xmlstr); $bytes = file_put_contents("output.xml", $xml->asxml()); ?> is possible re-order feed? having last modified on top? order lastmodified file system date. you did not provide xml examples let's assume simple structures: $xmls = [ '<productitems> <item> <title>item 1</title> <lastmodified>1</lastmodified> </item> </productitems>'

cocoa - Invert button image in selected table view row -

Image
what i'd have when row in view-based table view selected, images (or button images) inverted, in safari: i have button nsstopprogressfreestandingtemplate image ( ), nothing happens when row selected. text correctly becomes white. what style of nsbutton using? tried adding 1 view-based nstableview project, set style of 'inline' nsstopprogressfreestandingtemplate image , correctly turns white text when select table row.

How to convert string to hex value in C -

i have string "6a" how can convert hex value 6a? please me solution in c i tried char c[2]="6a" char *p; int x = atoi(c);//atoi deprecated int y = strtod(c,&p);//returns first digit,rest considers string , //returns 0 if first character non digit char. the question "how can convert string hex value?" is asked, it's not quite right question. better "how can convert hex string integer value?" the reason is, integer (or char or long) value stored in binary fashion in computer. "6a" = 01101010 it in human representation (in character string) value expressed in 1 notation or another "01101010b" binary "0x6a" hexadecimal "106" decimal "'j'" character all represent same value in different ways. but in answer question, how convert hex string int char hex[] = "6a"; // here hex string

python - How do I retrieve a list within dictionary within a list? -

how retrieve list value, within dictionary, that's within list? x = [{'name': 'joe', 'items': ['hat','scarf','boots']}, {'name': 'john', 'items': ['jeans','shirt','jacket']}] x considered list type variable, , i'm trying pull values within list called 'items'. calling x[0] load first list item includes name , items joe, not sure how pull items. x[0][0] of course doesn't work because it's part of dictionary. you access think intuitively. access first element in list, , list element @ index 0 respective dict: >>> print(x[0]['items'][0]) hat the logical progression >>> print(x[0]) {'name': 'joe', 'items': ['hat', 'scarf', 'boots']} >>> print(x[0]['items']) ['hat', 'scarf', 'boots'] >>> print(x[0]['items'][0]) hat

web - HTML Fixed Width? (No scroll bar) -

i want have set width page no horizontal scroll bar. (and if elements exceed page width, don't add width or horizontal scroll bar page.) probably not best user experience, need add css: body { overflow-x:hidden; }

doctrine - DDD PHP Doctrine2 - Mapping -

i hear how peoploe map domain objects data mapper pattern in doctrine2. went problem, when aggregates use clean php array , use php functions work array array_shift example. anyway till started integrate doctrine mappings domain entities. problem how doctrine works assosciations between entities. whenever aggregate root had 1 many relationship (or other tbh), doctrine used arraycollection class on that, instead of normal array. use 1 of methods toarray(), have check first in domain object if doctrine collections class, dirty. anyway chose in aggregate repository, before returning class. made reflection class set property public , replaced clean php array. works less dirty, still dont tbh. question is, how guys handle limitations od doctrine or maybe there no limitation :). , next question, if guys use doctrine arraycollection in domain classes? what using array for? i suspect problem using arrays instead of objects. objects should reflect domain , provide methods exi

wpf - DataGridTextColumn ValidationRules doesn't trigger Validation.HasErrorProperty -

i have datagrid datagridtextcolumn on have validationrule <datagridtextcolumn header="xxx" isreadonly="false"> <datagridtextcolumn.binding> <binding path="xxx" > <binding.validationrules> <v:xxxvalidator /> </binding.validationrules> </binding> </datagridtextcolumn.binding> i have b:bindvalidationresult.haserror="{binding haserror}" on datagrid . in bindvalidationresult use validation.haserrorproperty listen on validationerror changed. my validation rule return return new validationresult(false, ""); my feeling don't listen on right property datagridtextcolumn because if same thing textbox works charm. also, datagridcell red border when there error know there happening. i tried see if validation.haserror change doesn't trigger. <style.triggers> <trigger property="validation.haserror" value="tr

html - Form overlapping another form? -

i have 2 separate forms. however, second form overlapping first, instead of being beneath. can confirm css issue, cannot work out - has had me puzzled ages, , i'm giving up. here code: http://codepen.io/anon/pen/bnpgbw .comments-section .comment-form { padding: 20px; background: #f8f8f8; border: 1px solid #dddddd; border-radius: 3px; } thank time :) it's because .company-profile class being restricted 200px tall. first form doesn't fit height , overflows container won't push down next form because told 200px tall. remove height , fix issue.

Is there a way to shrink an Excel table to fit the data? -

i have excel table has several other places in spreadsheet using various reasons, , realized table had bad data. collected new data, , there fewer rows in new data set in previous table. is there way can shrink table reflect new count of data? not @ sure understand requirement i'm guessing want reduce size of tables/table without deleting entire rows in spreadsheet (because of content present elsewhere in spreadsheet in same rows table data). if so, merely select area of table deleted , press delete . if want remove formatting remains select angle icon shown @ extreme bottom right of table , drag suit. i assuming (table) rows deleted contiguous block @ bottom of table.

node.js - How to npm install a module without installing peer dependencies -

i trying npm install karma-jasmine , odd purpose want npm install module , not karma. install karma defined peerdependency. possible not install peerdependency , how? using npm 1.4.28 this package.json {"dependencies": {"karma-jasmine": "0.2.3"}} can update newer npm, let version >=3 ? not install peerdependencies default.

javascript - How reverse animations made with scrollTop(); -

function firstanimation() { $('.etc(1)').fadein(); } function secondanimation() { $('.etc(1)').fadeout(); $('.etc(2)').fadein(); } function thirdanimation() { $('.etc(2)').fadeout(); $('.etc(3)').fadein(); } function fourthanimation() { $('.etc(3)').fadeout(); $('.etc(4)').fadein(); } $(window).scroll(function() { if ($(this).scrolltop() > 150) { firstanimation(); } if ($(this).scrolltop() > 300) { secondanimation(); } if ($(this).scrolltop() > 450) { thirdanimation(); } if ($(this).scrolltop() > 600) { fourthanimation(); } }); guys, i'm using scrolltop() animate piece of site, , wondering if can reverse animation if o scroll bottom, , not top. i searching there isn't scrollbottom in jquery. first, set additional requirement each if statement condition each event scroll range prevent multiple events being triggered. second, add .fadeout() fu

ruby - Check specific line of HTML in Java -

i have following ruby code checks www.usnwc.org see if biking/running trails open. specifically, checks image changes status of trails: require 'open-uri' content = open('http://usnwc.org/#trail-status').read if content =~ /trailsclosed\.png/ puts "trails closed!" elsif content =~ /trailsopen\.png/ puts "trails open!" else puts "oops, images not found?" end i perform same task in java. far have following code gets page , prints whole html file console. public class openurl { /** * @param args command line arguments * @throws java.io.ioexception */ public static void main(string[] args) throws ioexception { url usnwc = new url("http://www.usnwc.org/#trail-status"); try (bufferedreader in = new bufferedreader(new inputstreamreader( usnwc.openstream()))) { string inputline; while((inputline = in.readline()) != null) syste

wpf - How to redraw a button from code behind to show new icon -

i have xaml style this: <style x:key="imagetextbuttonstyle" targettype="button"> <setter property="template"> <setter.value> <controltemplate targettype="button"> <border name="buttonstyleborder" cornerradius="9" background="#ff9e9fa3"> <grid margin="0,0,0,0"> <grid.columndefinitions> <columndefinition width="60"/> <columndefinition width="*"/> </grid.columndefinitions> <image source="{binding tag, relativesource={relativesource templatedparent}}" verticalalignment="stretch" horizontalalignment="stretch" margin="10"/> <label content="{templatebinding content}&q

'TypeError: list indices must be integers, not str' Python 3 -

i need bit of assignment (first time posting on se please excuse lack of posting etiquette if any) so code had write spell checker. supposed is: 1.) check through 2 lists (one dictionary, correctly spelled words, other user input list should have incorrectly spelled word or two) 2.) suggest correct word in place of misspelled word (example if spelled heloo, spell checker spelled wrong , suggest word hello, help, etc.) my biggest problem right @ line 19, getting list indices must integers problem. any appreciated, , finishing appreciated! feel outside of syntax more improved upon. thanks. here code, not finished import re def words_from_file(filename): try: f = open(filename, "r") words = re.split(r"[,.;:?\s]+", f.read()) f.close() return [word word in words if word] except ioerror: print("error opening %s reading. quitting" % (filename)) exit() user_word = words_from_file('user_word.txt') suggestion = wo

C++ template return types -

i have 2 template classes, vector3 , matrix4x4. vector3 explicitly instantiated float , double , int , whereas matrix4x4 explicitly instantiated float , double . i'm thinking return type user expect when multiplying them different types. internal multiplication happen such non-matching types promote 1 other, i'm not sure type return e.g. vector3i vec3i(1, 2, 3); matrix4x4f mat4f; //automatically set identity auto result = vec3i * mat4f; auto result2 = mat4f * vec3i; in both cases think result , result2 should both vec3f, if multiply int float . guess i'm wondering if in line common practice, or if not if, instead of multiplying different types, should doing explicitly casting 1 other static_cast , casting operators ?

c# - Blocking web page in ASP.NET Web Forms with long running method -

i want show database result in gridview web page extremly slow when calling long running method. inside gridview have template field following item template: <itemtemplate> <asp:label id="lblnumresults" runat="server" text='<%# getnumcrawlresults(convert.toint32(eval("id"))) %>'></asp:label> </itemtemplate> this corresponding method: public string getnumcrawlresults(int jobid) { var task = task.run(() => utilities.getnumcrawlresults(jobid)); //this slow , blocks gui return convert.tostring(task.result); } this database query: public static async task<int> getnumcrawlresults(int jobid) { documentcollection collection = await getorcreatecollectionasync(database.selflink, convert.tostring(jobid)); var result = (from c in documentdb.createdocumentquery<shared.crawlresult>(collection.selflink) select c).asenumerable(); return result.count();

java - Spring Security shows default login instead of OAuth2 -

i writing restful web service (jersey running on tomcat) needs authenticate users. plan redirect them login google via oauth2 . once grant permission see email address, we'll know if known user in our system. i using spring security . had working basic authentication (hard-wired list of users , passwords.) added oauth2 elements xml configuration, when access service browser i'm still getting prompted login browser, instead of getting redirected google's website. there no particular errors logged console. suggestions appreciated. here spring security configuration file: spring-security.xml (though without real client's id , secret.) <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:oauth="http://www.springframework.

swift - Master-Detail View Controller and CoreData -

as new swift, trying work master view controller read blog using json , store in core data. except don't understand how data gets deleted core data upon right swipe , delete. sorry ask such question , embarrassing. know sure following code deletes cant find implementation nor understand how knows entity delete data from. func controller(controller: nsfetchedresultscontroller, didchangeobject anobject: anyobject, atindexpath indexpath: nsindexpath?, forchangetype type: nsfetchedresultschangetype, newindexpath: nsindexpath?) { switch type { case .insert: tableview.insertrowsatindexpaths([newindexpath!], withrowanimation: .fade) case .delete: *tableview.deleterowsatindexpaths([indexpath!], withrowanimation: .fade)* case .update: self.configurecell(tableview.cellforrowatindexpath(indexpath!)!, atindexpath: indexpath!) case .move: tableview.deleterowsatindexpath

version control - git - merge two divergent branches ignoring some directories -

short story: want tell git ignore directory when merging. know git doesn't work way... long story: have project deployed on 2 different platforms. every platform needs tweaks code deploy. i have 2 branches, 1 every platform: platforma , platformb. 2 branches practically identical. difference in couple of files , directory needs present on 1 platform not on other. scenario: platforma branch: - dir1 - file1 - dir2 - file2 platformb branch: - dir1 -file1 the problem appears when i'm working on platforma , make changes file1. want these changes available on platformb. problem when merge, git adds dir2 , file2 platformb. i want able work on platformb , make changes file1 , able merge platforma without git removing dir2 , file2. so question is: there way have 2 mergeable divergent branches? or there way tell git ignore directory/commit? i have tried solution works when merging projectb->projecta, not other way around (git copies dir2 , file2 onto pr

How far along is logstash in processing a file -

i have logstash running this: input { file { path => ["/home/logdata/*.log"] codec => json { charset => "utf-8" } } } output { elasticsearch { protocol => "http" host => "whatever" cluster => "recordings" index => "logstash-%{+yyyymmdd}" } } some of these files many gb in size. how can tell logstash in process? there progress indicator? can tell how many lines in or left? amongst other things, i'm trying figure out when delete original log files knowing when logstash finished useful. logstash uses sincedb files track current read position of each input file. understanding sincedb files logstash file input describes format of files, , name of each sincedb file devised filename patterns (specifically, md5 hash of comma-separated list of patterns; see file.rb ). suspect logstash 2.0 might improve situation roadmap talks m

ruby - gem list shows knife-windows. But Fails when running the command knife bootstrap windows winrm -

i have chef client running in windows 7 machine , trying setup node chef workstation . installed knife-windows using rubygem , gemlist shows knife-windows (0.8.4) but following failed. knife bootstrap windows winrm 10.x.x.x -x userid -p password warning: hostname containing 'windows' specified. please install 'knife-windows' if attempting bootstrap wi ndows node via winrm. connecting windows error: network error: getaddrinfo: no such host known. check knife configuration , network settings checked winrm service , it's running , configured recommended here https://gist.github.com/jimcroft/3878113 what missing?

c++ - building llvm/clang 3.6 on windows 7 with mingw64 -

i pulled latest svn repositories , did manage build same code visual studio. i'm trying use youcompleteme plugin vim, needs clang built mingw64. visual studio build did not work. here error. not sure how continue. llvm[4]: compiling action.cpp release+asserts build llvm[4]: compiling compilation.cpp release+asserts build llvm[4]: compiling crosswindowstoolchain.cpp release+asserts build llvm[4]: compiling driver.cpp release+asserts build llvm[4]: compiling driveroptions.cpp release+asserts build llvm[4]: compiling job.cpp release+asserts build llvm[4]: compiling msvctoolchain.cpp release+asserts build in file included c:\mingw64\x86_64-w64-mingw32\include\winnt.h:7681:0, c:\mingw64\x86_64-w64-mingw32\include\minwindef.h:146, c:\mingw64\x86_64-w64-mingw32\include\windef.h:8, c:\mingw64\x86_64-w64-mingw32\include\windows.h:69, c:/llvm-3.6/tools/clang/lib/driver/msvctoolchain.cpp:38: c:\mingw64\x86_64-w64-mi

php - Finding and Replacing String and characters around it -

stackoverflow. let's have variable: $paragraph = "this bunch of random information. here url: http://example.com/inventory/personid checking out!"; i need detect if $paragraph has url in it, if personid changes, , save variable, replace new code. example, should walk away with: $url = "http://example.com/inventory/personid"; $replace = "newinformation!"; $newparagraph = "this bunch of random information. here url: newinformation! checking out!"; i'm pretty sure has strpos(), have no idea past that. edit: personid represented along lines of #730_2_1697061248 numbers change. just use preg_replace() , replace url: echo $newparagraph = preg_replace("/\b" . preg_quote($url, "/") . "\s*/", $replace, $paragraph); output: this bunch of random information. here url: newinformation! checking out! regex explanation: /\b . preg_quote($url, "/") . \s* \b assert position @

c# - Generic Generics or Type argument inference and inheritance -

i trying generics in .net 4.5 c# , honestly, i'm not sure if possible or it's called. makes searching more difficult. anyways, best explain example. let's have interface: public interface isomebase {} and example of implementation public class anobject : isomebase {} public class anotherobject : isomebase {} then i've got classa has few generic methods so public class classa { public t somemethod1<t>() t : class, isomebase { //do stuff , return t return default(t); } public list<t> somemethod2<t>(expression<func<t,object>> someexpression ) t : class, isomebase { //do stuff , return list<t> return new list<t>(); } } i want able use (which can): public class someimplementation { public void test() { var obj = new classa(); var v = obj.somemethod1<anobject>(); var v2 = obj.somemethod2<anotherobject>((t) =>

ruby on rails - How to add story to top of pivotal tracker backlog with API -

i've got 2 situations, either high or low priority. high-pri should go top of backlog. low-pri should go top of icebox. in order send top of backlog, have add current_state=unstarted , before_id=[id of first item in backlog] getting first item in backlog simple fetch /stories?limit=1&current_state=unplanned except request on average seems take 10-15 seconds! am going incorrectly?

c# - how to avoid a single pixel line disappear in wpf? -

i use path element(strokethickness="1" snapstodevicepixels="true") in grid. want resize window, grid element wrapped viewbox element. problem when resize window, path disappear time. if turn snapstodevicepixels false, path element may blur not want. how avoid single pixel line dispear? the xaml code: <window x:class="wpfapplication2.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="207" width="475"> <viewbox stretch="fill"> <grid height="320" width="517"> <path data="m0,0 h1 z" strokethickness="1" stroke="black" margin="72,73,79,218" stretch="fill" snapstodevicepixels="true" minheight="1"/> </grid> </viewbox>

struct - C Abstract data type pointer - Program modularity -

Image
if module depends other sub-module, either including in header or in code file, , if modules, besides contributing main program, mutually dependent? the figure below schematically illustrates situation in module1.h/.c requires sub-module module4.h, , module2 requires module3. each header file has own typedef struct exemple: typedef struct list * list; and source file related header files implement struct : struct list { unsigned length; char * value; }; i got struct in header file: typedef enum {start, end, middle, comments, conditions} typelistbal; typedef struct bal * bal; and source file : struct bal { typelistbal type; list name; // name of bal list attributes[]; // array of type struct list }; i've been reading lot tonight , i'm not quite sure 1 thing. if i'm including header file in source file need in case, i'm including list.h in bal.c cause bal.c got struct definition member of type list. to

Android GPS Tracking Returning Odd Results -

i've encountered strange numbers while tracking data using gps on htc one. in essence, have function calculates approximate difference between 2 gps locations, results are... odd. the first reading reasonable, , next readings 0.0km until 5th or sixth. i calculate distance every 10 seconds, while moving @ 50km/h naturally, i'd expect other 0.0km every reading. could spot problem is? there limit on how many times can gps readings? thanks! here sample of data going @ 50 km/h taking readings every 10 seconds: 186m 0.0m 0.0m 0.0m 190m 0.0 ... public class profile extends activity { gpstracker gps; private double long1, lat1; public static double haversine( double lat1, double lng1, double lat2, double lng2) { int r = 6371; // average radius of earth in km double dlat = math.toradians(lat2 - lat1); double dlon = math.toradians(lng2 - lng1); double = math.sin(dlat / 2) * math.sin(dlat / 2) + mat

c++ - CUDA - Generating the Halton sequence in parallel -

i want write kernel in cuda generate the halton sequence in parallel, 1 value generated , stored each thread. looking @ sequence, seem generating each subsequent value in sequence involves work done in generating previous value. generating each value scratch involve redundant work , cause large gap between execution times of threads. is there way parallel kernel improves upon serial algorithm? i'm new parallel programming pardon question if answer well-known pattern. note: did find this link in textbook (which uses without describing how works) file link there dead. halton sequence generated by: get representation of in base-p numeral system reverse bit order for example, base-2 halton sequence: index binary reversed result 1 1 1 1 / 10 = 1 / 2 2 10 01 01 / 100 = 1 / 4 3 11 11 11 / 100 = 3 / 4 4 100 001 001 / 1000 = 1 /

javascript - YouTube API - onPlayerStateChange -

i'm using youtube api in conjunction cyclone slider. goal pause slideshow once youtube starts playing. i'm using following code works nicely: <script> var tag = document.createelement('script'); tag.src = "//www.youtube.com/iframe_api"; var firstscripttag = document.getelementsbytagname('script')[0]; firstscripttag.parentnode.insertbefore(tag, firstscripttag); </script> <script> var player; function onyoutubeplayerapiready() { player = new yt.player('video', { events: { 'onstatechange': onplayerstatechange } }); } function onplayerstatechange(event) { if(event.data === 1) { $(".cycle-slideshow").cycle('pause'); } if(event.data === 2) { $(".cycle-slideshow").cycle('resume'); } } </script> however, seems work if refresh of page. if navigate between pages , return homepage

JQuery causing fadeIn twice? -

i trying achieve effect when click new item clicked item fadeout. when click same item twice fades in again, , not fade in twice. since still learning js please add reasoning why mine isnt working , needs done achieve it, able self learn better :) i wast able load code input module here code: jquery(document).ready(function() { jquery(".qs").click(function() { jquery(".qs").siblings(".ans").fadeout(600).not(jquery(this)); jquery(this).siblings(".ans").fadein(600); }); }); <table class="faqs" style="width:100%"> <tr> <td class="qs"><span>1. how lenden work?</span></td> <td class="ans">this example answer more length testing.</td> </tr> <tr> <td class="qs"><span>2. different modes of transaction?</span></td> <td class="ans">answer</td> </tr> </table&

linux - Google compute engine - how do I mount disk before init scripts that start applications run -

i have google-startup-script mounts disk on boot or restart. unfortunately google-startup-scripts run last during boot process, @ end of bsd init system. result, wildfly server application in /etc/init.d starts before disk mounted. how can ensure wildfly server starts after disk mounted? i agree mounting disk fstab not idea. solution, if debian-like distro init.d find wildfly in /etc/init.d i.e: /etc/init.d/wildfire , amend/add $gce_onboot # required-start: line in beginning of script should like: # required-start: google-startup-scripts xxxx yyyy

Graph In Android Using AChartEngine -

Image
problem not able fit graph according screen. of portion of graph cutting right side.i tried lot set margin right nothing works me.as can see in attached image last bar cutting half. please me. *layout.xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linear1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/white" android:orientation="vertical" > <tablelayout android:id="@+id/table1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:shrinkcolumns="6" android:stretchcolumns="*" > <tablerow android:id="@+id/tablerow1" an

c - Interpreting ELF symbol table -

i wrote simple program called a.c understand symbol table on x86 machine: extern int foo; int function(void){ return foo; } i compile , readelf $gcc -c -m32 a.c $readelf -a a.o > a.log the symbol table in a.log shown below: symbol table '.symtab' contains 10 entries: num: value size type bind vis ndx name 0: 00000000 0 notype local default und 1: 00000000 0 file local default abs a.c 2: 00000000 0 section local default 1 3: 00000000 0 section local default 3 4: 00000000 0 section local default 4 5: 00000000 0 section local default 6 6: 00000000 0 section local default 7 7: 00000000 0 section local default 5 8: 00000000 10 func global default 1 function 9: 00000000 0 notype global default und foo what purpose of symbol table entry 0 , entries 2 7?

sockets - Communication on 2 ports between 2 Android devices using WiFi Direct -

i creating application monitor movements in particular android device (client) , report such instances android device (server). also, under specific conditions, client take picture , transmit image server. i using wifi direct setup connection between 2 devices. after using socket connections explained in wifi direct demo. using port 8988 send motion sensor events , using port 8987 send images capture. on server side, using 2 different instances of same async task serversocket connecting different ports listen incoming messages. works fine long motion sensor events being sent across. first image capture being sent/received correctly. however, after server doesn't receive additional messages. tried having 2 different async task classes avoid having 2 instances of same class didn't work well. tried having 1 async task , intent service doesn't work. this intentservice using send messages across server. public class messagesender extends intentservice { public s