Posts

Showing posts from July, 2014

jquery - Check whether form is submitted or not -

in webpage form there submit button (id = search) , predict button(id = predict). if user doesn't submit form, clicks predict button must alert form not submitted. how check whether form submitted or not in jquery. $(document).ready(function(){ $('#predict').click(function(){ if($('#search').submit()) { window.open("ouput.php"); } else { alert("please click search or upload button first \n\ , click predict "); } }); }); but alert box not appearing , if form not submitted ouput.php page opening. i don't know if understand correctly question , if you in page have form, when submit form script add class ok predict button. when click on predict button script chcks presence of ok class if scripts not find class alert message show up <!doctype html> <html> <head> <meta charset="utf-8"> <script sr

eclipse - Can't find the generated bulkloader.yaml -

i trying generate bulkloader.yaml file in way appcfg.py create_bulkloader_config --filename=bulkloader.yaml --url=http://your_app_id.appspot.com/_ah/remote_api but error file "/applications/googleappenginelauncher.app/contents/resources/googleappengine-default.bundle/contents/resources/google_appengine/google/appengine/tools/bulkloader.py", line 3839, in checkoutputfile raise fileexistserror('%s: output file exists' % filename) i can't manage find such file is consider using eclipse pydev on mac os through googleappenginelauncher couple of things: 1) missing --application=s~your_app_id tag 2) directory in when run this? if not sure run cd path/to/where/you/want/it 3) can try find using mac's spotlight, in case not sure saved.

javascript - Simplecart's paypal checkout currency -

why paypal checkout keep showing in usd? have manage change simplecart currency, , showing right currency when item in shelf have added cart. moment click on checkout button, paypal page show in usd currency. e.g rm10 $10 usd. simplecart.email = "my@email.com"; simplecart.checkoutto = paypal; simplecart.currency = myr; simplecart.taxrate = 0.02; i changed this, case dkk: return "rp&nbsp;"; case myr: return "rm"; case usd: case cad: case aud: case nzd: case hkd: case sgd: return "&#36;"; default: return ""; } }; me.currencystringforpaypalcheckout = function( value ){ if( me.currencysymbol() == "rm" ){ return "rm" + parsefloat( value ).tofixed(2); } else { return "" + parsefloat(value ).tofixed(2); } }; where did went

libgdx - JSON inherit properties -

i have json file describes style (colors etc...) of widgets. defines default style each widget, , add more styles. com.badlogic.gdx.scenes.scene2d.ui.label$labelstyle: { default: { font: default-font, fontcolor: white } }, i'd add style extends default, don't have copy values of default implementation. highlighted extends default: {bgcolor: green } 'highlighted' still has font properties default. is possible json? json notation part of equation. json grammer helps determine legal grammer. this legal json: { "default" : { "font": "default-font", "fontcolor": "white" } } so question of inheritance question of builder uses json setup properties of objects based on string. based on read in libgdx api not see way of doing want. not know intricacies of how objects built. i read on , edit answer later. edit: brief search did reveal standard serializer behaviour. expectancy object created

plot - how histogram in Gnuplot works -

Image
i try reproduce simple histogram gnuplot simple macro: reset n=9 #number of intervals width=1 #interval width hist(x,width)=width*floor(x/width) set terminal pngcairo size 800,500 enhanced font 'verdana,14' set output "test.png" set boxwidth width set style fill transparent solid 0.5 border #fillstyle set xrange [*:*] set yrange [0:2.] set xlabel "x" set ylabel "freq." plot "const.dat" u (hist($1,width)) smooth freq w boxes lc rgb "orange" notitle whit follow data: 1.1 1.1 1.1 1.1 1.1 1.1 1.1 1.1 now understand how hist(x,width) works in sense: hist(x,width)=width*floor(x/width) works every numbers taking width=1 , then: hist(1.1,1)=1*floor(1.1/1)=1 and on, right? now (hist($1,width)) take elements in columns , applay hist function everyone. and can able make follow plot macro above:! question: if use (hist($1,width)):(1.0) don't understand whit plots change elements stay in 1

C# random value from dictionary and tuple -

i have following code, , need random item contains string "region_1" dictionary. public static dictionary<int, tuple<string, int, currencytype>> itemarray = new dictionary<int, tuple<string, int, currencytype>>() { { 0xb3e, new tuple<string, int, currencytype>("region_1", 1500, currencytype.fame) } }; public static int generateitemid(string shopid) { var generateditem = itemarray.elementat(new random().next(0, itemarray.count)).key; } how select this? it's not possible efficiently... first create static random @ class level... prevent non-random behaviour if run query on short period of time... (it's seeded discrete clock) static random rnd = new random(); then: var item = itemarray.values .where(t => t.item1 == shopid) .orderby(_ => rnd.next()) .firstordefault()

user interface - Quintus JavaScript Programming GUI -

in simple javascript/html 5 game have believe update error don't know how fix. thing there no real error, not responding code how wanted to. problem is, want on screen gui displays number of enemies killed on map. far have gui there. here picture of game: http://i.stack.imgur.com/0rx4d.png [this shows 3 enemies on screen, gui in top right corner, , player.] now problem whenever kill enemy number should raise, of course doesn't. here code: window.addeventlistener("load",function() { var ekl1 = 0; // enemies killed level 1 var q = window.q = quintus() .include("sprites, scenes, input, 2d, anim, touch, ui, tmx") .setup({ maximize: true }) .controls().touch() q.sprite.extend("player",{ init: function(p){ this._super(p, { sprite: "player", sheet: "player", speed: 150, x: 410, y: 90 }); this.add('2d, platformercontrols, animation'); },

performance testing - How to check which javascript loads and preforms quicker -

i have written in javascript 2 different ways hover on links , have background of window change color, 1 using event delegation , 1 not. how check option best performance wise (probably checking in browser developer tools)? from reading conventions have learned event delegation way go code seems less clear , readable want check if perform better. in chrome developer tools can use timeline section , create recording of these events , time how long take.

c# - Suspending event not raising using WinRT -

Image
i'm having problem suspending event on windows phone 8.1 using winrt, not fire. don't know why. code: /// <summary> /// initializes singleton application object. first line of authored code /// executed, , such logical equivalent of main() or winmain(). /// </summary> public app() { initializecomponent(); suspending += onsuspending; #if debug this.displayrequest = new displayrequest(); #endif } /// <summary> /// invoked when application execution being suspended. application state saved /// without knowing whether application terminated or resumed contents /// of memory still intact. /// </summary> /// <param name="sender"> /// source of suspend request. /// </param> /// <param name="e"> /// details suspend request. /// </param> private void onsuspending(object sender, suspendingeventargs e) { var deferral = e.suspendingoperation.getdeferral(); deferral.complete(); } i set breakpoi

java - Create Timeline android app -

Image
i'm creating android app , i'd include timeline 1 in facebook it'll have vertical scrollbar view whole timeline events till end here sample photo made i know android basics, , i've made simple apps before i'm missing way mix graphical line texts, , extend line till bottom of layout. thanks in advance :) you're going need old fashioned way- custom view , draw canvas drawtext , drawline commands.

amazon ec2 - Elasticsearch fails to start -

i'm trying implement 2 node es cluster using amazon ec2 instances. after setup , try start es, fails start. below config files: /etc/elasticsearch/elasticsearch.yml - http://pastebin.com/3q1qnqmz /etc/init.d/elasticsearch - http://pastebin.com/f3ajyurr below /var/log/elasticsearch/es-cluster.log content - [2014-06-08 07:06:01,761][warn ][common.jna ] unknown mlockall error 0 [2014-06-08 07:06:02,095][info ][node ] [logstash] version[0.90.13], pid[29666], build[249c9c5/2014-03-25t15:27:12z] [2014-06-08 07:06:02,095][info ][node ] [logstash] initializing ... [2014-06-08 07:06:02,108][info ][plugins ] [logstash] loaded [], sites [] [2014-06-08 07:06:07,504][info ][node ] [logstash] initialized [2014-06-08 07:06:07,510][info ][node ] [logstash] starting ... [2014-06-08 07:06:07,646][info ][transport ] [logstash] bound_address {inet[/0:0:0:0:0:0:0:0:9

php - Assigning variable value in dropdown list in table -

i have list of materials drop down in each row of table (100 rows). want selectively assign row selected material. for example, suppose $materialoptions assigned array (1=>'material 1', 2=>'material 2',3=>'material 3'). list of dropdown in each row. i want assign in php say, in row 20, material selected 'material 2'. below implementation. not able assign properly. html/smarty code <form name='materialsel' id='materialsel' method='post' action=''> <table> {section name=counter start=1 loop=100 step=1} <tr> <td><select name="materialid_{$smarty.section.counter.index}" id="materialid_{$smarty.section.counter.index}" onchange='return document.forms.materialsel.submit();'><option value='0'>select material</option> {html_options selected=$material_$smarty.section.counter.index options=$materialoptions} </select>

Loading Distance package not responding in Julia -

in julia studio 0.4.4 on mac os x 10.9, unable load distance package. when run: julia> using distance julia studio terminal not respond, never goes prompt. have tried reinstall package remove ~/.julia folder , problem persists. julia> pkg.status() required packages: - dataframes 0.4.3 - distance 0.2.6 - ijulia 0.1.11 55b60c47 (dirty) - rdatasets 0.1.1 additional packages: - bindeps 0.2.12 - blocks 0.0.4 - dataarrays 0.0.3 - gzip 0.2.12 - homebrew 0.0.6 - json 0.3.5 - nettle 0.1.3 - numericextensions 0.3.6 - replcompletions 0.0.1 - sortingalgorithms 0.0.1 - statsbase 0.3.8 - uriparser 0.0.2 - zmq 0.1.1

entity framework - Compare the value of 2 rows in 1 query -

i have table structure this: userid int login_date datetime logout_date datetime login_status varchar(10) the requirement retrieve top 2 rows particular userid sorted login_date asc. compare 2 login_date records , check if less 5 minutes. can done in single linq statement? thanks parameswaran something should work (untested) bool isrecentlogin = db.users .orderby(u => u.login_date) .take(2) .all(u => u.login_date.addminutes(5) < datetime.now);

database - MariaDB vs MySQL documentation -

in trying learn bit more mariadb find documentation somwehat lacking compared mysql. instance coverage on mariadb partitioning not seem complete, far background explanation goes. i'm bit concerned mysql , mariadb diverge in terms of functionality on time should need refer products's documentation see how mariadb works. if mariadb documentation lacking, what's next best option? mariadb fork of mysql predates acquisition of mysql oracle. since acquisition, number of key developers, including founder of mysql, monty wedenius, have joined mariadb giving considerable impetus. you can find documentation mariadb on official doc site . as can join freenode irc #maria or can try books: mariadb cookbook getting started mariadb

c# - Change button color for a short time -

i change backgroundcolor of button couple of seconds lime , change normal. reason doesnt work, have wait seconds , things tested work backgroundcolor isn't changed. i've tried far: private void button1_click(object sender, eventargs e) { button1.backcolor = color.lime; thread.sleep(2000); button1.backcolor = systemcolors.control; } hopefully can me out this! you need timer. add timer control toolbox form. double-click on add timer tick event handler private void button1_click(object sender, eventargs e) { button1.backcolor = color.lime; //set time between ticks in miliseconds. timer1.tick=2000; //start timer, program continues execution normaly timer1.start; //if use sleep(2000) program stop working 2 seconds. } //this event rise every time set in tick (from start stop) private void timer1_tick(object sender, eventargs e) { //when execution reach here, m

javascript - jQuery Datetimepicker XDsoft: How do I get value from inline calendar? -

i use jquery datetimepicker plugin xdsoft: http://xdsoft.net/jqplugins/datetimepicker/ i have calender displayed inline. here comes code: html: <input type="text" id="start_date"> js: jquery('#start_date').datetimepicker({ format:'d.m.y h:i', inline:true }); my problem: when pick date in frontend, input field not selected date value. changes need make or need add? use date time picker event . html <input type="hidden" id="start_date"> js var $startdate = $('#start_date'); $startdate.datetimepicker({ inline:true, sidebyside: true }); $startdate.on('dp.change', function() { var selecteddate = $(this).val(); alert(selecteddate); }); js fiddle demo

ruby on rails - Transform hash result of multiple group result set -

this output of product.group([:name, :category]).order([:name, :category]).count : { ["product a", "category 2"]=>42, ["product a", "category 3"]=>83, ["product a", "category 4"]=>47, ["product b", "category 2"]=>1, ["product b", "category 3"]=>4, ["product b", "category 4"]=>10, ["product c", "category 3"]=>2, ["product c", "category 4"]=>4, ["product d", "category 1"]=>6, ["product d", "category 2"]=>13, ["product d", "category 3"]=>57, ["product d", "category 4"]=>27 } each product can of categories 1-4. need have count of 0's final transformation. desired transformation array columns: product name, count of category 1, count of category 2, count of category 3 , count of cat

entity framework - How to correct issue with creating Web API 2 OData Controller with Actions using EF code-gen template with VS 2013? -

i have couple of dev environments. in older vs 2013 ultimate, can execute web api 2 odata controller actions using entity framework template code create classes. the second visual studio 2013 ultimate update 2 rc. can create other classes, in trying create aforementioned, following error: microsoft visual studio error there error running selected code generator: 'exception has been thrown target of invocation.' since have installed other components, reset settings through tools / import export settings / reset settings. i uninstalled/re-installed - same issue on fronts. in both environments code same, connection same db. i have tried using code templates folder working env in newer env - no go. i tried removing update 2 rc through windows / installed updates, request rejected, indicating vs requires update run. suggestions?

Returning a true value instead of integer value in prolog -

i have simple function below takes 2 lists ( same size) , variable stores result. my intention compare first list's head second 1 , increase result one, , return it. but instead true / false . myfunction( [], [], 0). myfunction([h1|t1], [h2|t2], n) :- h1 > h2 -> myfunction(t1, t2, n1 + 1); myfunction(t1, t2, n1), n n1 . you're treating prolog imperative/procedural language, doesn't work way. should read through prolog tutorials and/or books. in prolog, define predicate defines relation. when define predicate variables, saying that, these variables related in such , such way if... . if prolog succeeds in verifying relation true, predicate response "true" or "yes". otherwise, responds "false" or "no". here's rework of you're trying do: my_predicate([], [], 0). this relation "base case" , says the count of cases corresponding values in first list greater second when lists empt

jmenubar - How can I create title bar menu in Java -

Image
i wanna create simple application java. designed main template in head have kind of design problem. i using jmenubar , jmenu. works fine it's location not want. in ubuntu, use eclipse , has menu in titlebar: as can see , menus @ top.(file,edit,source,etc..) however, application not same. here application. jmenu working fine in title bar there no menu. what can create menus ? are there component ? thank you. best regards. Ömer. you may interested jayatana project

Python - Exception seems to be skipping out of with block -

this question has answer here: why contextmanager-function not work contextmanager class in python? 1 answer here relevant pieces of code: @contextlib.contextmanager def make_temp_dir(): temp_dir = tempfile.mkdtemp() yield temp_dir shutil.rmtree(temp_dir) make_temp_dir(listing_id) tmpdir: pass # in here throws exception gets caught higher ok, writing out, understand what's happening. exit method in contextmanager i'm creating decorator is running doesn't, of course, return flow generator. so how should doing this? what happens here following: on __enter__() , generator started. yields taken return value of __enter__() . on __exit__() , generator resumed, either in normal way or injecting exception. relevant code in $pythonroot/contextlib.py can see either next() or throw() called on gener

php - Merging multiple images creates broken image -

so i'm attempting create array of names, take image associated name, , merge them together. code below seems return broken image. <?php header('content-type: image/png'); $startlink = file_get_contents("http://websiteforimage.com/1/img.png"); $start = imagecreatefromstring($startlink); $name = array("2", "3", "4", "5", "6"); foreach($name $value){ $link = "http://websiteforimage.com/" . $value . "/img.png"; $img = imagecreatefrompng($link); $offset = imagesx($start) + imagesx($img); imagecopymerge($start, $img, $offset, 0, 64, 64, 64, 64, 100); } imagepng($start); ?> any clue on how can fixed? my initial thoughts imagecopymerge() function. don't state how you're merging them i'm going assume it's left right? in case, co-ordinates seem wrong $start - sure, that's first image $img - yes, that's new image attach $offset - make

typeclass - Coq: unfolding class instances -

how unfold class instances in coq? seems possible when instance doesn't include proof, or something. consider this: class c1 (t:type) := {v1:t}. class c2 (t:type) := {v2:t;c2:v2=v2}. instance c1_nat: c1 nat:= {v1:=4}. instance c2_nat: c2 nat:= {v2:=4}. trivial. qed. theorem thm1 : v1=4. unfold v1. unfold c1_nat. trivial. qed. theorem thm2 : v2=4. unfold v2. unfold c2_nat. trivial. qed. thm1 proved, can't prove thm2 ; complains @ unfold c2_nat step error: cannot coerce c2_nat evaluable reference. . what's going on? how c2_nat 's definition of v2 ? you ended definition of c2_nat qed . definitions ending qed opaque , cannot unfolded. write following instead instance c2_nat: c2 nat:= {v2:=4}. trivial. defined. and proof finishes without problems.

python - Why is HttpCacheMiddleware disabled in scrapyd? -

why httpcachedmiddleware need scrapy.cfg , how work around issue? i use scrapyd-deploy build egg, , deploy project scrapyd. when job run, see log output httpcachemiddleware disabled because scrapy.cfg not found. 2014-06-08 18:55:51-0700 [scrapy] warning: disabled httpcachemiddleware: unable find scrapy.cfg file infer project data dir i check egg file , scrapy.cfg indeed not there because egg file consists of files in project directory. wrong, think egg built correctly. foo/ |- project/ | |- __init__.py | |- settings.py | |- spiders/ | |- ... |- scrapy.cfg digging code more, think 1 of 3 if-condition failing somehow in middlewaremanager. try: mwcls = load_object(clspath) if crawler , hasattr(mwcls, 'from_crawler'): mw = mwcls.from_crawler(crawler) elif hasattr(mwcls, 'from_settings'): mw = mwcls.from_settings(settings) else:

iis - How do I connect a device to SQL server through a network? -

Image
i have laptop sql server , compact server agent , iis running. i'd connect mobile device laptop on same network , able access sql server. how go this? know it's possible iis , rda, i'm getting following error: error code: 80072eff message: request send data computer running iis has failed. more information, see hresult. minor err.: 28037 source: microsoft sql server compact make sure accounting internet proxy. had similar problem , unchecked proxy settings in internet options, error message went away.

asp.net - How to Show Captcha images for repeated requests -

in project, avoid spammers , other security issues, have show captcha image repeated requests same ip address. is, if multiple requests same ip address, captcha should shown check user.. so, task, if 10 requests within 5 seconds same ip, captcha should enabled ip address... any suggestion highly appreciated.. split task steps, , try think around each step. if 10 requests within 5 seconds same ip, 1) need identify you're under attack. e.g. see block dos attacks in asp.net then captcha should enabled ip address... 2) need show captcha. e.g. using captcha prevent bots using asp.net web razor) site 3) need save "validated" ip "white" list.

installation - Install Liferay as Windows 2012R2 service -

Image
i newbie on liferay , furthermore 100% windows infrastructure knowledge based. installed liferay 6.2 on windows 2012r2 server java jdk-8u5 version. running perfect long logged in user on server via remotedesktop having open tomcat startup.bat window. have start liferay and/or tomcat service? thanks in advance efforts. configuring liferay or tomcat run service on windows server doesn't differ much.so in order have add files liferay_home\tomcat\bin directory. to files have download full version of 64-bitwindows tomcat here : http://tomcat.apache.org/download-70.cgi . extract zip , go bin directory, copy service.bat , tomcat7.exe , tomcat7w.exe location : liferay_home\tomcat\bin setting service open commad prompt (make sure have admin rights or run command prompt administrator),in command prompt go liferay_home\tomcat\bin , execute following command service.bat install tomcat7 this install tomcat6 service in windows. execute following commond setup

java - Count characters in specific line -

i reading file , check number of lines, characters , longest line , want know number of characters in second line of file. how can it? scanner input = new scanner(new filereader("c:/.../mrr569.fasta")); int lines = 0; int characters = 0; int maxcharacters = 0; string longestline = ""; while (input.hasnextline()) { string line = input.nextline(); lines++; characters += line.length(); if (maxcharacters < line.length()) { maxcharacters = line.length(); longestline = line; } } system.out.println(lines); system.out.println(characters); system.out.println(longestline); you need keep track of line on. create variable lineno . int lineno=1; you need store number of characters in second line: int charsinsecondline=0; and @ end of while loop increment variable: lineno++; then in while loop (before increment) add if statement checks if second

gcc - Android command-line executable: Segmentation fault -

i try compile do-nothing program , segmentation fault. exe1.c: int main() { return 12; } android.mk: local_path := $(call my-dir) include $(clear_vars) local_module := exe1 local_src_files := exe1.c #local_cflags += -save-temps #local_ldlibs := -llog include $(build_executable) and get: root@android:/ # exe1 [1] + stopped (signal) exe1 root@android:/ # [1] + segmentation fault exe1 root@android:/ # (the console output evidently bit buggy, 2nd line not shown after executed command.) how make work? (i need @ least hello-word functionality.) update: root@android:/ # strace exe1 execve("/system/bin/exe1", ["exe1"], [/* 22 vars */]) = 0 (udpate2: oops! looks strace not work @ all!)

browser - SharePoint 2013: hover on search result automatically starts downloading document -

i have configured search results webpart show documents based on search keywords. as hover on of search result item, automatically triggers download , asks weather save document or open directly. this issue coming on ie. i have come find root cause of problem not solution(will update when solution). as intranet portal, ie has default security settings medium-low(it medium internet sites). under medium-low security settings allow active-x filtering disabled. enabling solved issue. ps: can settings clicking on tools->internet options->security->local intranet.

c# - Entity Framework COUNT is doing a SELECT of all records -

profiling code because taking long time execute, generating select instead of count , there 20,000 records very slow. this code: var catviewmodel= new catviewmodel(); var catcontext = new catentities(); var cataccount = catcontext.account.single(c => c.accountid == accountid); catviewmodel.numberofcats = cataccount.cats.count(); it straightforward stuff, code profiler showing is: exec sp_executesql n'select [extent1].xxxxx yyyyy, [extent1].xxxxx yyyyy, [extent1].xxxxx yyyyy, [extent1].xxxxx yyyyy // idea [dbo].[cats] [extent1] cats.[accountid] = @entitykeyvalue1',n'@entitykeyvalue1 int',@entitykeyvalue1=7 i've never seen behaviour before, ideas? edit: fixed if instead: catviewmodel.numberofrecords = catcontext.cats.where(c => c.accountid == accountid).count(); i'd still know why former didn't work though. so have 2 separate queries going on here , think can explain why different results. let's @ first one // pu

ios - How to integrate Cocoapods with a Swift project? -

as apple introduced swift , new programming language, wonder how can integrate existing objective-c libraries available via cocoapods ? cocoapods 0.36 , above introduces use_frameworks! instruction implies bridging header not required importing objective-c pods in swift. please find below full example using mbprogresshud , alamofire : 1. podfile source 'https://github.com/cocoapods/specs.git' platform :ios, '8.3' use_frameworks! pod 'alamofire', '>= 1.2.2' # swift pod pod 'mbprogresshud', '>= 0.9.1' # objective-c pod 2. deletion remove #imports bridging header or delete bridging header file if not need it. if choose latter possibility, not forget delete path (to deleted bridging header file) in xcode project configuration. 3. adding imports add import mbprogresshud and/or import alamofire @ top of every swift files need these class(es). 4. fix enums if necessary you're using bona fide framewo

java - Why does Android draw View inside another (with width and height defined in pixels) in incorrect way? -

Image
i wondering in way android draws views on screen inside layout views defined android:layout_width , android:layout_height values in pixels. i using android class view extends android.view.surfaceview . mjpegview display mjpeg stream camera on android app. working code (with small changes): android ics , mjpeg using asynctask this mjpegview class placed inside relativelayout . mjpegview object added programmatically , relativelayout has attributes defined in way: android:layout_width="800px" android:layout_height="600px" this size values necessary application can't change them. application working in landscape orientation. mjpegview need set 320 x 240 pixels size inside relativelayout (800 x 600 px) . application enlarges realtivelayout fill screen on current device. , problem connected streaming mjpeg. working on nexus 7 (2012 version), has 1280 x 800 resolution. to real size of view inside layout have measured height of nexus 7 screen w

mysql - Table name of "Static blocks" and "Cms pages" in database magento? -

i need export database of static blocks , cms pages of magento, dont know whats extactly table name of database, hope can me this, patience, regards , vibes! for static block cms_block , cms page cms_page . for import , export cms page , static blocks can use free extension http://www.magentocommerce.com/magento-connect/enhanced-cms-pages-static-block-importer.html let me know if have query

php - Increase CPU Usage Of Gearman Worker Over Time -

i running gearman worker distribute background jobs multiple workers. monitor background jobs , restaart upon crash, using supervisord process management system. the gearman worker code pretty simple official example: $worker = new gearmanworker(); $worker->addserver($config["gearman.host"],$config["gearman.port"]); $worker->addfunction("config_job", "run_config_job"); while ($worker->work()); for workers, expecting, during job execution cpu usage high, after completion if become low during waiting time. interestingly, long running processes, contains increased cpu usage on time. does has idea main reason behind incremental cpu usage on time is? also, tasks run on aws ec2 small instances, how many workers can run in parallel in single workers-only instance on average? php not particularly designed use case, may prudent restart workers on regular interval. if not cleaning after each job, may running memory leak.

javascript - AngularJS : Bind to transclusive directive without isolating the scope -

let's have angular markup like: <custom bindto="modelproperty"> <!-- trascluded content. --> </custom> would possible custom directive bind using bindto attribute, allowing properties accessible transcluded content, without isolating scope of custom? basically, want directive bind custom part of model without cutting off scopes of parents , without having add code like: scope.prop = scope.$parent.prop; any ideas? edit imagine structured http://plnkr.co/edit/zq2oo1?p=preview , except working , without isolate scope. by using scope: true can maintain access parent scope's properties via prototypical inheritance while maintaining unique scopes each instance of directive (ie. reusable). (note: make sure observe the dot rule models need change on parent scope within transcluded content) you'll need call transclude function compile function, passing directive's scope first argument in order link transcluded content

python - CUDA installation on ubuntu 12.04 -

cuda installation broke when installed python-pyopencl apt repository. have removed opencl , nvidia-current installed dependency , installed drivers nvidia. error when try run devicequery. the machine in question headless server, multiple cards. appreciate suggestions. just complete reinstall of cuda. don't use repositories. download appropriate cuda 6 ubuntu 12.04 linux installer (i.e. runfile) here and run it. use runfile installation method described here .

php - MySQL AUTO_INCREMENT according to year -

im creating ticketing system , table structure: create table tix_sip ( tktnum int unsigned not null, sipnum int unsigned auto_increment, primary key( sipnum ), foreign key(tktnum) references tix (tktnum) ); what happen sipnum numbered according year. example: 20140001, 20140002, ..20140334, 20140335.... how make change first 4 digits automatically everytime next year comes, create new\another set of auto_increment ed numbers example: 20150001, 20150002........ 20160001, 20160002.. btw, im using php code program, in case if solution creating function. thanks you can use mysql custom auto_increment values follows: (read article first) create table , trigger: create table test ( id int not null auto_increment primary key, year_autonum varchar(20) ); delimiter // drop trigger if exists custom_autonums_bi// create trigger custom_autonums_bi before insert on test each row begin set new.year_autonum = getnextcustomseq(year(now()),year(now())); end

Scala: Removing first 2 directories from a String -

i have string looks "./path1/path2/path3/path4/etc/file" i remove first 2 paths , return string looks this: "path3/path4/etc/file" how can using scala? how simple: s.split("/").drop(3).mkstring("/") in statement firstly split path / , next remove first 3 tokens (as first 1 . in case) , merge tokens create new path.

r - Arranging GGally plots with gridExtra? -

i'd arrange ggpairs plots arrangegrob : library(ggally) library(gridextra) df <- structure(list(var1 = 1:5, var2 = 4:8, var3 = 6:10), .names = c("var1", "var2", "var3"), row.names = c(na, -5l), class = "data.frame") p1 <- ggpairs(df, 1:3) p2 <- ggpairs(df, 1:2) p <- arrangegrob(p1, p2, ncol=2) which results in error: error in arrangegrob(p1, p2, ncol = 2) : input must grobs! is there way work around problem? unfortunately, cannot see how possible. first, it's not going work gridextra , since arrangegrob operates on tablegrob objects: > ggplotgrob(qplot(1:100)) stat_bin: binwidth defaulted range/30. use 'binwidth = x' adjust this. tablegrob (6 x 5) "layout": 8 grobs z cells name grob 1 0 (1-6,1-5) background rect[plot.background.rect.3349] 2 3 (3-3,3-3) axis-l absolutegrob[grid.absolutegrob.3341] 3 1 (4-4,3-3) spacer

hibernate does not return the correct values -

my problem this, mapped project classes in xml , shape objects hibernate automatically method (). question return data other rows not match ask this class mapping alimento <?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <!-- generated 29-may-2014 11:22:30 hibernate tools 3.4.0.cr1 --> <hibernate-mapping> <class name="innopckg.alimento" table="alimento"> <id name="id" type="int"> <column name="id_al" /> <generator class="identity" /> </id> <property name="nombre" type="java.lang.string" > <column name="nombre" unique="true"/> </property> <set name="compuestos" table="compues

c++ - I want to overload "=" operator to assign value from an object to a non class int variable -

this question has answer here: how overload operators built-in return type? 4 answers int i; integer a; //a class object i=a; //here a's member variable value should assigned 'i' you can providing conversion operator class int : class integer { // ... stuff public: operator int() const { return member_to_assign; } };

java - Which manner of processing two repetative operations will be completed faster? -

generally speaking, there significant differance in processing speeds of these 2 example segments of code, , if so, should complete faster? assume "processa(int)" , "processb(int)" voids common both examples. for(int x=0;x<1000;x++){ processa(x); processb(x); } or for(int x=0;x<1000;x++){ processa(x); } for(int x=0;x<1000;x++){ processb(x); } i'm looking see if can speed 1 of programs , involves cycling through blocks of data several times , processing differant ways. currantly, runs seperate cycle each processing method, meaning lot of cycles run in total, each cycle little work. thinking rewriting code each cycle incorporates every processing method; in other words, fewer cycles, each cycle has heavier workload. this intensive rewrite of program stucture. unless give me significant performance boost, won't worth trouble. the first case faster second case because loop in , of has effect on performance. however

javascript - In sequences sunburst, how to give a child the same color of parent? -

what give child same colour of parent lighter, used following generate colour var color = d3.scale.category20b(); .style("fill", function(d) { return color((d.children ? d : d.parent).name); }) this code gives random colour each node. first image : random colour the next image need, code produce randomly. gradient colour i want make colour of child lighter colour of parent. sorry, put result images link because not have enough reputation. thank you this interesting one. bulk of work in setting colors , associated web page types. had weird issues when trying use d3.interpolatestring() , have shelved later investigation. in case, here preparation piece: var brewercolors = d3.entries(colorbrewer); // offsets 1-5 similar // offsets 6-13 offer greatest contrast // offsets 4 , above no var breweroffset = 9; var pagetypes = ["home","product","search","account","other","end"]; var colors = [];

php - Archive a .wdgt folder in ZipArchive() -

i'm creating online widget creation tool in php, , able export need via .zip , problem users have extract zip , add .wdgt extension on folder work in ibooks. there way make part of process easier, e.g - unzip , .wdgt folder there, or better, download .wdgt. here code have create zip file: //zip name $archivename = 'widget.zip'; $filenames = array(); //scan through directories, , add array foreach(scandir($workingdir) $content){ $filenames[] = $workingdir.$content; } foreach(scandir($resources) $content){ $filenames[] = $resources.$content; } archivefiles($filenames, $archivename); function archivefiles($filenames, $archivename){ //init new ziparchive() $zip = new ziparchive(); //open archive $zip->open($archivename); if($zip->open($archivename, ziparchive::overwrite ) !==true){ exit("cannot open <$archivename>\n"); } else{ //archive create, add files foreach($filenames

ticker - Paypal system configure in Fusion Ticket -

Image
how configure paypal system in fusion ticket. remain systems working in fusion ticket. payment: cash shipment: point of sale (it wokring) payment: invoice: please pay within 10 days or within 3 days of event if sooner shipment: email(it working) paypal (unable see option) in pos user. configured paypal in fusion ticket admin user. consulting google turned payment , shipment options , looks complete walkthrough.

python - Check the installation date of Windows XP -

is possible check, using python programming languque, time on operating system installed ? mainly, interested in windows xp platform. wonder if there such api in python or trick it. using windows registry: import _winreg reg datetime import datetime key = reg.openkey(reg.hkey_local_machine, r'software\microsoft\windows nt\currentversion') secs = reg.queryvalueex(key, 'installdate')[0] # stored unix timestamp date = datetime.fromtimestamp(secs)

javascript - autoreload webpage on new release -

i have website in php ajax-based. there index.php , part it, other pages never rendered directly browser. instead, post , requests done javascript through ajax. basically, if go /contact.php not see anything. pages rendered inside index.php . there lot of people use page not web-savvy , may not understand means when ask them refresh page. the biggest issue happens when new release. javascript code (but not only) can old 1 in client's webpage maybe haven't refreshed page weeks. i perform svn update publish new code server. refresh page , see new features. however, people don't know how refresh not see anything. have added big button on page text "refresh", executes location.reload . may people, not everyone. how can "force" browser reload when new version has been published? prefer simple not require additional libraries or timer. it quite important page not refresh when user doing page, may lose work when happens. i think can a

delphi - Why does the is operator fail to return what I expect when passed an instance from a different module? -

i work on delphi project interac many other small libraries. use fastmm4 , work complex classes passed on dll parameter. so exemple send form dll. dll test type of parameter operator "is". but dll operator "is" return "false" exemple library dll; uses fastmm4, system.sysutils, system.classes, vcl.dialogs, vcl.forms; {$r *.res} procedure complex(l : tobject);stdcall; begin if l tform showmessage('ok') else showmessage('pas ok') ; if l tcustomframe showmessage('ok') else showmessage('pas ok') end; exports complex; begin end. and call procedure tffsisoperator.button2click(sender: tobject); var madll : thandle; proc : procedure (l : tobject); begin try madll := loadlibrary(pchar('dll.dll')); @proc := getprocaddress(madll, 'complex'); proc(self); freelibrary(madll); end; end;

regex - How to make grep interpret a search expression ignoring all special characters -

i'd search html string contains characters interpreted grep special characters. there flag or command tell grep interpret characters in search string literal characters, not special characters? perfect world: grep --ignorespecial '<a href="/abc/def" class="foo.bar"/>' yes! use grep -f . from man grep : -f , --fixed-strings interpret pattern list of fixed strings, separated newlines, of matched. (-f specified posix.) test $ cat hello <a href="/abc/def" class="foo.bar"/>my href</a> <a href="/abc/def/ghi" class="foo.bar"/> $ grep -f '<a href="/abc/def" class="foo.bar"/>' <a href="/abc/def" class="foo.bar"/>my href</a> or more bash codes: $ cat hello <a href="/abc/def" class="foo.bar"/>my href</a> is/ $line ^codes * yeah $ grep 'this is/ $line ^codes

website - How to get user input in javascript -

how user input in javascript. becuase i'am making website input email puts input in text file. here code: <button type="button" onclick="var_name()">enter email</button> <script> function var_name() { email_1 = prompt("please enter email. thank you."); } </script> do have popup message box ?! suggest magnific popup jquery plugin in way wanna write code popup message form write div display [style] none , in js set display inherit remember position absolute , have black opacity 0.6 background fill webdesign.

login - No persistent user connection with django between 5 websites stored in the same server -

i have 5 django website on server. problem can't logged-in in every website @ same time, when login in website , click on site b : lose connection on a. can logged 1 site @ time. 4 sites works sqlite , 1 postgresql, every site has it's own folder. use django 1.4 , db session storage , mod wsgi. do know how can make user connection persistent can logged on websites @ same time ? don't know how solve issue, maybe it's problem database, or wsgi not configured. thanks. because using same domain websites must set session_cookie_path in each django website point top-level path website served from. can find more details here it's advisable set different session_cookie_name each website.

asp.net - Unable to cast object of type 'system.string' to type 'system.Byte[]' when trying to download a file from database -

i trying download file database giving me error called unable cast object of type 'system.string' type 'system.byte[]' on line : response.addheader("content-length", bytes.tostring()); please tell me how can cast string byte in case, thank in advance. i have column named salefilename want download file. aspx code: <asp:templatefield headertext="recieptname" sortexpression="recieptname"> <itemtemplate> <asp:linkbutton id="linkbutton1" runat="server" commandname="download" commandargument='<%# bind("salename") %>' text='<%# bind("salename") %>' ></asp:linkbutton> </itemtemplate> </asp:templatefield> code behind file: protected void gridcontributions_rowcommand(object sender, gridviewcom

java - Hibernate Criteria : Find property nested in a list -

im trying build using criteriabuilder following query : select * job j, asset a, asset_users au j.job_id = a.asset_id , a.asset_id = au.asset_id , au.user_id = 6 where job has asset , asset has list of users... want return list of jobs have asset contains given user... i saw guys doing : session session = this.sessionfactory.getcurrentsession(); criteria criteria = session.createcriteria(company.class); criterion = restrictions.eq("companyroles.name", "admin"); criteria.add(criterion); list<company> companylist = criteria.list(); tried replicate criteriabuilder got no luck. getting couldn't find user id inside object list (userlist). guess example harder because have access object (job).asset.userlist.id . btw, tried : criteriabuilder cb = em.getcriteriabuilder(); criteriaquery<job> cq = cb.createquery(job.class); root<job> jobroot = cq.from(job.class); join<job, user> assetjoin = jobroot.join("asset.userlist&quo

java - unable to open web service tester page with jdk8 and netbeans 8 -

i wrote simple web service program can not test on glassfish 4.0 web server . when test web service see message : make sure service has been deployed successfully, , server running. i can see in list of deployed web services on glassfish web server . , add file \jdk1.8.0\jre\lib fix problem. jaxp.properties javax.xml.accessexternalschema = all doesn't work also see error in url of tester page : linenumber: 52; columnnumber: 88; schema_reference: failed read schema document 'xjc.xsd', because 'bundle' access not allowed due restriction set accessexternalschema property. thanks in advance this answer : https://netbeans.org/kb/docs/websvc/jax-ws.html#extschema should configure ide , glassfish server directly . special pablo

python - cx_Oracle doesn't connect when using SID instead of service name on connection string -

i have connection string looks this con_str = "myuser/mypass@oracle.sub.example.com:1521/ora1" where ora1 sid of database. using information in sql developer works fine, meaning can connect , query without problems. however, if attempt connect oracle using string, fails. cx_oracle.connect(con_str) databaseerror: ora-12514: tns:listener not know of service requested in connect descriptor this connection string format works if ora1 service name, though. i have seen other questions seem have reverse of problem (it works sid, not service name) using oracle service names sqlalachemy oracle sid , service name; connection problems cx_oracle & connecting oracle db remotely what proper way connect oracle, using cx_oracle , using sid , not service name? how do without need adjust tnsnames.ora file? application distributed many users internally , making changes tnsnames file less ideal when dealing users without administrator privileges on