Posts

Showing posts from September, 2013

python - Scrapy not working as expected -

this scrapy spider. i'm trying scrape data web. don't know how force scrapy follow links recursively. mistake? import re scrapy.selector import htmlxpathselector scrapy.contrib.spiders import crawlspider, rule scrapy.contrib.linkextractors.sgml import sgmllinkextractor scrapy.selector import selector yellowpagesofmoldova.items import yellowpagesofmoldovaitem scrapy.item import item class yellowspider(crawlspider): name = 'yellow' allowed_domains = ['yellowpages.md'] start_urls = [ 'http://www.yellowpages.md/eng/companies/info/8939-arc-publishing-house'] rules = ( rule(sgmllinkextractor(allow=('eng.+')), follow=true), ) def parse(self, response): sel = selector(response) = yellowpagesofmoldovaitem() i['url'] = response.url i['locality'] = sel.xpath("//tr[3]/td/p[1]/span[1]/text()").extract() i['title'] ...

c# - Button click highlight list box item WP8 -

i have list box 4 items a,b,c , d. i have button in application bar,onclick of button need highlight or change background color of list item , b green. how achieve ? if want in xaml, add following lines inside tag <listbox.resources> <solidcolorbrush x:key="{x:static systemcolors.highlightbrushkey}" color="red"/> <solidcolorbrush x:key="{x:static systemcolors.controlbrushkey}" color="red"/> </listbox.resources>

javascript - Masonry doesnt display correctly on Safari -

i using masonry display images , on firefox loads fine on safari doesnt load correctly displays scattered. js im using. no clue doing wrong? var $container = $('.main_containera'); $container.imagesloaded(function(){ $container.masonry({ itemselector: '.item1', columnwidth: function(containerwidth){ return containerwidth / 12; } }); $('.item1 img').removeclass('lazy-load'); $('.item1 img').addclass('not-loaded'); $('.item1 img.not-loaded').lazyload({ effect: 'fadein', load: function() { // disable trigger on image $(this).removeclass("not-loaded"); $container.masonry('reload'); } }); $('.item1 img.not-loaded').trigger('scroll'); });

android - GetFile Cordova 3.4.0 err.code 1000 -

i try getfile cordova 3.4.0 : filemanager.prototype.readastextfromfile = function (filename, readdatacallback) { var = this; try { window.requestfilesystem(localfilesystem.persistent, 0, function (filesystem) { filesystem.root.getfile(filename, {create: false}, function (fileentry) { fileentry.file( function (file){ var reader = new filereader(); reader.onloadend = readdatacallback; reader.readastext(file); } , function(err){alert('readfile' + " fail: " + err.code);}); } , function(err){alert('getfile' + " fail: " + err.code);}); }, function(err){alert('filesystem' + " fail: " + err.code);}); } catch (e) { logerror(...

Java - Best way(main criteria is perfomance) to get part of a string before a given substring? -

i have string: this string-tro:jjj me i want string this string- i know can use method string#split colleagues said not best way because harm performance. is there way doing that? yes, can use string#substring method that: string s = "this string-tro:jjj me"; system.out.println(s.substring(0,s.indexof("-")+1)); output: this string-

datasource - Grails with multiple data sources and Hibernate Envers -

i'm running grails 2.2.4 application multiple data sources. 1 requirement provide auditing hibernate envers. did following: domain classes annotated org.hibernate.envers.audited org.hibernate:hibernate-envers:3.6.10.final in classpath hibernate event listeners defined follows. should work defined data sources. beans { auditeventlistener(auditeventlistener) hibernateeventlisteners(hibernateeventlisteners) { listenermap = [ 'post-insert': auditeventlistener, 'post-update': auditeventlistener, 'post-delete': auditeventlistener, 'pre-collection-update': auditeventlistener, 'pre-collection-remove': auditeventlistener, 'post-collection-recreate': auditeventlistener ] } } however, no audit entries inserted revision tables. has hint how fix this? still issue latest grails version? invest effort upgrade. note, using hibernate envers. not use grails plugin. ther...

jquery - width and height of a swf based on screen resolution -

my swf effect appears on div if press button. problem div has size in %, need swf have same width , height. here code tried( show code swf size, because jquery code appear on button press works): <div id="be2"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="border-effect2" align="middle"> <param name="movie" value="img/border-effect.swf" /> <param name="quality" value="high" /> <param name="bgcolor" value="transparent" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="wmode" value="transparent" /> <param name="scale" value="showall" /> <param name="men...

automation - Continuous integration for The cross-platform (Mainly Linux) development projects -

we start new project in linux environment. i put source code under source control system , automate build process tool (continuous integration system). can 1 suggest please. i thinking of - svn source control. -teamcity vs jenkins vs cruisecontrol ns how git, gerrit , jenkins. using , great open source combination.

PHP image upload fail -

i need help. trying upload image php code. when use different .php file upload code, works, when try add main code have information posted database. i have added , said works separate code upload. form action="core/books-reg.php" method="post" enctype="multipart/form-data" this main .php code in want make work. code starts after !empty(description). database takes name , puts in mysql there no file in folder. or other method good. <?php session_start(); require("dbc.php"); $username = $_session['username']; $title = $_post['title']; $con = $_post['con']; $price = $_post['price']; $prodcode = $_post['prodcode']; $isbn = $_post['isbn']; $publisher = $_post['publisher']; $pages = $_post['pages']; $description = $_post['description']; $year = $_post['year']; $course = $_post['course']; $module = $_post['module']; if(!empty($title)) { ...

how to use if else in sql server with where clause -

create procedure findlist @comedianname1 nvarchar(30),@comedianname2 nvarchar(30) select comedian comedian if @comedianname2!=null begin comedian! = @comedianname1 , comedian! = @comedianname2 end else begin comedian! = @comedianname1 end go i getting error : msg 156, level 15, state 1, procedure findlist, line 7 incorrect syntax near keyword 'where'. you can not use if in select. instead in case: select comedian comedian comedian! = @comedianname1 , comedian! = isnull(@comedianname2, comedian!) what do? if compares comedian! @comedianname1 , if @comedianname2 not null, compares comedian! @comedianname2 . otherwise compares comedian! comedian! , true .

crossfilter: how to extract time information from start date and end date columns -

i have list of projects start date , end date in separate columns. want show how many projects in each month on bar graph. each project required counted on each month between start , end month can see how many projects still active in each month. data looks below. projects,start date,end date project 1,6/10/2013,5/31/2014 project 2,6/13/2013,2/14/2014 project 3,6/16/2013,6/15/2014 project 4,6/20/2013,3/31/2014 project 5,6/21/2013,3/20/2014 project 6,6/21/2013,3/31/2014 project 7,7/1/2013,1/1/2014 project 8,7/1/2013,3/30/2014 project 9,7/1/2013,6/30/2014 project 10,7/1/2013,12/31/2014 project 11,7/15/2013,1/15/2014 project 12,7/16/2013,3/31/2014 project 13,8/15/2013,2/15/2014 project 14,8/27/2013,3/31/2014 project 15,9/1/2013,10/31/2014 project 16,9/2/2013,2/28/2014 project 17,9/2/2013,12/31/2014 project 18,9/7/2013,12/31/2014 project 19,9/10/2013,3/9/2014 project 20,9/13/2013,3/31/2014 project 21,10/1/2013,3/31/2014 in excel prepare data graph below (for ye...

one field not submitting value on submit in php -

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> its complaint registration form.the created field not submitting //value on on submit. <?php //to display contents after posting in same page if (isset($_post['submit'])) { $createdby = $_post["createdby"]; //its complaint registration form.the created field not submitting //value on on submit. echo "createdby:".$createdby." <br>"; } //its complaint registration form.the created field not submitting //value on on submit. echo "<script>window.close();</script>"; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type=...

python - pip installs 2.7 packages into /usr/local/lib/python3.2/dist-packages -

folks. i'm trying install packages tornado using pip (simple pip, not pip3.2 ), in installs /usr/local/lib/python3.2/dist-packages , python2.7 can't find them. what doing wrong? should set pythonpath or whatever? (it seems quite dangerous). $ /usr/local/bin/pip --version pip 1.4.1 /usr/local/lib/python3.2/dist-packages/pip-1.4.1-py3.2.egg (python 3.2)\ ubuntu 12.04 lts answer: sudo mv /usr/local/bin/pip /usr/local/bin/pip3.2 do have python2 installed? don't know on distribution are, there pip2 pip python2 (example arch linux -> link ). otherwise check http://pip.readthedocs.org/en/latest/installing.html additional instructions

java - How to turn 2D array rows into a tab separated string when writing an output file -

i have object writing output file. bufferedwriter bufferedwriter = new bufferedwriter(new filewriter("output.txt")); bufferedwriter.write("id"+"\t"+"symbol"+"\t"+ arrays.tostring(data.symbols)); bufferedwriter.write("\n"); (int = 0; < data.cids.length; i++) { bufferedwriter.write(data.ids[i]+"\t"+data.isymbols[i]+"\t" +arrays.tostring(data.matdata[i])+"\n"); i table in output file: id symbol [001, 002, 003, 004, 005] #1 a01 [2.3, 5.5, 4.5, 1.2, 3.3] #2 a02 [2.2, 4.5, 7.5, 6.2, 9.3] ...and on. how can display arrays without brackets , tab-separated strings, output this: id symbol 001 002 003 004 005 #1 a01 2.3, 5.5, 4.5, 1.2 3.3 #2 a02 2.2 4.5 7.5 6.2 9.3 you can implement own tostring method returns tab delimited string something public static string tostring(...

javascript - Implement autoplay, pause on hover, keyboard control on slideshow -

i trying implement this sideshow on project, , want add features : auto-play pause on hover multiple instance of slider go next slide keyboard arrow keys what have tried ? i have added code var autoscroll = window.setinterval(function(){ navigate( 'next' )}, 5000); component.onmouseover = function(e){ autoscroll = clearinterval(autoscroll); console.log('onmouseover'); }; component.onmouseout = function(e) { clearinterval(autoscroll); var autoscroll = setinterval(function() {navigate( 'next' )}, 5000); console.log('onmouseout'); }; live demo: http://jsfiddle.net/m2cwf/1/ what problem ? the autoplay works fine until manually use control arrow, see interval change in case, maybe need add condition if( isanimating ) return false; the pause on hover not seems work, , console log see event fired several times in 1 single hover ! if have multiple instance o...

Youtube Iframe API return "ptk" parameter -

i'm getting 404 @ http://www.youtube.com/get_video?noflv=1&video_id=heyb3xd1qye&cpn=b7nl0olmp …3a%2f%2fpoolside.fm%2f&fmt=135&ptk=sonypicture_longform&autoplay=1&splay=1 when using youtube iframe api. interestingly video still plays. i've noticed "ptk=sonypicture_longform" parameter. can shed light on ptk parameter is? thanks.

java - CXF + polymorphic POST data -

my project has core , extended projects. project classes can extend entities , add data them. core supposed support subclasses in rest api, exception not recognizing added fields. for example: core: class student { private integer id; private string name; } interface studentservices { @path("/") @put public void savestudent(student student); } and there implementation handles save operation. works well. but want provide ability extend student class, projects , other won't: project: class studentext extends student { private string extradata; } if send studentext in json server, system crushes unknown property exception. don't think disabling validation suffice - cxf still wont know want extended class. tried generics didn't work: public <t extends student> void savestudent(t student); please me. regards, id

string - benefits of Data.Text -

what benefits of importing data.text on haskell's native string functions? ghci$> drop 3 "abcdefg" > "defg" ghci$> import qualified data.text t > t.drop 3 $ t.pack "abcdefg" > "defg" etc. many other methods (if not all) provided data.text provided out box standard library. in addition, use string data.text, have pack/unpack string text. why want use data.text? data.text more space-efficient. haskell's native string equivalent linked list of char s, means has high space overhead moderately-sized chunks of text. data.text more performant string . because string linked list, whereas text memory array (or several memory arrays in lazy variant), provides better memory locality. text can interface native system libraries (e.g. io) more efficiently string s, need go through intermediate buffer. programs lot of io (reading/writing files), speedup can order of magnitude or more. finally...

How to add audio to a HTML image? -

i'm still new this, i'm trying add audio mp3 sound html image, played when clicked on. how can right? i've tries few things, '' tag, or installing java-based stuff, soundmanager2, none of them seems work. problem is, don't know how use them properly. i'm using dreamweaver cs6, in there should option "behaviour"--> play sound, it's not there, i'm lost this. you can achieve using audio , video dom methods play() , pause() onclick of image working demo <audio id="audio_play"> <source src="http://www.w3schools.com/tags/horse.ogg" type="audio/ogg" /> <source src="http://www.w3schools.com/tags/horse.mp3" type="audio/mpeg" /> </audio> <img src="http://bit.ly/1kx7d49" onclick="document.getelementbyid('audio_play').play(); return false;" /> <img src="http://bit.ly/1mq0tit" onclick="document....

c++ - What does new (this) mean? -

i found code sample study: t & t::operator=(t const & x) { if (this != &x) { this->~t(); // destroy in place new (this) t(x); // construct in place } return *this; } when @ the documentation new there no version takes pointer. thus: what new (this) mean? what used for? how can called if not listed in documentation? it called "placement new", , comments in code snippet pretty explain it: it constructs object of type t without allocating memory it, in address specified in parentheses. so you're looking @ copy assignment operator first destroys object being copied (without freeing memory), , constructs new 1 in same memory address. (it pretty bad idea implement operator in manner, pointed out in comments)

Cordova plugin (for ver > 3) for Android account manager -

i've been on past few days, may because not strong on java side... trying list of android device's email accounts (or - accounts) using cordova. there plugin available it's compatible cordova app version less 2.9. so, built new plugin instruction available @ phonegap website , hosted plugin on git . while adding project, receive errors related js , also, main java class - accountmanager shows error @ "context". can me looking @ plugin tried bring of so question , phoengap's plugin development guide... is plugin complete 1 @ all? kindly guide me.. update: updated java , javascript files, , when add plugin, new error -as follows - uncaught module com.am.accountmanager.accountmanager defined : line 79 in cordova.js here working/tested plugin retrieving android device information - includes every piece of information android device...

web services - SOAP in PHP. How do I get a return? -

so, i'll come right out , new soap. i've done php quite time, , xml, never made wsdl , soap. here's goes (hopefully isnt stupid). i have wsdl file want request from. ex: http://whateverservice.org/?wsdl and want simple api call job called "jobapi_checkconnection". using soapui, soap code when looking @ job: <soapenv:envelope xmlns:soapenv="http://schemas/xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> <soapenv:header/> <soapenv:body> <tem:jobapi_checkconnection/> </soapenv:body> </soapenv:envelope> so, how translate php? looking @ tutorial: http://devzone.zend.com/2202/php-and-soap-first-steps/ i of it, not all... can gather far, php code should similar this: <?php $wsdl = "http://whateverservice.org/?wsdl"; $client = new soapclient($wsdl); $result = $client->jobapi_checkconnection(); echo $result->jobapi_checkconnectionresult; ?> but returns ...

Google Analytics Version 3 for Android - Nothing is logged or tracked -

what need my analytics screen empty. 0 users, 0 sessions, etc. have waited couple hours kind of tracking show no luck. there way events logged on logcat? how have kind of indication happening? running on debug mode, kind of indication great! have waited 4 hours. what did far @override public void onstart() { super.onstart(); // rest of onstart() code. easytracker.getinstance(this).activitystart(this); // add method. googleanalytics.getinstance(this).getlogger() .setloglevel(logger.loglevel.verbose); googleanalytics googleanalytics = googleanalytics.getinstance(getapplicationcontext()); googleanalytics.setappoptout(false); } @override public void onstop() { super.onstop(); // rest of onstop() code. easytracker.getinstance(this).activitystop(this); // add method. } sample code logs event : public void togglemenuvisibility() { easytracker easytracker = easytracker.getinstance(this); ...

json - Fusion Charts for representing data in graphical form -

i trying render data in graph using fusion charts. have web service returns data in json format. want render chart data. can directly give url of web service cannot set key value pairs. possible so/ can 1 please tell me how this. it can use json url/feed, json object (in javascript) or json string. functionality provided fusioncharts class method setjsonurl() . example mychart.setjsonurl("data.json"); see http://docs.fusioncharts.com/charts/contents/firstchart/jsondata.html

javascript - SVG Rotate and Scale Transform Issue -

i trying re-size, rotate , drag svg elements using transformations. if rotate object, re-size it, , rotate again, on last rotation element gets displaced wrongly. resizing done way var matrix = svg.createsvgmatrix() .translate(x,y) .scalenonuniform(sx,sy) .translate(-x,-y); var newmatrix = svg.createsvgtransformfrommatrix(ctm.multiply(matrix)); element.transform.baseval.initialize(newmatrix); rotation done way var matrix = svg.createsvgmatrix() .translate(cx,cy) .rotate(angle) .translate(-cx,-cy); var newmatrix = svg.createsvgtransformfrommatrix(ctm.multiply(matrix)); element.transform.baseval.initialize(newmatrix); is there idea resolve issue? i use combination of getbbox element identify center no matter transforms applied. also, track element's transformed center, enclose in svg wrapper, , bounding box. use matrix transforms , consolidate() on each transfo...

algorithm - Find the arc of the intersection between circle and rectangle -

Image
i need find largest arc created intersection of circle , rectangle. have center of circle, radius , coordinates of rectangle, , need find angle of intersection points center of circle. i have code works, computes solution iterating points of circumference, , wondering if there's more elegant way calculate solution using trigonometry instead of "brute force". that's code: import 'dart:math'; class circlethesquare { final point _circlecenter; final int _circleradius; final rectangle _box; circlethesquare(this._circlecenter, this._circleradius, this._box); map<string, double> arc { map res = new map(); double angle = .0; double anglein; double angleout; double increment = 1.0; while (true) { if (angle > 360.0 && anglein == null) { break; } // finds point of intersection (next points inside // of rectangle). if (!_isoutside(angle) && _iso...

php - Symfony2 POST variable parameter empty in Internet Explorer -

i made custom form login in symfony2 application : {% block body %} <div id="login"> <div class="login_title">authentication</div> {% if error %} <div class="alert alert-error">{{ error.message }}</div> {% endif %} <form action="{{ path('login_check') }}" method="post"> <table id="login_form"> <tbody> <tr> <th><label for="login_login">login</label></th> <td> <input type="text" id="username" name="_username" value="{{ last_username }}" required></td> </tr> <tr> <th><label for="login_password">password</label></th> ...

html - Horizontal Scrolling Banner Isn't Working -

i have created website in entire page scrolls left , right instead of , down using html , css. have taken code website create banner type navigation thing polygon's website when page viewed iphone or device small screen that, can't understand why in case code isn't working, have spent ages on , cant see problem. maybe fresh pair of eyes help, here code i'm using. css: html { height: 100%; overflow-x:hidden; } body { height: 100%; } #cover_menu { width: 2560px; height: 480px; overflow: hidden; } #cover_tile { width: 640px; height: 480px; float: left; } #cover_link { width: 100%; height: 50%; } html: <div id="cover_menu"> <div id="cover_tile"> <div id="cover_link" class="link_1">hello</div> <div id="cover_link" class="link_2">hello</div> </div> <div id="cover_tile"> ...

r - How to set up cluster slave nodes (on Windows) -

i need run thousands* of models on 15 machines (each of 4 cores), windows. started learn parallel , snow , snowfall packages , read bunch of intro's, focus on setup of master. there little information on how set worker (slave) nodes on windows. information contradictory: some sock cluster practically easiest way go , others claim sock cluster setup complicated on windows (sshd setup) , best way go mpi . so, easiest way install slave nodes on windows? mpi, pvm, sock or nws? my, possibly naive ideas (listed priority): to use 4 cores on slave nodes (required). ideally, need r packages , slave r script or r function listen on port , wait tasks master. ideally, nodes can added/removed dynamically cluster. ideally, slaves connect master - wouldn't have list slaves ip's in configuration of master. only 1 100% required, 2-4 "would good". naive request? i sorry have not been able figure out available docs , tutorials. grateful if point me out right sour...

c# - .NET add directory for dependencies at runtime -

from main c# application instantiate application via reflection. assembly.createinstance( ... ) however other assembly relies on dlls in directory executing assembly. how can add directory lookup path? here how implement need in ndepend.powertools. these set of tools based on ndepend.api . dll ndepend.api.dll in directory .\lib while ndepend.powertools.exe assembly inn directory .\ . the ndepend.powertools.exe main() method looks like: [stathread] static void main() { appdomain.currentdomain.assemblyresolve += assemblyresolverhelper.assemblyresolvehandler; mainsub(); } // mainsub() here avoids main() method uses // ndepend.api without having registered assemblyresolvehandler [methodimpl(methodimploptions.noinlining)] static void mainsub() { ... and assemblyresolverhelper class is: using system; using system.diagnostics; using system.reflection; namespace ndepend.powertools { internal static class assemblyresolverhelper { internal s...

java - Disable Parity Bit for serial Communication does not work -

i have problem sending bytes through comport. sends parity bit, although explicitly turned off (i need byte without parity communicate hardware). code simple: process p = runtime.getruntime().exec("cmd.exe /c mode com1: baud=115200 parity=n data=8 stop=1 to=off xon=off rts=off dtr=off"); p.waitfor(); fp = new randomaccessfile("com1","rw"); fp.write((byte)0x21); i have oscillator connected port , whatever do, there 1 bit, appears parity bit. can see, disabled parity via code, , disabled via device manager. see on oscillator : 0 0010 0001 11 (start , stop bit incuded). can't figure out, parity or bit comes from... has idea? while mode command 1 upon time intended used , did work, skeptical how effort microsoft has put maintaining kind of legacy support. first step open command prompt , run c:\>mode c:\>rem above command display values configurable settings c:\>mode com1: baud=115200 parity=n data=8 stop=1 to=off xon=off rts=of...

mdx building set from external file -

i trying build 'dynamic' mdx take external file (which has 1 column multiple rows) input build set. set used part of mdx. not sure doable? t-sql ground, it's pretty doable in t-sql, how mdx? last week published mdx script injection projects on codepelx. https://mdxscriptinjection.codeplex.com/ the mdx script can updated or extended code without need deploy cube again. can useful when mdx script dynamically expand e.g. update cube side sets generate sets external data source sql querys or xml content create dynamic calucalate member update whole section in mdx script any feedback or proposalis welcome. not hesitate contact me. regards, marco

multithreading - In Android i want to run countdown timer who can run in background also -

hi friends developing 1 app in requirement run timer in background popular candy crush game actual requirement when open app first time in day want start countdown timer 24:00:00 after time suppose leave application , open other application during same time countdown timer must running never pause or never stop i visit 8,9 tutorial not getting exact result please me out kind of class may use or tutorial link please in advance you have 2 options: service , storing time of app launching. service killed system @ time, have save time on ondestroy method , when system relaunch service system call oncreate method need restore timer. second method easier. store current time on starting app , check differences. sample: @override protected void onresume() { super.onresume(); final sharedpreferences appprefs = getsharedpreferences("appprefs", mode_private); final long launchtime = appprefs.getlong("launchtime", 0); final long currenttim...

JSON node in jquery, Uncaught TypeError: Cannot read property '0' of undefined -

how read json nodes below jquery code, currently, getting "uncaught typeerror: cannot read property '0' of undefined" in firebug, please let me know doing wrong. jquery $(document).ready(function() { $('#search_btn_2').click(function(){ var queryvalue = $('#search_string_2').val(); $('.my-div').hide(); $.getjson( "${kb_endpoint_url}", { search_query : queryvalue } ) .done(function( data ) { console.log("success:"+queryvalue+":"+data); alert(data.docs[0].title); $('.my-div').html('<a href="'+data.docs[0].type+'">'+data.docs[0].title+'</a>'); }) .done(function() { console.log("second success"); }) .fail(function() { console.log("error"); }) .always(function() { console.log("finished"); $('.my-div').show(); }); }); }); json { "resp...

javascript - continue looping after alert message -

below function use check session of page. page reload after clicked alert message. var timeleft = 60; function checktime() { timeleft--; if (timeleft == 30 ) { alert("30 secs left."); window.location.reload(); } } is there anyway timeleft continue minus (if user din't not notice alert message) redirect logout page when timeleft = 0. alert() modal, stops javascript execution. check code: var start = new date(); var start2; window.settimeout(function() { var end = new date(); var result = "time start: " + (end.gettime() - start.gettime()) result += "\ntime alert: " + (end.gettime() - start2.gettime()) result += "\nalert open for: " + (start2.gettime() - start.gettime()) alert(result); }, 500); window.settimeout(function() { alert("hello"); start2 = new date(); }, 100); fiddle upper code: http://jsfiddle.net/aorcsik/vfeh2/1/ check out code, shows se...

design patterns - Go - why do scheduling goroutine background workers also requires its own goroutine? -

Image
i'm working on picking few of concurrency patterns of go. looked @ implementing background workers using goroutines , input/output channels, , noticed when sending new jobs receiving channel (essentially enqueuing new jobs) have in goroutine or scheduling gets messed up. meaning: this crashes: for _, jobdata := range(dataset) { input <- jobdata } this works: go func() { _, jobdata := range(dataset) { input <- jobdata } }() for more concrete, played nonsense code ( here in go playground ): package main import ( "log" "runtime" ) func dowork(data int) (result int) { // ... 'heavy' computation result = data * data return } // processing of input , return // results on output channel func worker(input, output chan int) { data := range input { output <- dowork(data) } } func scheduleworkers() { input, output := make(chan int), make(chan int) := 0 ; < runtime.numc...

c# - how to return json error msg in asp.net web api? -

i return json errormessage @ moment in fiddler cannot see in json panel: string error = "an error happened"; jsonresult jsonresult = new jsonresult { data = error, jsonrequestbehavior = jsonrequestbehavior.allowget }; response = request.createresponse(httpstatuscode.badrequest, jsonresult.data); how this? a few points: if you're looking return error response containing simple error message, web api provides createerrorresponse method that. can do: return request.createerrorresponse(httpstatuscode.badrequest, "an error happened"); this result in following http response (other headers omitted brevity): http/1.1 400 bad request content-type: application/json; charset=utf-8 content-length: 36 {"message":"an error happened"} if want return custom object instead, use request.createresponse doing, don't use mvc jsonresult . instead, pass object directly createresponse ...

rational team concert - Utilizing RTC Dashboard -

Image
i'm wondering if rtc dashboard provides closed set of predefined charts? know if can utilize , create kind of charts need, given source of data? couldn't answer after reading rtc website thank you i'm wondering if rtc dashboard provides closed set of predefined charts? yes, there widgets done displaying charts, can see in example : you can add many widget want. to create own chart or widget, can follow " how create dashboard viewlets in rational team concert ".

php - How to get ip address of client connected to remote desktop -

i need retrieve ip address of client connected through remote desktop windows server. i need possibly through php. so client connects remote desktop , run browser php page on server client connected. if run print_r($_server) get: array ( ... [http_host] => 10.80.3.107 //this server ip ... [server_name] => 10.80.3.107 //this server ip [server_addr] => 10.80.3.107 //this server ip [server_port] => 80 [remote_addr] => 10.80.3.107 //this server ip -> need client ip here ... ) is there solution? can use cmd info , take php using exec? i can't use netstat -n | find ":3389" | find "established" because gives me client connected , not 1 need. thanks! this can achieve using $_server['remote_addr'] or $_server['remote_host'] variables of php. the below both functions equivalent difference in how , values retrieved. in first function have used getenv() used value of environment variable in php // functi...

javascript - Callback after ForEach (with async function inside) is done -

i have .foreach loop async function inside of , code executing callback() before loop finished. there way make finish loop , move on callback(). here code: var transactions = []; t.transactions.foreach(function(id){ client.query('select * transactions id = $1;', [id], function(err, result) { if(!err){ transactions.push({from : result.rows[0].from, : result.rows[0].to, amount : result.rows[0].amount, time : result.rows[0].ct, message : result.rows[0].message, id : result.rows[0].id}); } }); }); callback(transactions); return done(); use index parameter of foreach test if you're on last transaction: var transactions = []; t.transactions.foreach(function(id, idx){ client.query('select * transactions id = $1;', [id], function(err, result) { if(!err){ transactions.push({from : result.rows[0].from, : result.rows[0].to, amount : result.rows[0].amount, time : result.rows[0].ct, message : resul...

android - Loading an XML file from SD card in jQuery Function -

i trying read xml sd card in jquery function .. html file loaded in webview of android device...here trying <script type="text/javascript"> $(document).ready(function(){ $("#dvcontent").append("<ul></ul>"); $.ajax({ type: "get", url: "file:///mnt/sdcard/reginfo/output/data.xml", datatype: "xml", success: function(xml){ $(xml).find('book').each(function(){ var sname = $(this).find('name').text(); var semail = $(this).find('email').text(); $("<li></li>").html(sname + "-" + semail).appendto("#list"); }); }, error: function() { alert("an error occurred while processing xml file."); } }); }); </script> there wrong file url not being able figure out problem... code working fine desktop browser . . . , not using phonegap.js or cordova.js

c# - Excel add-in on startup -

i creating add in microsoft excel using visual c#. when first created solution, included function called thisaddin_startup. added following code function: private void thisaddin_startup(object sender, system.eventargs e) { messagebox.show("startup"); } the message box not show upon installing add in , starting microsoft excel. indeed, nothing in function works when add in loads. literally change i've made new project after first creating it. why won't work? nothing magic , thisaddin_startup called before executing messagebox.show instruction. you can use "find references" in visual studio, bring thisaddin.internalstartup() , private method in thisaddin.cs . this method called framework's runtime. did explanation help?

html - change type password style to none with angular -

i have doubt, i'd put in application check box, show or hide text of password's input html <input type="text" ng-model="data.username" placeholder="username" value="username" class="form-control" popover="inserisci qui il tuo username" popover-trigger="focus" popover-placement="right"/><br> <input id="pwd" type="password" ng-model="data.password" placeholder="password" value="password" class="form-control" popover="inserisci qua la tua password" popover-trigger="focus" popover-placement="right"/><br> <input class="btn-primary btn-lg" type="submit" value="login"> <button class="btn-warning btn-lg" type="button" ng-click="cancel()">cancella</button> <input ng-model="show" type="checkbox...

vb.net - Time Span not working properly -

i'm working on download eta calculator..so use timespan code tell eta..the timespan code in visual basic not working should be... because when ever type file size , speed i.e 1gb , 1 mb/s, time span label1.text 5.17:00:00. here code public class form1 private property z object private sub linklabel1_linkclicked(sender object, e linklabellinkclickedeventargs) handles linklabel1.linkclicked process.start("www.speedtest.net") end sub private sub button1_click(sender object, e eventargs) handles button1.click dim x, y, z, a, b, c single x = textbox1.text y = textbox2.text if radiobutton1.checked = true , radiobutton3.checked = true label4.text = "minutes" z = x * 1024 c = y / 8 = z / c label1.text = new timespan(a / 60, 0, 0).tostring() end if if radiobutton1.checked = true , radiobutton4.checked = true label4.text = "minutes" z = x * 1024 c = 1024 / 8 /...

jquery - jQM1.4 - enhanceWithin() over-riding data-role="none". Why? -

i'm dynamically injecting data running search on string , inserting links linking glossary, this: return '<a href="#glossary" data-role="none" class="glossarylink" data-transition="slide">' + match + '</a>'; the returned string appended append() div. this works fine, usually. because lot of text , page elements dynamically injected have call enhancewithin() on div in order jqm widgets work (like collapsibles). enhancewithin() giving glossary links classes, don't want. these classes inherited (it seems) , making text buttons , list items , on. want control of how tried data-role="none" , doesn't work. can help?

ios - Mjpeg broken on recent Mobile Safari? -

i playing live mjpeg streams ip cameras , found support mjpeg seems broken on recent mobile safari releases. i using simple html test page embedded image follows: <img src="http://[ip_address]/[path]"> this works fine on iphone 4s ios 5.1, doesn't show on ipad ios 7.0.3. can confirm this? known workarounds? mjpeg support on iphone (and on osx also) has been broken in past, , can confirm right i'm having same problem mjpeg streams on iphone 5, version 7.0.4. you can find threads talking problem in apple website, dating mid 2013 , few recent answers, 1 https://discussions.apple.com/message/22933450#22933450 this 1 posts possible solution, if can control stream: https://discussions.apple.com/thread/4347848 i have not tried if solution works, because can't change stream itself. and problem on osx lion : https://discussions.apple.com/message/19028348#19028348 they has been fixed in osx, , bug reports has been filed ios, can't fi...

.htaccess - Wordpress installation in my app/webroot/blog folder of CakePHP -

i have wordpress installation in app/webroot/blog folder of cakephp, access www.example.com/blog/, when enter article loose link, example www.example.com/blog/app/webroot/blog/?p=1 is there solution fix that? think should modify wordpress .htaccess don't know add. my wordpress .htaccess file is: <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule> my cakephp app/.htaccess is <ifmodule mod_rewrite.c> rewriteengine on rewriterule ^$ webroot/ [l] rewriterule (.*) webroot/$1 [l] </ifmodule> and cakephp app/webroot/.htaccess is <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] </ifmodule> cheers the way did put wordpress folder inside root, , call /blog. note isn't going...

objective c - I need perticular regular expression for my data check -

i new in regular expression. have allow users input type of data. the string must start w or w. the string must have minimum 2 "/". the string must have character or number after /. after second / there should minimum 1 number. please me out. stucking 2-3 hours. how about: ^(?i)w[a-z0-9]*(?:/[a-z0-9]+)+/(?=.*\d+)[a-z0-9]*$ if want digits after last slash: ^(?i)w[a-z0-9]*(?:/[a-z0-9]+)+/\d+$

objective c - Show/Hide Password Toggle. Bug or Feature? -

i'm developing ipad application using xcode , objective-c. have ui includes password entry field , show/hide button (code shown below). tester has pointed out following inconsistent behaviour. if password hidden , half typed in (e.g. "abc") , user hits toggle button show password , continues typing new characters (e.g. "def") added end of initial entry (making "abcdef"). , good. however, if password shown , half typed in (e.g. "abc") , user hits toggle button hide password , continues typing new characters (e.g. "def") replace initial entry (making "def"). show/hide toggle not shows or hides text changes behaviour of uitextfield (append / clear , start over) when next character entered. i can think of (not good) reasons why behaviour design, no 1 i've shown thinks good. can suggest quick fix (that prevents toggle hide text action clearing part entered password)? - (ibaction)togglepasswordreveal:(id)sen...

highcharts - Remove padding above bar columns -

we have bar chart columns not reach top of graph container. how can remove that? { data: { chart: { type: 'column', plotbackgroundcolor: null, plotborderwidth: null, plotshadow: false, margin: [0, 0, 0, 0], backgroundcolor:'rgba(255,255,255,0.002)' }, colors: tallpoppies.templatecolours, legend: { enabled: false }, title: null, plotoptions: { series: { animation: false }, column: { cursor: 'pointer', datalabels: { enabled: false }, grouppadding: 0, pointpadding: 0.1, bordercolor: 'pink' } }, series: [{ type: 'column', name: 'skill', data: [ { name:'blah 1', color: 'red', y: 2 }, { name:'blah 2', ...

asp.net - Why does using <%=ConfigurationManager.AppSettings("MySetting")%> cause href attribute not to render in asp:HyperLink? -

i trying bind hyperlink control's navigateurl property in markup using server tag so: <asp:hyperlink id="lnkhelp" runat="server" navigateurl='<%#configurationmanager.appsettings("helpurl")%>'>text</asp:hyperlink> the ide recognizes , intellisense, tag ends rendering without href attribute. i've discovered <%$ appsettings:helpurl%> , have started using this, don't intellisense it. that's not deal breaker, intellisense nice. that's question time, though, wanting know why using <%# %> causes href attribute not render. you should use this navigateurl='<%$ configurationsettings.appsettings["helpurl"] %>'

c - How to change python version in makefile - compiling Multicorn (PostgreSQL FDW extension) -

i'm trying install postgresql extension multicorn on centos 6.5. problem have though default version of python on centos 2.6 , multicorn requires 2.7 or 3.3. i'm trying compile multicorn using this tutorial , it's little dated , step python version changed doesn't work anymore: sed -i 's/^pyexec = python$/pyexec = python2.7/' makefile can me make above command work again, or show me how edit makefile change version of python? can call python version 2.7 in command line python2.7 . version 2.6 called python - apparently can't change without breaking centos. this makefile: module_big = multicorn objs = src/errors.o src/python.o src/query.o src/multicorn.o data = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql)) docs = $(wildcard doc/*.md) extension = multicorn extversion = $(shell grep default_version $(extension).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)...