Saturday 15 August 2015

Map a Ruby array of timeseries values to a weighted interval -



Map a Ruby array of timeseries values to a weighted interval -

i have ruby array of arrays represents series of observations of metric that's recorded on time. each inner array has 2 elements:

a time instance in utc describing when observation recorded the integer value of observation

for example, might have like:

[ [<time: 2014-01-15 @ 18:00>, 100], [<time: 2014-01-16 @ 06:00>, 200], [<time: 2014-01-16 @ 12:00>, 300], [<time: 2014-01-16 @ 23:00>, 400], [<time: 2014-01-17 @ 12:00>, 500], [<time: 2014-01-18 @ 03:00>, 600], [<time: 2014-01-18 @ 06:00>, 700], ]

the problem @ hand turn array of weighted values each date:

[ [<date: 2014-01-15>, 100], [<date: 2014-01-16>, 229], ... ]

the value each day in above array obtained next procedure:

break day series of intervals delimited each observation , boundaries of day.

for example, since jan 16th has observations @ 06:00, 12:00, , 23:00, broken intervals of 00:00-06:00, 06:00-12:00, 12:00-23:00, , 23:00-00:00.

the value of each interval equal value of observation @ origin of interval, or lastly observation made if it's start of day.

for example, value of 06:00-12:00 interval on jan 16th 200, since value of 200 recorded @ 06:00.

the value of 00:00-06:00 interval on jan 15th 100, since value of 100 lastly observation recorded @ point day started.

the weighted value of each interval equal value multiplied fraction of lengths of intervals in day occupied.

for example, weighted value of 06:00-12:00 interval on jan 16th 50 (200 * 0.25).

the final weighted value of each day sum of weighted values of intervals, coerced integer.

for example, weighted value jan 16th 229, because:

(100*(6/24) + 200*(6/24) + 300*(11/24) + 400*(1/24)).to_i = 229

the first point in array special case: day starts there, rather @ 00:00, jan 15th has 1 interval: 18:00-00:00 value of 100, weighted value 100.

any suggestions on how started tackling this?

i've assumed there no days no entries.

i found convenient first transform array of time objects. rules used transformation follows (arb refers arbitrary value, may equal val):

for first day, replace single element [dt, val] 3 elements: [dt1, val], dt1 same date @ time 00:00:00 [dt2, arb], dt2 same date @ time 23:59:59 [dt3, val], dt3 1 day later @ time 00:00:00 for lastly day, if [dt, val] lastly element day, add together element [dt1, arb], dt same date @ time 23:59:59. for every day other first , last, if [dt, val] lastly element day, add together 2 elements: [dt1, arb], dt1 same date @ time 23:59:59 [dt2, val], dt2 1 day later @ time 00:00:00

suppose next initial array. clarity, i've used strings (allowing me replace "23:59:59" "24:00"):

arr = [ ["2014-01-15 18:00", 100], ["2014-01-16 06:00", 200], ["2014-01-16 12:00", 300], ["2014-01-16 23:00", 400], ["2014-01-17 12:00", 500], ["2014-01-18 03:00", 600], ["2014-01-18 06:00", 700] ]

after applying above rules, obtain:

arr1 = [ ["2014-01-15 00:00", 100], ["2014-01-15 24:00", 100], ["2014-01-16 00:00", 100], ["2014-01-16 06:00", 200], ["2014-01-16 12:00", 300], ["2014-01-16 23:00", 400], ["2014-01-16 24:00", 400], ["2014-01-17 00:00", 400], ["2014-01-17 12:00", 500], ["2014-01-17 24:00", 500], ["2014-01-18 00:00", 500], ["2014-01-18 03:00", 600], ["2014-01-18 06:00", 700], ["2014-01-18 24:00", 700] ]

or elements grouped date,

arr1 = [ ["2014-01-15 00:00", 100], ["2014-01-15 24:00", 100], ["2014-01-16 00:00", 100], ["2014-01-16 06:00", 200], ["2014-01-16 12:00", 300], ["2014-01-16 23:00", 400], ["2014-01-16 24:00", 400], ["2014-01-17 00:00", 400], ["2014-01-17 12:00", 500], ["2014-01-17 24:00", 500], ["2014-01-18 00:00", 500], ["2014-01-18 03:00", 600], ["2014-01-18 06:00", 700], ["2014-01-18 24:00", 700] ]

code implement these rules should straightforward. 1 time have arr1, create enumerator enumerable#chunk:

enum = arr1.chunk { |a| a.first[0,10] } #=> #<enumerator: #<enumerator::generator:0x000001010e30d8>:each>

let's see elements of enum:

enum.to_a #=> [["2014-01-15", [["2014-01-15 00:00", 100], ["2014-01-15 24:00", 100]]], # ["2014-01-16", [["2014-01-16 00:00", 100], ["2014-01-16 06:00", 200], # ["2014-01-16 12:00", 300], ["2014-01-16 23:00", 400], # ["2014-01-16 24:00", 400]]], # ["2014-01-17", [["2014-01-17 00:00", 400], ["2014-01-17 12:00", 500], # ["2014-01-17 24:00", 500]]], # ["2014-01-18", [["2014-01-18 00:00", 500], ["2014-01-18 03:00", 600], # ["2014-01-18 06:00", 700], ["2014-01-18 24:00", 700]]]]

now need map each element (one per date) weighted average of vals (noting don't utilize first element of each element of enum):

enum.map { |_,arr| (arr.each_cons(2) .reduce(0.0) { |t,((d1,v1),(d2,_))| t + min_diff(d2,d1)*v1 }/1440.0).round(2) } #=> [100.0, 229.17, 450.0, 662.5]

using helper:

def min_diff(str1, str2) 60*(str1[-5,2].to_i - str2[-5,2].to_i) + str1[-2,2].to_i - str2[-2,2].to_i end

putting together:

arr1.chunk { |a| a.first[0,10] } .map { |_,arr| (arr.each_cons(2) .reduce(0.0) { |t,((d1,v1),(d2,_))| t + min_diff(d2,d1)*v1 }/1440.0).round(2) } #=> [100.0, 229.17, 450.0, 662.5]

along helper min_diff.

ruby arrays time

windows - CMD how to pass parameters to script and save to file name of one of the parameters -



windows - CMD how to pass parameters to script and save to file name of one of the parameters -

i want pass next parameters script:

myscript.cmd "foo" "bar" "file"

where 3rd parameter should added extension .log

in illustration should file.log

set logfile = "%~3" + .log echo logfilename "%logfile%" echo %date% %time% got parameters "%~1" "%~2" >> "%logfile%"

should script above, not beingness able create work

three problems, quotes (included in value of variable), spaces (you have included spaces in name of variable) , concatenation (there no concatenation operator in batch files)

you have defined variable named logfile_, aditional space (represented underscore) in name, , assigned value literal _"file"_+_.log (as before, underscores represent spaces)

the line

set logfile = "%~3" + .log ^ ^^ ^^^^ unneeded/problematic characters

should

set "logfile=%~3.log"

no aditional spaces , quotes not included in value, delimit assignment prevent problems special characters or aditional spaces @ end of line

windows command-line cmd dos

Running Spatial Queries in PostGIS 2.1.3 and Postgresql 9.3 in Windows 7 -



Running Spatial Queries in PostGIS 2.1.3 and Postgresql 9.3 in Windows 7 -

i installed postgresql 9.3 ( pgadmin 3 gui) , postgis 2.1.3 (http://www.enterprisedb.com/products-services-training/pgdownload#windows) windows 7 64 bit. after installing it, downloaded sql files country database (http://www.spatial.cs.umn.edu/book/labs/vania/spatialqueries.html) , tried execute commands in country.sql

in sql builder , stuck @ next error:

notice: srid value -1 converted officially unknown srid value 0 context: sql statement "select addgeometrycolumn('',$1,$2,$3,$4,$5,$6,$7)" pl/pgsql function addgeometrycolumn(character varying,character varying,character varying,integer,character varying,integer,boolean) line 5 @ sql statement error: function geometryfromtext(unknown, integer) not exist line 4: ...3000.0000','dollar','usd','n','5','united states',geometryfr... ^ hint: no function matches given name , argument types. might need add together explicit type casts. ********** error **********

error: function geometryfromtext(unknown, integer) not exist sql state: 42883 hint: no function matches given name , argument types. might need add together explicit type casts. character: 769

i can't error resolved. please help me out.

postgresql postgis windows-7-x64

override - Java abstract class and overriding variables -



override - Java abstract class and overriding variables -

i have encountered problem cannot solve. let's have superclass a:

public enum enumeration { a, b, c; } public abstract class { private enumeration e; public void somemethod { // here 'e'. } }

now let's assume have class b.

public class b extends { private final enumeration = e.a; }

here compiler warning value never used.

i want define method in class a, have define variable. want give variable new fixed value in subclass.

is not possible?

field can't overridden. if want assign specific enum instance class, utilize constructor:

public abstract class { private final enumeration e; protected (enumeration e) { this.e = e; } public void somemethod { // 'e'. } } public class b extends { public b() { super(enumeration.a); } }

java override abstract-class

html/javascript how to display user input with a method on button click? -



html/javascript how to display user input with a method on button click? -

i'm trying alert window display first , lastly name user inputs after click "submit". i'm trying using methods in javascript, can't display after user clicks button.

here code:

<html> <head> <meta charset = 'utf-8'> <title>form</title> <script type = 'text/javascript'> var firstname; //first name var lastname; //last name function getfirstname() { //get first name homecoming document.getelementbyid("first_name").value; } function getsecondname() { //get lastly name homecoming document.getelementbyid("last_name").value; } function display() { //get names , display them firstname = getfirstname(); lastname = getlastname(); window.alert(firstname + lastname); } document.getelementbyid("submit").onclick = display(); </script> </head> <body> <form id='form' method = 'post'> <p> first name: <input type='text' id = "first_name"/></p> <p> lastly name: <input type='text' id = "last_name"/> </p> <p><input id ="submit" type = "button" value = 'clickme' /></p> </form> </body> </html>

http://jsfiddle.net/wqymjl32/

<form id='form' method = 'post'> <p> first name: <input type='text' id = "first_name"/></p> <p> lastly name: <input type='text' id = "last_name"/> </p> <p><input id ="submit" type = "button" onclick="display()" value='clickme'/></p> </form>

slight alter html, onclick attribute / event added submit button.

var firstname; //first name var lastname; //last name function getfirstname() { homecoming document.getelementbyid("first_name").value; } function getsecondname() { homecoming document.getelementbyid("last_name").value; } function display() { firstname = getfirstname(); lastname = getsecondname(); window.alert(firstname + lastname); document.getelementbyid("form").submit(); }

slight alter javascript phone call getsecondname instead of getlastname

javascript html

Set Timeout for MAX_AGI_CONNECT in Asterisk -



Set Timeout for MAX_AGI_CONNECT in Asterisk -

i have asterisk installed , zoiper softphone. whenever create call, there error displayed on asterisk :

warning[28761]: res_agi.c:1498 launch_netscript: fastagi connection 'agi://0.0.0.0/incoming.agi' timed out after max_agi_connect (2000) milliseconds. -- auto fallthrough, channel 'sip/123-0000003d' status 'unknown'

it takes approx 10 seconds connect call, time-out 2 sec, phone call never connected.

my question : how can alter default time-out 2000ms 15000ms ?

problem in point of dialplan there agi can't executed. it's this:

exten => ????,n,agi(agi://0.0.0.0/incoming.agi)

if need have prepare script receive connection in proper way or alter dialplan.

in case realy need this, can change timeout in sources

asterisk

npm install q --save only saves in devDependencies -



npm install q --save only saves in devDependencies -

i getting strangest behavior npm install q --save installing q in devdependencies, never in dependencies. true module, not q. no matter install flags use, modules ever saved in devdependencies.

i switched between multiple versions of npm including latest stable version , behavior same every time.

eventually tracked downwards ~/.npmrc file contained following:

save = true save-dev =

i changed this:

save = false save-dev = false

and npm install q --save correctly saves dependencies!

npm

Capturing/Intercepting Android Intents during runtime -



Capturing/Intercepting Android Intents during runtime -

is there way capture/intercept intents of application during runtime without modifying android framework? modifying android framework might require much work. please help me.

to view intents happen, run logcat in shell , filter downwards intents this:

adb logcat | fgrep -i intent

(you can add together filter app's intents, exclude intents sent app scheme , other apps.)

this should show intents such as

i/activitymanager( 585): starting activity: intent { action=android.intent.action...}

to see system-wide intents, seek intent intercept app.

to see intents sent own classes, then

in each broadcastreceiver, override onreceive(context context, intent intent). in each activity, phone call getintent() intent started activity. in each service, override onstartcommand(intent intent, int flags, int startid) intent started service.

for info on standard intent actions, see intent.

android android-intent runtime

Login with facebook Error Code=7 in IOS -



Login with facebook Error Code=7 in IOS -

in application

acaccountstore *accountstore = [[acaccountstore alloc] init]; acaccounttype *fb_account_type = [accountstore accounttypewithaccounttypeidentifier:acaccounttypeidentifierfacebook]; // specify app id , permissions nsdictionary *dictfb = @{ acfacebookappidkey:@"523377051045933", acfacebookpermissionskey: @[@"email"], acfacebookaudiencekey: acfacebookaudiencefriends }; [accountstore requestaccesstoaccountswithtype:fb_account_type options:dictfb completion:^(bool granted, nserror *e) { if (granted) { nsarray *accounts = [accountstore accountswithaccounttype:fb_account_type]; // nslog(@"facebook business relationship = %@",[accounts lastobject]); acaccount *fb_account = [accounts lastobject]; // access token, used in other scenarios acaccountcredential *fbcredential = [fb_account credential]; nsstring *accesstoken = [fbcredential oauthtoken]; // nslog(@"facebook access token: %@", accesstoken); [[nsuserdefaults standarduserdefaults] setobject:accesstoken forkey:@"fb_token"]; [[nsuserdefaults standarduserdefaults] synchronize]; [self performselectoronmainthread:@selector(loginwithfacebookok) withobject:nil waituntildone:no]; } #if debug else { nslog(@"error getting permission %@",e); } #endif [self.progressview hidewithanimated:yes]; }];

when effort login facebook error generated

error getting permission error domain=com.apple.accounts code=7 "the operation couldn’t completed. (com.apple.accounts error 7.)" invalid application fb_app_id" userinfo=0xb461770 {nslocalizeddescription=the facebook server not fulfill access request: invalid application fb_app_id}

my code right why error generate. add together fb business relationship in iphone settings.

ios facebook login

sql - MSSQL 2008: Get last updated record by specific field -



sql - MSSQL 2008: Get last updated record by specific field -

i'm having simplified table called content in mssql:

contentid updatedat fileid 1 2014-01-01 00:00:00 file-a 1 2014-02-02 00:00:00 file-b 1 2014-03-03 00:00:00 file-b 2 2012-12-30 00:00:00 file-x 2 2012-12-31 00:00:00 file-y

what want accomplish following:

get each row table content, fileid has been updated compared it's previous version. result should following:

contentid updatedat fileid 1 2014-02-02 00:00:00 file-b 2 2012-12-31 00:00:00 file-y

what have tried far:

looked different solutions , found lag() function, seemed promising. feature seems available in mssql 2012, error "the parallel info warehouse (pdw) features not enabled" states. tried wrap head around cursors, since i'm noob this, couldn't find running solution. lots of nested queries, ugh... since new row created each update, assume nested queries not way go because of performance-reasons.

in sql server 2012, utilize lag(). can replicate in various ways in sql server 2008. here method using cross apply:

select c.* content c cross apply (select top 1 c2.* content c2 c2.contentid = c.contentid , c2.updatedat < c.updatedat order c2.updatedat desc ) cprev c.fileid <> cprev.fileid;

sql sql-server sql-server-2008

assembly - Conditional Jump (jg) after comparison (cmp) -



assembly - Conditional Jump (jg) after comparison (cmp) -

here snippet of code book provided. question asks whether execution bx,1 or ax,10 executed. looking @ code want ax,10 executed, reply online says bx,1 executed, , emulator says both executed. help me understand going on here?

mov cx,5 not cx mov dx,10 cmp cx,dx jg jump1 mov bx,1 jump1: mov ax,10

let's trace. before cmp line value of cx -6 (the result of not on 5). jg command performs signed comparing - doesn't treat negative numbers big positive ones (ja , jb do).

so cx (-6) not greater dx (10), , conditional jump not taken. both lines execute.

assembly

visual studio 2012 - LGHT0103 SYSTEM CANNOT FIND FILE WIX38 -



visual studio 2012 - LGHT0103 SYSTEM CANNOT FIND FILE WIX38 -

i new stack overflow , wix please bear me.

i using wix38 in visual studio2012 on x64 laptop. trying create x86 installer of files trying add together failing build lght0103 scheme cannot find file error.

my wix code add together files follows:

<fragment> <componentgroup id="desktopcomponents" directory="installfolder"> <component id="cmpexecutable" guid="{e84bf717-9b73-439f-b8d2-1e2c2e5fa204}"> <file id="fileexecutable" keypath="yes" source="$(var.paddockdesktop.targetdir)paddockdesktop.exe" /> </component> <component id="cmpenityframework" guid="{596a608e-53aa-4131-92f3-5b1ea065aec9}"> <file id="fileentityframework" keypath="yes" source="$(var.paddockdesktop.targetdir)entityframework.dll" /> </component> <component id="cmpmahapps" guid="{2434f3af-00c0-4363-9dcd-d631656d275d}"> <file id="filemahapps" keypath="yes" source="‪$(var.paddockdesktop.targetdir)mahapps.metro.dll" /> </component> <component id="cmpinteractivity" guid="{1179cc18-8bd6-42d0-ae4d-35fb6b4f5750}"> <file id="fileinteractivity" keypath="yes" source="$(var.paddockdesktop.targetdir)system.windows.interactivity.dll" /> </component> </componentgroup> </fragment>

the error shown in build output as:

c:\program files (x86)\wix toolset v3.8\bin\candle.exe -d"devenvdir=c:\program files (x86)\microsoft visual studio 11.0\common7\ide\\" -dsolutiondir=g:\aa\ -dsolutionext=.sln -dsolutionfilename=paddockdesktop.sln -dsolutionname=paddockdesktop -dsolutionpath=g:\aa\paddockdesktop.sln -dconfiguration=release -doutdir=bin\release\ -dplatform=x86 -dprojectdir=g:\aa\paddocksetup\ -dprojectext=.wixproj -dprojectfilename=paddocksetup.wixproj -dprojectname=paddocksetup -dprojectpath=g:\aa\paddocksetup\paddocksetup.wixproj -dtargetdir=g:\aa\paddocksetup\bin\release\ -dtargetext=.msi -dtargetfilename=paddocksetup.msi -dtargetname=paddocksetup -dtargetpath=g:\aa\paddocksetup\bin\release\paddocksetup.msi -dpaddockdesktopservice.configuration=release -d"paddockdesktopservice.fullconfiguration=release|x86" -dpaddockdesktopservice.platform=x86 -dpaddockdesktopservice.projectdir=g:\aa\paddockdesktopservice\ -dpaddockdesktopservice.projectext=.csproj -dpaddockdesktopservice.projectfilename=paddockdesktopservice.csproj -dpaddockdesktopservice.projectname=paddockdesktopservice -dpaddockdesktopservice.projectpath=g:\aa\paddockdesktopservice\paddockdesktopservice.csproj -dpaddockdesktopservice.targetdir=g:\aa\paddockdesktopservice\bin\x86\release\ -dpaddockdesktopservice.targetext=.exe -dpaddockdesktopservice.targetfilename=paddockdesktopservice.exe -dpaddockdesktopservice.targetname=paddockdesktopservice -dpaddockdesktopservice.targetpath=g:\aa\paddockdesktopservice\bin\x86\release\paddockdesktopservice.exe -dpaddockdesktop.configuration=release -d"paddockdesktop.fullconfiguration=release|x86" -dpaddockdesktop.platform=x86 -dpaddockdesktop.projectdir=g:\aa\paddockdesktop\ -dpaddockdesktop.projectext=.csproj -dpaddockdesktop.projectfilename=paddockdesktop.csproj -dpaddockdesktop.projectname=paddockdesktop -dpaddockdesktop.projectpath=g:\aa\paddockdesktop\paddockdesktop.csproj -dpaddockdesktop.targetdir=g:\aa\paddockdesktop\bin\x86\release\ -dpaddockdesktop.targetext=.exe -dpaddockdesktop.targetfilename=paddockdesktop.exe -dpaddockdesktop.targetname=paddockdesktop -dpaddockdesktop.targetpath=g:\aa\paddockdesktop\bin\x86\release\paddockdesktop.exe -out obj\release\ -arch x86 product.wxs c:\program files (x86)\wix toolset v3.8\bin\light.exe -out g:\aa\paddocksetup\bin\release\paddocksetup.msi -pdbout g:\aa\paddocksetup\bin\release\paddocksetup.wixpdb -cultures:null -contentsfile obj\release\paddocksetup.wixproj.bindcontentsfilelistnull.txt -outputsfile obj\release\paddocksetup.wixproj.bindoutputsfilelistnull.txt -builtoutputsfile obj\release\paddocksetup.wixproj.bindbuiltoutputsfilelistnull.txt -wixprojectfile g:\aa\paddocksetup\paddocksetup.wixproj obj\release\product.wixobj g:\aa\paddocksetup\product.wxs(41,0): error lght0103: scheme cannot find file '‪g:\aa\paddockdesktop\bin\x86\release\mahapps.metro.dll'.

the file mahapps.metro.dll indeed @ location referenced. other 3 files seem added correctly , @ same location file causing error.

i have looked @ other stackoverflow questions: wix project error in tfs build shows problem similar mine. did not understand tfs solution provided , path length far less 255 characters. there other link wix unable load file, error lght0103 . solution seems easy couldn't figure out how alter $(var.paddockdesktop.targetdir) sys.sourcefiledir.

i cant understand why files same folder added , others not added though in same folder.

please note : paddockdesktop wpf project in same solution wix installer. targeting x86 cpu.

thank assistance in advance.

i installed wix3.9 , compiled correctly. not sure problem was, bug in wix3.8

visual-studio-2012 wix wix3.8

javascript - Attach video to marker using google map API -



javascript - Attach video to marker using google map API -

desired output: attach video marker

what has been achieved yet: basic google map codes place marker @ specific location

idea: utilize marker variable defined attach video

tried using infowindow doesnt show video. note video in same folder file contains code. can help please?

<!doctype html> <html> <head> <script src="http://maps.googleapis.com/maps/api/js?&sensor=false"> </script> <script> function initialize() { var mapprop = { center:new google.maps.latlng(-20.240154, 57.589669), zoom:10, maptypeid:google.maps.maptypeid.roadmap }; var map=new google.maps.map(document.getelementbyid("googlemap"),mapprop); var curepipe=new google.maps.marker({ position: new google.maps.latlng(-20.318813, 57.524149) }); curepipe.setmap(map); var infowindow = new google.maps.infowindow({ content:"hello world!" }); infowindow.open(map,marker); } } google.maps.event.adddomlistener(window, 'load', initialize); </script> </head>

you had already, needed add together html5 video element infowindow, ensure video files accessible via server.

aaaand, few minor changes:

class="snippet-code-js lang-js prettyprint-override">function initialize() { var mapprop = { center: new google.maps.latlng(-20.240154, 57.589669), zoom: 10, maptypeid: google.maps.maptypeid.roadmap }; var map = new google.maps.map(document.getelementbyid("googlemap"), mapprop); var curepipe = new google.maps.marker({ position: new google.maps.latlng(-20.318813, 57.524149) }); curepipe.setmap(map); var infowindow = new google.maps.infowindow({ content: '<video controls="" style="width:100px;height:100px;" poster="poster.png">' + '<source src="http://www.html5rocks.com/en/tutorials/video/basics/devstories.webm" type="video/webm;">' + '<source src="http://www.html5rocks.com/en/tutorials/video/basics/devstories.mp4" type="video/mp4;">' + '</video>' }); infowindow.open(map, curepipe); } google.maps.event.adddomlistener(window, 'load', initialize); class="snippet-code-html lang-html prettyprint-override"><script src="https://maps.googleapis.com/maps/api/js?&sensor=false"></script> <div id="googlemap" style="width:500px; height:500px;"></div>

edit

the video used comes this page

javascript html google-maps google-maps-markers

r - rCharts: Change the individual point colors of a time series plot (Highcharts) -



r - rCharts: Change the individual point colors of a time series plot (Highcharts) -

i trying create time-series plot using plotting interface of rcharts highcharts library. trying figure out how can set color of individual point depending on y-value. found way have different colors line , points, group, not info points individually.

here's test code:

library(rcharts) library(rjson) transformdate <- function(x){ as.numeric(as.posixct(x, origin="1970-01-01")) * 1000 } x <- transformdate(c('2013-01-01 11:05:35', '2013-03-03 04:50:35', '2013-05-05 21:09:37', '2013-07-07 12:49:05')) y <- c(1,56,123,1000) w<-transformdate(c('2013-01-10 11:05:35', '2013-03-13 04:50:35', '2013-05-15 21:09:37', '2013-07-17 12:49:05')) z<-c(10, 100, 70, 500) df1 <- data.frame(x = x,y = y) df2 <- data.frame(x = w, y = z) combo <- rcharts:::highcharts$new() combo$series(list(list(data = rcharts::tojsonarray2(df1, json = f, names = f), name = "temp1", marker = list(fillcolor = c('#999'), linewidth=6, linecolor=c('#999'))), list(data = rcharts::tojsonarray2(df2, json = f, names = f), name = "temp2"))) combo$xaxis(type='datetime') combo$chart(type = "scatter") combo$chart(zoomtype="x") combo

i believe can done in polycharts reason why using highcharts plots time-series info nicely , has cool zoom-in functionality.

thanks in advance help & suggestions. jan

here's 1 way command color/size lines/markers separately:

h <- rcharts:::highcharts$new() h$series(list( list(data = rcharts::tojsonarray2(df1, json = false, names = false), name = "big reds", color = '#ff0000', linewidth = 4, marker = list( fillcolor = '#ffa500', radius = 10) ), list(data = rcharts::tojsonarray2(df2, json = false, names = false), name = "small blues", color = '#0000ff', linewidth = 2, marker = list( fillcolor = '#add8e6', radius = 6) ))) h$xaxis(type = 'datetime') h$chart(type = "scatter") h$chart(zoomtype = "x") h

r highcharts rcharts

opengl - glGetUniformLocation unpredictable behavior -



opengl - glGetUniformLocation unpredictable behavior -

i've defined struct in fragment shader, below:

struct light_source{ vec4 ld, location; int type; float radii, specular_exponent; };

and i'm using uniform access struct members: uniform light_source light_sources[5];

now, c++ code, i'm getting uniform locations this:

ld = glgetuniformlocation(globals::programid, "light_sources[0].ld"); ls = glgetuniformlocation(globals::programid, "light_sources[0].ls"); location = glgetuniformlocation(globals::programid, "light_sources[0].location"); type = glgetuniformlocation(globals::programid, "light_sources[0].type"); radii = glgetuniformlocation(globals::programid, "light_sources[0].radii"); specular_exponent = glgetuniformlocation(globals::programid, "light_sources[0].specular_exponent");

when print above values, find values -1,1,2,-1,3,4 . so, couldn't locations ld , type . similarly, if add together new variable shader , times location, , -1 .

i don't problem here. variable definitions right , there no typos. can behavior remedied?

when uniform/attribute not beingness used or has no effect on output compiler/linker free remove exclusively results in getuniformlocation , glgetattributelocation returning invalid values.

opengl glsl

node.js - duplicate repository via github API -



node.js - duplicate repository via github API -

i need create repositories contains core-files , single setting file via github api. single setting file generated each application (single unique file), core-files static files, need upload them each repository. there way set core-files in 1 repo , duplicate repository instead of upload these files everytime? using node.js octonode module. thanks.

the core-files static files, need upload them each repository. there way set core-files in 1 repo

you can add together repo submodule in each of other repos:

cd arepo git submodule add together https://github.com/username/core-repo git add together . git commit -m "add reference core repo" git force

node.js git github github-api

Difference between include directive and forward declaration in C++ -



Difference between include directive and forward declaration in C++ -

i must refactor old code. 1 of problems exceeds on useless 'includes'. in same project, i've seen next syntax:

#include <anyclass> //a scheme header #include "anotheranyclass" //a application header class anotherclass; class class : public onemoreclass { public: explicit class(); ~class(); private: anotherclass *m_anotherclass; }

i'd figure out:

what differences between 'include "class"' , 'class class'? when should sec method used , how?

those 2 different things:

#include <anyclass>

this normal include header (or type of textual) file. equivalent pasting content of anyclass file in spot typed inclusion directive (that's why include guards and/or compiler pragmas used prevent multiple inclusions in same file).

this syntax:

class anotherclass;

is forward declaration , informs compiler of existence of anotherclass class. useful in many scenarios, e.g. suppose have 2 classes each 1 needs pointer other:

class classb { classa* pointer_to_classa; }; class classa { classb* pointer_to_classb; };

the above code generate error: "error: unknown type name 'classa'" since used classa type without compiler knowing (yet). compiler's parser know classa's existence when parses origin of class declaration.

to have above working need forwards declaration:

class classa; // classa type exists class classb { classa* pointer_to_classa; }; class classa { classb* pointer_to_classb; };

c++

c# - Get Property of generic type object without knowing the generic type -



c# - Get Property of generic type object without knowing the generic type -

i need see property of object of generic type, without knowing specific type:

foreach(var n in nodes) { if(n.gettype().getgenerictypedefinition() == typeof(variablenode<>)) { if((n variablenode<>).variable == myvar) //obviously not work { toremove.add(n); } } }

so, elegant way check property "variable" ? (variable reference type)

thanks!

edit:

def of node:

using system; using system.collections.generic; using system.linq; using system.text; using unityengine; using kspcomputer.types; using kspcomputer.connectors; namespace kspcomputer.nodes { [serializable] public abstract class node { public svector2 position; public int inputcount { { homecoming inputs.count; } } public int outputcount { { homecoming outputs.count; } } public flightprogram programme { get; private set; } private dictionary<string, connectorin> inputs; private dictionary<string, connectorout> outputs; public keyvaluepair<string, connectorin>[] inputs { { homecoming inputs.toarray(); } } public keyvaluepair<string, connectorout>[] outputs { { homecoming outputs.toarray(); } } public node() { position = new svector2(); inputs = new dictionary<string, connectorin>(); outputs = new dictionary<string, connectorout>(); } internal virtual void init(flightprogram program) { programme = program; oncreate(); } protected void in<t>(string name, bool allowmultipleconnections = false) { var connector = new connectorin(typeof(t), allowmultipleconnections); connector.init(this); inputs.add(name, connector); } protected void out<t>(string name, bool allowmultipleconnections = true) { var connector = new connectorout(typeof(t), allowmultipleconnections); connector.init(this); outputs.add(name, connector); } protected void out(string name, object value) { connectorout o; if (outputs.trygetvalue(name, out o)) { if (o.connected) { o.senddata(value); } } } protected connectorout getouput(string name, bool connected = true) { connectorout o; if (outputs.trygetvalue(name, out o)) { if (o.connected || !connected) { homecoming o; } } homecoming null; } protected connectorin in(string name) { connectorin o; if (inputs.trygetvalue(name, out o)) { homecoming o; } homecoming null; } public void updateoutputdata() { requestinputupdates(); onupdateoutputdata(); } protected virtual void onupdateoutputdata() { } protected virtual void oncreate() { } protected void requestinputupdates() { foreach (var in inputs.values) { i.freshdata = false; } foreach (var in inputs.values) { if (!i.freshdata) { i.requestdata(); } } } public ienumerable<connector> getconnectedconnectors() { homecoming (from c in inputs.values c.connected select c connector).concat(from c in outputs.values c.connected select c connector); } public ienumerable<connector> getconnectedconnectorsin() { homecoming (from c in inputs.values c.connected select c connector); } public ienumerable<connector> getconnectedconnectorsout() { homecoming (from c in outputs.values c.connected select c connector); } } }

definition of variablenode:

using system; using system.collections.generic; using system.linq; using system.text; using kspcomputer; using kspcomputer.nodes; using kspcomputer.connectors; using kspcomputer.variables; namespace kspcomputer.nodes { [serializable] public class variablenode<t> : executablenode { internal variable variable { get; private set; } internal void setvariable(variable variable) { this.variable = variable; } protected override void oncreate() { in<t>("set"); out<t>("get"); } protected override void onexecute(connectorin input) { variable.value = in("set").get<t>(); executenext(); } protected override void onupdateoutputdata() { out("get", variable.value); } } }

it looks should able utilize reflection:

foreach(var n in nodes) { if(n.gettype().getgenerictypedefinition() == typeof(variablenode<>)) { if(n.gettype().getproperty("variable").getvalue(n, null) == myvar) { toremove.add(n); } } }

c# generics types properties get

sed - regex: not match a group rather than single characters -



sed - regex: not match a group rather than single characters -

echo test.a.wav|sed 's/[^(.wav)]*//g' .a.wav

what want remove every character until reaches whole grouping .wav(that is, want result .wav), seems sed remove every character until reaches of 4 characters. how trick?

groups not work within [], dot part of class parens.

how about:

echo test.a.wav|sed 's/.*\(\.wav\)/\1/g'

note, there may other valid solutions, provide no context on trying determine may best solution.

regex sed

java - LibGDX Uncaught RunTime Exception in HTML Deployment -



java - LibGDX Uncaught RunTime Exception in HTML Deployment -

i seem getting error when deploying game html. menu screen works fine, transition game screen causes error.

text console:

uncaught java.lang.runtimeexception: com.google.gwt.core.client.javascriptexception: (typeerror) gwt$exception: <skipped>: cannot read property 'get_5' of null

the errors seem pile on millisecond window kept open. game runs on desktop (windows , mac), android, , iphone. not sure what's going on. i'm using 6 different sounds, multiple textures/textureatlas's, no fonts. extension have project "tools" extension.

i fixed previous error received after compiling html using reflection class. not sure error though.

this problem similar this thread year ago. took @ build.gradle file in html folder, "strict = true" within compiler struct, i'm assuming that's okay. project uses gl20 i'm not sure if solutions applicable in case.

thanks help!

java html html5 gwt libgdx

c++ - Change QWidget Parent During Mouse Event -



c++ - Change QWidget Parent During Mouse Event -

i'm trying create detachable type style widget, in way chrome tabs detachable (class called tab). have working, except bug (maybe 50% of time), tab object never gets mouse release event, , stops getting mouse move events.

essentially, detaching scheme works allowing drags in mouse press/move/release functions, normal. mousemoveevent checks total distance moved start, , if on amount, start "detaching" process. detaching process involves setting parent widget 0 (top level widget, undecorated window), tab object pretty much floating above everything, under mouse, , continues dragged along until released.

i ran through qevent items beingness delivered, , found when issue occurs, qevent::mousemove items (and mouse events after this) beingness sent tabbar (the tab object's original parent). occurs straight after calling setparent(0) on tab.

basic mouse handling overview: void tab::mousepressevent(*) { [set boolean, start positions, etc] } void tab::mousemoveevent(*) { [track updated position] if (positionchange > static_amount) detachtab(); } void tab::mousereleaseevent(*) { [return tab original position, , set parent tabbar] } void tab::detachtab() { qpoint mappedpos = maptoglobal(0, 0); setparent(0); //the loss of mousemove events occurs when returns. move(mappedpos); show(); raise(); }

here events tab object receives (first row qevent type, sec name)

[tab::detachtab() started] [setparent(0) started] qevent::hide qevent::leave qapp qevent::mousemove [ tabbar ] <-- tabbar soaking mouse events qevent::hidetoparent qevent::parentabouttochange qevent::parentchange [setparent(0) returned] ....

summed up: draggable qwidget loses qevent::mousemove , qevent::mousebuttonrelease events after having parent set 0.

any advice appreciated!

a bit tricky workaround. didn't test it, it's idea.

when mouse hovers draggable part of widget may create topmost widget (let's phone call shade) qt::framelesswindowhint (and possible qt::wa_translucentbackground). may manipulate shade apperance via reimplementing paintevent. illustration - draw content of original widget, or draw transparent preview, etc.

then may resize shade during dragging, show user widget detached. not loose mouse capture.

when user release mouse - remember position of shade, destroy , detach+move original widget.

feel free ask, if want more details.

c++ qt qt5 qwidget

javascript - Changing html2canvas to accept display as none -



javascript - Changing html2canvas to accept display as none -

i using jspdf create utilize of html2canvas. here illustration of it.

based on this answer, downloaded html2canvas , started using locally create alter suggested, because alternative of setting colour other answers proposed didn't worked me.

also, notice other requirement have different of html2canvas delivers default. need able generate pdf file if display set none.

note on illustration gave, alternative html renderer (early stages) works display none, implements poor render. on other hand, addhtml() using now, renders page is, implies render visible.

this default method of html2canvas decide consider visible.

function iselementvisible(element) { homecoming (getcss(element, 'display') !== "none" && getcss(element, 'visibility') !== "hidden" && !element.hasattribute("data-html2canvas-ignore")); }

i commented line: getcss(element, 'visibility') !== "hidden", , enabled me create pdf if visibility: hidden. samething not true display: none, if method homecoming true.

how implement it?

a node display: none can't domrect calculated it, not have 1 within dom (as display: none).

if want render display: none content, you'll need create display of node else prior rendering.

starting html2canvas 0.5.0, can provide onclone alternative html2canvas callback returns cloned document object, can go , modify dom see fit prior rendering it, without affecting original document.

javascript html2canvas jspdf

in app billing - How to track user statistic in android -



in app billing - How to track user statistic in android -

i'm looking solution info amount of bypassed premium purchases.

my actual approach in short: maintain track of usage when premium feature -used- , send info web server.

actually concept provides user grants "read business relationship information" permission. able receive android-id , gmail-account well. @ end hope useful info security issues, maybe hide in in-app-billing code, comparing info in wallet database.

my question:

i not sure if necessary collect these user info @ all. of know, here in federal republic of germany people in panic fast, when wants collect usage information.

i appreciate helpful information. regards , in advance.

android in-app-billing usage-statistics user-data

How can I get the jquery gzoom plugin working? -



How can I get the jquery gzoom plugin working? -

i have picked jquery plugin called gzoom the gzoom site seems able want (variable zoom). have seen previous question on stackoverflow seems have been resolved. not familiar js , jquery, , missing easy.

i have downloaded custom version of latest jquery-ui (with jquery) - version 1.11.2 - pdc folder. have downloaded 2 gzoom files - jquery.gzoom.css , jquery.gzoom.js. testing on wamp, outside wordpress environment now.

my html file (adapted above sources)

<!doctype html> <html> <head> <meta charset="utf-8"> <title>test gzoom</title> <link rel="stylesheet" href="/pdc/jquery-ui-1.11.2.custom/jquery-ui.min.css"> <script src="/pdc/jquery-ui-1.11.2.custom/external/jquery/jquery.js"></script> <script src="/pdc/jquery-ui-1.11.2.custom/jquery-ui.min.js"></script> <link rel="stylesheet" href="/pdc/gzoom/css/jquery.gzoom.css" type="text/css" media="screen"> <script type="text/javascript" src="/pdc/gzoom/jquery/jquery.gzoom.js"></script> <style> div#zoom{ cursor: crosshair; } </style> </head> <body> <div id="gzoomwrap"> <div id="zoom" class="zoom minizoompan"> <img src='/wp/wp-content/uploads/hcn-sign-for-palette.jpg'/> </div> </div> <script type="text/javascript"> /*<![cdata[*/ $(function() { $zoom = $("#zoom").gzoom({ sw: 300, sh: 225, lw: 1400, lh: 1050, lightbox : false }); }); /*]]>*/ </script> </body> </html>

the image , slider display ok, when move slider image not change. error can see (using chrome)

uncaught typeerror: cannot read property 'replace' of undefined jquery.gzoom.js:94 , line var hisrc = ig.attr("src").replace(settings.re, settings.replace);

i have tried 1 or 2 different jquery versions have had same problem. have done wrong? thanks

jquery

python - Need for help in this scrapy regular expression -



python - Need for help in this scrapy regular expression -

i pretty new scrapy, trying crawl website using crawlspider, want crawl recursively based on "next" button. not working. think problem comes regular expression, checked many times, can not find mistake. crawl landing page without proceed next page.

# -*- coding: utf-8 -*- start_urls = ['https://shopping.yahoo.com/merchantrating/?mid=13652'] rules = ( rule(linkextractor(allow = "/merchantrating/;_ylt=anf3hf19r8mgfpwuyujuny4ceb0f\?mid=13652&sort=1&start=\d+"), callback = 'parse_start_url', follow = true), ) def parse_start_url(self, response): sel = selector(response) contents = sel.xpath('//p') content in contents: item = bedbugsitem() item['pagecontent'] = content.xpath('text()').extract() self.items.append(item) homecoming self.items

use xpath instead:

rules = ( rule(linkextractor( restrict_xpaths = [ "//div[@class='pagination']//a[contains(., 'next')]" ]), callback = 'parse_start_url', follow = true), )

python regex scrapy

javascript - How do I prevent the browser window from jumping back to the top of the page when when I open and close my panel? -



javascript - How do I prevent the browser window from jumping back to the top of the page when when I open and close my panel? -

i've been working on website has persistent header, navigation panel slides out of top of screen. works wrapping header , navigation panel in fixed div, , giving div negative top margin equal height of navigation.

the html

<div class="sticky"> <div class="above-header"> navigation panel. </div> <div class="header"> logo <a href="#" class="toggle">toggle</a> </div> </div>

the css

.sticky { height:300px; margin:-250px 0 0; position:fixed; z-index:1000; } .above-header { height:250px; } .header { height:50px; } .open { margin:0 }

then utilize tiny js/jquery script alter margin 0, making navigation visible.

$('a.toggle').click(function() { if ($('.sticky').hasclass('open')){ $('.sticky').removeclass('open'); } else{ $('.sticky').addclass('open'); } });

i've got working fine except 1 problem: if open or close panel, view jumps top of page, regardless of i've scrolled to.

i've recreated a simplified version of problem on codepen demonstrate i'm talking about.

i cannot imagine why doing this, , google fu hasn't turned answers. thought can prepare problem? or perhaps there's improve technique i'm not aware of?

just prevent default action (nl navigating url + #)

$('a.toggle').click(function(e) { e.preventdefault(); $('.sticky').toggleclass('open'); });

and toggleclass option, can simplify phone call :)

javascript jquery html css

css - AutoCompleteExtender positioning for Chrome ONLY -



css - AutoCompleteExtender positioning for Chrome ONLY -

autocompleteextender positioning doesn't work in google chrome. works fine in ie though.

please see image attached. in ie style in inline element , nil appears on element style in google chrome.

the ajax list appears on top instead of below company name's textbox.

<span class="singlelinetextinput">company name</span><asp:textbox id="companynametextbox" cssclass="singlelinetextinput" runat="server"></asp:textbox> <div id="completionlist"></div> <ajaxtoolkit:autocompleteextender id="autocompleteextender1" runat="server" minimumprefixlength="1" targetcontrolid="companynametextbox" completionlistelementid="completionlist" servicemethod="getprovidercompletionlist" servicepath="~/services/providerselectorservice.asmx" completioninterval="500" completionsetcount="20" completionlistcssclass="completionlist" onclientpopulated="autocompleteclientpopulated" onclientitemselected="autocompleteitemselectedhandler" />

can help in please?

i fixed entering below in css:

@media screen , (-webkit-min-device-pixel-ratio:0) { div#completionlist { width: 350px !important; top: 1134px !important; } }

thanks views people! :)

css google-chrome position autocompleteextender

css3 - Media queries for iPhones are not working -



css3 - Media queries for iPhones are not working -

i maintain trying , trying, media queries not working iphones.

@media screen , (max-device-width: 667px) {}

it's supposed back upwards iphones, 6 plus. can help?

in terms of targeting versions of iphone / iphone 6, post provides helpful response: iphone 6 , 6 plus media queries

to back upwards little devices, under 667px mark, can generalize media query to:

@media screen , (max-width: 667px) { ... }

if testing on desktop, little window size, reason max-device-width may have not been working is:

width versus device-width

in css media difference between width , device-width can bit muddled, lets expound on bit. device-width refers width of device itself, in other words, screen resolution of device.

source: http://www.javascriptkit.com/dhtmltutors/cssmediaqueries2.shtml

css3 responsive-design media-queries

MariaDB i am not able to import this dump file -



MariaDB i am not able to import this dump file -

i have mariadb 5.5.39 version

mysqldump -u root -p database > dumpfile.sql

yes working fine getting dump file.

but not able import dump file.

mysqldump -u root -p database < dumpfile.sql mysqlimport -u root -p database < dumpfile.sql mysql -u root -p database < dumpfile.sql

these not working.

can help me please?

mysql -u root -p --database=db_name < dumpfile.sql

mariadb

c# - The client and server cannot communicate, because they do not possess a common algorithm -



c# - The client and server cannot communicate, because they do not possess a common algorithm -

i have issue c# paytrace gateway. below code working fine until yesterday when believe turned off ssl3 due poodle exploit. when running code below got next message. remote server has forcefully closed connection. after doing research on problem determined because our iis server 7.5 configured still utilize ssl3, c# defaulted ssl3, paytrace forcibly close connection. removed ssl3 server. lead next error:

the client , server cannot communicate, because not possess mutual algorithm.

my guess there additional ssl algorithm need install on server ssl 3 removed. our staff claims tls 1.1 , tls 1.2 working , asp.net should defaulting those. sense there still must else need install on server, have no knowledge of ssl algorithms have no thought begin.

var posturl = new stringbuilder(); //initialize url configuration , parameter values... posturl.appendformat("un~{0}|", this.merchantloginid); posturl.appendformat("pswd~{0}|", this.merchanttransactionkey); posturl.append("terms~y|method~processtranx|tranxtype~sale|"); posturl.appendformat("cc~{0}|", cardnumber); posturl.appendformat("expmnth~{0}|", expirationmonth.padleft(2, '0')); posturl.appendformat("expyr~{0}|", expirationyear); posturl.appendformat("amount~{0}|", transactionamount); posturl.appendformat("baddress~{0}|", this.addressline1); posturl.appendformat("baddress2~{0}|", this.addressline2); posturl.appendformat("bcity~{0}|", this.city); posturl.appendformat("bstate~{0}|", this.state); posturl.appendformat("bzip~{0}|", this.zip); posturl.appendformat("saddress~{0}|", this.addressline1); posturl.appendformat("saddress2~{0}|", this.addressline2); posturl.appendformat("scity~{0}|", this.city); posturl.appendformat("sstate~{0}|", this.state); posturl.appendformat("szip~{0}|", this.zip); if (!string.isnullorempty(this.country)) { posturl.appendformat("bcountry~{0}|", this.country); } if (!string.isnullorempty(this.description)) { posturl.appendformat("description~{0}|", this.description); } if (!string.isnullorempty(this.invoicenumber)) { posturl.appendformat("invoice~{0}|", this.invoicenumber); } if (this.istestmode) { posturl.appendformat("test~y|"); } //posturl.append(); webclient wclient = new webclient(); servicepointmanager.securityprotocol = securityprotocoltype.tls; string srequest = "parmlist=" + url.encode(posturl.tostring()); wclient.headers.add("content-type", "application/x-www-form-urlencoded"); string sresponse = ""; sresponse = wclient.uploadstring(paytraceurl, srequest);

also, fyi, issue happening when connect first info e4 gateway it's not paytrace thing. guess more gateways turn off access ssl3 we'll go on run issues other gateways until can resolved on server. also, did find few suggestions online, suggested placing next code right before making outbound request:

servicepointmanager.securityprotocol = securityprotocoltype.tls;

unfortunately did not work either, same error. why i'm thinking additional needs installed on iis7.5 server. i'm not sure what.

this resolved. turns out our staff correct. both tls 1.1 , tls 1.2 installed on server. however, issue our sites running asp.net 4.0 , have have asp.net 4.5 run tls 1.1 or tls 1.2. so, resolve issue, our staff had reenable tls 1.0 allow connection paytrace.

so in short, error message, "the client , server cannot communicate, because not possess mutual algorithm", caused because there no ssl protocol available on server communicate paytrace's servers.

c# asp.net ssl iis-7.5 poodle-attack

Primefaces calendar restricted not work correctly -



Primefaces calendar restricted not work correctly -

p: calendar not work correctly if after selecting date in restricted range can type in text box , alter date outside range.

<p:calendar value="#{addfacturamb.facturautilnew.fechaemision}" mindate="#{administrarmb.fechainicio}" maxdate="#{administrarmb.fechafin}" id="popupbuttoncal1" showon="button" required="true" locale="es" effect="show" navigator="true"/>

from described <p:calendar> mindate , maxdate attributes working correctly. limit date can selected on calendar pop up.

if don't want user alter date text box have few options stop this.

set calendar input text box read only. <p:calendar readonlyinput="true" /> change calendar mode inline <p:calendar mode="inline" /> there no input text box.

primefaces

batch file - Run a .exe from java and move on -



batch file - Run a .exe from java and move on -

i want programmatically run .exe programme if not running yet. moment utilize process builder launch .bat java. batch file runs .exe after checking if running. problem java won't move on until user closes .exe program. how can solve this?

java code :

try { processbuilder builder = new processbuilder("open.bat"); final process process = builder.start(); inputstream = process.getinputstream(); inputstreamreader isr = new inputstreamreader(is); bufferedreader br = new bufferedreader(isr); while ((br.readline()) != null) { } system.out.println("command line terminated"); } grab (exception err) { err.printstacktrace(); system.out.println("error "); }

batch code : (open.bat)

tasklist | find "illustrator.exe" if errorlevel 1 start "" "c:\program files (x86)\adobe\adobe illustrator cs6\support files\contents\windows\illustrator.exe"

updated

using...

start "" "c:\program files (x86)\adobe\adobe illustrator cs4\support files\contents\windows\illustrator.exe"

as open.bat batch file , using...

try { processbuilder builder = new processbuilder("open.bat"); builder.redirecterror(); builder.inheritio(); final process process = builder.start(); final inputstream = process.getinputstream(); inputstreamreader isr = new inputstreamreader(is); bufferedreader br = new bufferedreader(isr); string text = null; while ((text = br.readline()) != null) { system.out.println(text); } system.out.println("command line terminated"); system.out.println("exited " + process.waitfor()); } grab (exception err) { err.printstacktrace(); system.out.println("error "); }

i can batch file run , terminate , still have illustrator load , run.

the primary add-on phone call processbuilder#inheritio, magic i'm not aware of, seems allow batch file terminate...

from javadocs

this gives behavior equivalent operating scheme command interpreters, or standard c library function system().

java batch-file processbuilder

Node available for search before chef-client run -



Node available for search before chef-client run -

just wondering, if possible search node before node has completed chef-client run.

going chef docs: https://docs.getchef.com/essentials_nodes_chef_run.html

when of actions identified resources in resource collection have been done, , when chef-client run finished successfully, chef-client updates node object on chef server node object built during chef-client run. (this node object pulled downwards chef-client during next chef-client run.) makes node object (and info in node object) available search.

the chef-client checks resource collection presence of exception , study handlers. if present, each 1 processed appropriately

so example, have recipe searchs nodes role called "webserver". im creating chef node via pychef, , filling attributes, , runlists (including role in run_list). launching chef-client mahchine, fails find nodes role, has not been saved, not available search.

its easy see knife search roles attribute of returned search empty (roles still on run_list) , when chef-client finishes, roles moved proper place, node.roles.

is there way can forcefulness node saved, before doing search appear in results? keeping chef node in chef server works, deleted day , search not work anymore.

thanks!

in general bad thought several reasons.

any chef server uses acls scheme (enterprise chef, chef server 12) has issues manually creating node objects break permissions. can corrected manually, complex task. if query using roles or recipes expanded forms, have manually populated since step done chef-client during run list expansion , saved server. having partial results in search index leads service discovery failures non-working services end in production rotations.

chef chef-recipe

php - How to get the thumbnail image in full size? -



php - How to get the thumbnail image in full size? -

i having problem size of thumbnail. code using :

wp_get_attachment_image_src( $v, array(200,200));

need actual size image.

please utilize :

wp_get_attachment_image_src( $v, 'full' );

"$v" should attachment id. hope work you.

php wordpress

Facebook like box plugin for twitter bootstrap -



Facebook like box plugin for twitter bootstrap -

facebook's box iframe isn't working me. can point out why? here's code btw works on different bootstrap theme

<div class ="section" id= "lastsectionmainpage"> <div class ="row"> <div class ="col-lg-12"> <div class ="col-md-4"> <img src= "img/sg.jpg"> <h4 style ="color:white"> more testimonials</h4> </div> <!-- end of 4 --> <div class ="col-md-4"> <h4 style= "color:white"> see our image gallery </h4> <!-- button here --> </div> <!-- end of 4 --> <div class ="col-md-4"> <iframe src="http//www.facebook.com/plugins/likebox.php?href=https%3a%2f 2fwww.facebook.com%2ffacebookdevelopers&amp;width&amp;height=590& &amp;colorscheme=light&amp;show_faces=true&amp;header=true&amp;stream=true& amp;show_border=false" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:590px;" allowtransparency="true"></iframe> </div> </div> </div> </div>

after "http", forgot ":":

<iframe src="http://www.fa...

even better: remove "http" protocol website used:

<iframe src="//www.fa...

always utilize code generator getting right code social plugins: https://developers.facebook.com/docs/plugins/like-button

facebook twitter-bootstrap

c++ - Lighting a cube with a shader issue -



c++ - Lighting a cube with a shader issue -

i've been next tutorials on directx 11 book , trying give code lighting effects shader. problem shows buffer , doens't seem te create utilize of lighting shader file @ all. trying lite cube. help already. hlsl:

struct directionallight { float4 ambient; float4 diffuse; float4 specular; float3 direction; float pad; }; struct pointlight { float4 ambient; float4 diffuse; float4 specular; float3 position; float range; float3 att; float pad; }; struct spotlight { float4 ambient; float4 diffuse; float4 specular; float3 position; float range; float3 direction; float spot; float3 att; float pad; }; struct material { float4 ambient; float4 diffuse; float4 specular; float4 reflect; }; void computedirectionallight( material mat, directionallight l, float3 normal, float3 toeye, out float4 ambient, out float4 diffuse, out float4 spec) { ambient = float4(0.0f, 0.0f, 0.0f, 0.0f); diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f); spec = float4(0.0f, 0.0f, 0.0f, 0.0f); float3 lightvec = -l.direction; ambient = mat.ambient * l.ambient; float diffusefactor = dot(lightvec, normal); [flatten] if( diffusefactor > 0.0f ) { float3 v = reflect(-lightvec, normal); float specfactor = pow(max(dot(v, toeye), 0.0f), mat.specular.w); diffuse = diffusefactor * mat.diffuse * l.diffuse; spec = specfactor * mat.specular * l.specular; } } void computepointlight(material mat, pointlight l, float3 pos, float3 normal, float3 toeye, out float4 ambient, out float4 diffuse, out float4 spec) { ambient = float4(0.0f, 0.0f, 0.0f, 0.0f); diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f); spec = float4(0.0f, 0.0f, 0.0f, 0.0f); float3 lightvec = l.position - pos; float d = length(lightvec); if( d > l.range ) return; lightvec /= d; ambient = mat.ambient * l.ambient; float diffusefactor = dot(lightvec, normal); [flatten] if(diffusefactor > 0.0f) { float3 v = reflect(-lightvec, normal); float specfactor = pow(max(dot(v, toeye), 0.0f), mat.specular.w); diffuse = diffusefactor * mat.diffuse * l.diffuse; spec = specfactor * mat.specular * l.specular; } float att = 1.0f / dot(l.att, float3(1.0f, d, d*d)); diffuse *= att; spec *= att; } void computespotlight(material mat, spotlight l, float3 pos, float3 normal, float3 toeye, out float4 ambient, out float4 diffuse, out float4 spec) { ambient = float4(0.0f, 0.0f, 0.0f, 0.0f); diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f); spec = float4(0.0f, 0.0f, 0.0f, 0.f); float3 lightvec = l.position - pos; float d = length(lightvec); if( d > l.range ) return; lightvec /= d; ambient = mat.ambient * l.ambient; float diffusefactor = dot(lightvec, normal); [flatten] if( diffusefactor > 0.0f ) { float3 v = reflect(-lightvec, normal); float specfactor = pow(max(dot(v, toeye), 0.0f), mat.specular.w); diffuse = diffusefactor * mat.diffuse * l.diffuse; spec = specfactor * mat.specular * l.specular; } float spot = pow(max(dot(-lightvec, l.direction), 0.0f), l.spot); float att = spot / dot(l.att, float3(1.0f, d, d*d)); ambient *= spot; diffuse *= att; spec *= att; } cbuffer cbperframe { directionallight gdirlight; pointlight gpointlight; spotlight gspotlight; float3 geyeposw; }; cbuffer cbperobject { float4x4 gworld; float4x4 gworldinvtranspose; float4x4 gworldviewproj; material gmaterial; }; struct vertexin { float3 posl : position; float3 normall : normal; }; struct vertexout { float4 posh : sv_position; float3 posw : position; float3 normalw: normal; }; vertexout vs(vertexin vin) { vertexout vout; vout.posw = mul(float4(vin.posl, 1.0f), gworld).xyz; vout.normalw = mul(vin.normall, (float3x3)gworldinvtranspose); vout.posh = mul(float4(vin.posl, 1.0f), gworldviewproj); homecoming vout; } float4 ps(vertexout pin) : sv_target { pin.normalw = normalize(pin.normalw); float3 toeyew = normalize(geyeposw - pin.posw); float4 ambient = float4(0.0f, 0.0f, 0.0f, 0.0f); float4 diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f); float4 spec = float4(0.0f, 0.0f, 0.0f, 0.0f); float4 a, d, s; computedirectionallight(gmaterial, gdirlight, pin.normalw, toeyew, a, d, s); ambient += a; diffuse += d; spec += s; computepointlight(gmaterial, gpointlight, pin.posw, pin.normalw, toeyew, a, d, s); ambient += a; diffuse += d; spec += s; computespotlight(gmaterial, gspotlight, pin.posw, pin.normalw, toeyew, a, d, s); ambient += a; diffuse += d; spec += s; float4 litcolor = ambient + diffuse + spec; litcolor.a = gmaterial.diffuse.a; homecoming litcolor; }

code in cpp file:

struct vertex { xmfloat3 pos; xmfloat3 normal; }; struct cbuffer{ xmmatrix gworldviewproj; }; class boxapp : public framework_app { public: boxapp(hinstance hinstance); ~boxapp(); bool init(); void onresize(); void updatescene(float dt); void drawscene(); void onmousedown(wparam btnstate, int x, int y); void onmouseup(wparam btnstate, int x, int y); void onmousemove(wparam btnstate, int x, int y); private: void buildgeometrybuffers(); void buildfx(); private: id3d11buffer* mboxvb; id3d11buffer* mboxib; id3d11buffer* mboxcb = nullptr; id3d11vertexshader* pvs; id3d11pixelshader* pps; id3d11inputlayout* minputlayout; xmfloat4x4 mworld; xmfloat4x4 mview; xmfloat4x4 mproj; xmfloat3 meyeposw; xmfloat3 getnormal(float x, float z)const; //licht variablen directionallight mdirlight; pointlight mpointlight; spotlight mspotlight; material mlandmat; material mwavesmat; float mtheta; float mphi; float mradius; float getheight(float x, float z)const; point mlastmousepos; }; int winapi winmain(hinstance hinstance, hinstance previnstance, pstr cmdline, int showcmd) { boxapp theapp(hinstance); if (!theapp.init()) homecoming 0; homecoming theapp.app_run(); } boxapp::boxapp(hinstance hinstance) : framework_app(hinstance), mboxvb(0), mboxib(0), mboxcb(0) ,pvs(0), pps(0), minputlayout(0), meyeposw(0.0f, 0.0f, 0.0f), mtheta(1.5f*mathtools::halftau), mphi(0.25f*mathtools::halftau), mradius(5.0f) { mlastmousepos.x = 0; mlastmousepos.y = 0; xmmatrix = xmmatrixidentity(); xmstorefloat4x4(&mworld, i); xmstorefloat4x4(&mview, i); xmstorefloat4x4(&mproj, i); //directional lite mdirlight.ambient = xmfloat4(0.2f, 0.2f, 0.2f, 1.0f); mdirlight.diffuse = xmfloat4(0.5f, 0.5f, 0.5f, 1.0f); mdirlight.specular = xmfloat4(0.5f, 0.5f, 0.5f, 1.0f); mdirlight.direction = xmfloat3(0.57735f, -0.57735f, 0.57735f); //point lite mpointlight.ambient = xmfloat4(0.3f, 0.3, 0.3f, 1.0f); mpointlight.diffuse = xmfloat4(0.7f, 0.7f, 0.7f, 1.0f); mpointlight.specular = xmfloat4(0.7f, 0.7f, 0.7f, 1.0f); mpointlight.att = xmfloat3(0.0f, 0.1f, 0.0f); mpointlight.range = 25.0f; //spot lite mspotlight.ambient = xmfloat4(0.0f, 0.0f, 0.0f, 1.0f); mspotlight.diffuse = xmfloat4(1.0f, 1.0f, 0.0f, 1.0f); mspotlight.specular = xmfloat4(1.0f, 1.0f, 1.0f, 1.0f); mspotlight.att = xmfloat3(1.0f, 0.0f, 0.0f); mspotlight.spot = 96.0f; mspotlight.range = 1000.0f; //materials mlandmat.ambient = xmfloat4(0.48f, 0.77f, 0.46f, 1.0f); mlandmat.diffuse = xmfloat4(0.48f, 0.77f, 0.46f, 1.0f); mlandmat.specular = xmfloat4(0.2f, 0.2f, 0.2f, 16.0f); } boxapp::~boxapp() { releasecom(mboxvb); releasecom(mboxib); releasecom(mboxcb); releasecom(pvs); releasecom(pps); releasecom(minputlayout); } bool boxapp::init() { if (!framework_app::app_init()) homecoming false; buildgeometrybuffers(); buildfx(); homecoming true; } void boxapp::onresize() { framework_app::onresize(); // window resized, update aspect ratio , recompute projection matrix. xmmatrix p = xmmatrixperspectivefovlh(0.25f*mathtools::halftau, aspectratio(), 1.0f, 1000.0f); xmstorefloat4x4(&mproj, p); } void boxapp::updatescene(float dt) { // convert spherical cartesian coordinates. float x = mradius*sinf(mphi)*cosf(mtheta); float z = mradius*sinf(mphi)*sinf(mtheta); float y = mradius*cosf(mphi); meyeposw = xmfloat3(x, y ,z); // build view matrix. xmvector pos = xmvectorset(x, y, z, 1.0f); xmvector target = xmvectorzero(); xmvector = xmvectorset(0.0f, 1.0f, 0.0f, 0.0f); xmmatrix v = xmmatrixlookatlh(pos, target, up); xmstorefloat4x4(&mview, v); //update lights mpointlight.position.x = 70.0f*cosf(0.2f*mtimer.totaltime()); mpointlight.position.z = 70.0f*sinf(0.2f*mtimer.totaltime()); mpointlight.position.y = mathtools::max(getheight(mpointlight.position.x, mpointlight.position.z), -3.0f) + 10.0f; mspotlight.position = meyeposw; xmstorefloat3(&mspotlight.direction, xmvector3normalize(target - pos)); } void boxapp::drawscene() { maindevcontext->clearrendertargetview(mrendertargetview, reinterpret_cast<const float*>(&colors::lightsteelblue)); maindevcontext->cleardepthstencilview(mdepthstencilview, d3d11_clear_depth | d3d11_clear_stencil, 1.0f, 0); maindevcontext->iasetinputlayout(minputlayout); maindevcontext->iasetprimitivetopology(d3d11_primitive_topology_trianglelist); uint stride = sizeof(vertex); uint offset = 0; maindevcontext->iasetvertexbuffers(0, 1, &mboxvb, &stride, &offset); maindevcontext->iasetindexbuffer(mboxib, dxgi_format_r32_uint, 0); // set constants xmmatrix world = xmloadfloat4x4(&mworld); xmmatrix view = xmloadfloat4x4(&mview); xmmatrix proj = xmloadfloat4x4(&mproj); xmmatrix worldviewproj = world*view*proj; xmmatrix worldviewprojtrns = xmmatrixtranspose(worldviewproj); cbuffer cbuffer; cbuffer.gworldviewproj = worldviewprojtrns; maindevcontext->updatesubresource(mboxcb, 0, 0, &cbuffer, 0, 0); maindevcontext->drawindexed(36, 0, 0); mswapchain->present(0, 0); } void boxapp::onmousedown(wparam btnstate, int x, int y) { mlastmousepos.x = x; mlastmousepos.y = y; setcapture(frmewrkmainwnd); } void boxapp::onmouseup(wparam btnstate, int x, int y) { releasecapture(); } void boxapp::onmousemove(wparam btnstate, int x, int y) { if ((btnstate & mk_lbutton) != 0) { // create each pixel correspond quarter of degree. float dx = xmconverttoradians(0.25f*static_cast<float>(x - mlastmousepos.x)); float dy = xmconverttoradians(0.25f*static_cast<float>(y - mlastmousepos.y)); // update angles based on input orbit photographic camera around box. mtheta += dx; mphi += dy; // restrict angle mphi. mphi = mathtools::clamp(mphi, 0.1f, mathtools::halftau - 0.1f); } else if ((btnstate & mk_rbutton) != 0) { // create each pixel correspond 0.005 unit in scene. float dx = 0.005f*static_cast<float>(x - mlastmousepos.x); float dy = 0.005f*static_cast<float>(y - mlastmousepos.y); // update photographic camera radius based on input. mradius += dx - dy; // restrict radius. mradius = mathtools::clamp(mradius, 3.0f, 15.0f); } mlastmousepos.x = x; mlastmousepos.y = y; } void boxapp::buildgeometrybuffers() { // create vertex buffer vertex vertices[] = { { xmfloat3(-1.0f, -1.0f, -1.0f), (const float*)&colors::white }, { xmfloat3(-1.0f, +1.0f, -1.0f), (const float*)&colors::black }, { xmfloat3(+1.0f, +1.0f, -1.0f), (const float*)&colors::red }, { xmfloat3(+1.0f, -1.0f, -1.0f), (const float*)&colors::green }, { xmfloat3(-1.0f, -1.0f, +1.0f), (const float*)&colors::blue }, { xmfloat3(-1.0f, +1.0f, +1.0f), (const float*)&colors::yellow }, { xmfloat3(+1.0f, +1.0f, +1.0f), (const float*)&colors::cyan }, { xmfloat3(+1.0f, -1.0f, +1.0f), (const float*)&colors::magneta } }; d3d11_buffer_desc vbd; vbd.usage = d3d11_usage_immutable; vbd.bytewidth = sizeof(vertex)* 8; vbd.bindflags = d3d11_bind_vertex_buffer; vbd.cpuaccessflags = 0; vbd.miscflags = 0; vbd.structurebytestride = 0; d3d11_subresource_data vinitdata; vinitdata.psysmem = vertices; maind3ddevice->createbuffer(&vbd, &vinitdata, &mboxvb); // create index buffer uint indices[] = { // front end face 0, 1, 2, 0, 2, 3, // face 4, 6, 5, 4, 7, 6, // left face 4, 5, 1, 4, 1, 0, // right face 3, 2, 6, 3, 6, 7, // top face 1, 5, 6, 1, 6, 2, // bottom face 4, 0, 3, 4, 3, 7 }; d3d11_buffer_desc ibd; ibd.usage = d3d11_usage_immutable; ibd.bytewidth = sizeof(uint)* 36; ibd.bindflags = d3d11_bind_index_buffer; ibd.cpuaccessflags = 0; ibd.miscflags = 0; ibd.structurebytestride = 0; d3d11_subresource_data iinitdata; iinitdata.psysmem = indices; maind3ddevice->createbuffer(&ibd, &iinitdata, &mboxib); } float boxapp::getheight(float x, float z)const { homecoming 0.3f*(z*sinf(0.1f*x) + x*cosf(0.1*z)); } xmfloat3 boxapp::getnormal(float x, float z)const { xmfloat3 n(-0.03f*z*cosf(0.1f*x) - 0.3f*cosf(0.1f*z), 1.0f, -0.3f*sinf(0.1f*x) - 0.03f*x*sinf(0.1f*z)); xmvector unitnormal = xmvector3normalize(xmloadfloat3(&n)); xmstorefloat3(&n, unitnormal); homecoming n; } void boxapp::buildfx() { id3d10blob* vs; id3d10blob* ps; d3dx11compilefromfile((lpstr)"mcolor.shader",0,0, "vs", "vs_4_0", 0, 0, 0, &vs, 0, 0); d3dx11compilefromfile((lpstr)"mcolor.shader", 0, 0, "ps", "ps_4_0", 0, 0, 0, &ps, 0, 0); maind3ddevice->createvertexshader(vs->getbufferpointer(), vs->getbuffersize(), null, &pvs); maind3ddevice->createpixelshader(ps->getbufferpointer(), ps->getbuffersize(), null, &pps); maindevcontext->vssetshader(pvs, 0, 0); maindevcontext->pssetshader(pps, 0, 0); d3d11_input_element_desc vertexdesc[] = { { "position", 0, dxgi_format_r32g32b32_float, 0, 0, d3d11_input_per_vertex_data, 0 }, { "normal", 0, dxgi_format_r32g32b32a32_float, 0, 12, d3d11_input_per_vertex_data, 0 } }; maind3ddevice->createinputlayout(vertexdesc, 2, vs->getbufferpointer(), vs->getbuffersize() ,&minputlayout); maindevcontext->iasetinputlayout(minputlayout); d3d11_buffer_desc bd; zeromemory(&bd, sizeof(bd)); bd.usage = d3d11_usage_default; bd.bytewidth = sizeof(cbuffer); bd.bindflags = d3d11_bind_constant_buffer; maind3ddevice->createbuffer(&bd, nullptr, &mboxcb); maindevcontext->vssetconstantbuffers(0, 1, &mboxcb); }

i think have alot of errors in code.

folow these tutorials aswell, might easier whole view then: http://web.archive.org/web/20140213145557/http://rastertek.com/tutdx11.html

one example, run buildfx() @ start, pretty sure should set these 2 functions every frame

maindevcontext->vssetshader(pvs, 0, 0); maindevcontext->pssetshader(pps, 0, 0);

have succeded rendered cube pure colors yet? if should build there. there alot of code mention lastly 5 functions run every frame those:

devicecontext->iasetinputlayout(m_layout); devicecontext->vssetshader(m_vertexshader, null, 0); devicecontext->pssetshader(m_pixelshader, null, 0); devicecontext->pssetsamplers(0, 1, &m_samplestate); devicecontext->drawindexed(indexcount, 0, 0);

read link , cut down downwards errors. havent read of code.

c++ visual-c++ directx directx-11

ios - Flash CameraUI orientation is wrong -



ios - Flash CameraUI orientation is wrong -

we're developing air app android , ios. of import part of app taking photos. using flash.media.cameraui works on android, experience problems on ios.

in ios photographic camera application, when rotate ipad, orientation wrong: if rotate pad clockwise, image rotated anticlockwise. ui buttons have right orientation though, , when photo taken, resulting bitmap has right orentation based on orientation of camera, not actual view on screen.

looking @ different photographic camera apps, notice when pad rotated orientation changes clockwise, photographic camera 3 things: first, displayed image becomes rotated 90 degrees anti-clockwise (so looks wrong). then, image rotates 90 degrees clockwise, restore right orientation. in addition, ui buttons alter orientation text displayed correctly.

it seems in our app, rotates image without doing first immediate rotation. thus, end result wrong.

anyone know how prepare this?

after more research, found issue isn't restricted air. uiimagepickercontroller photographic camera view rotating strangely on ios 8 (pictures)

ios flash camera

php - Using a function to query a database -



php - Using a function to query a database -

i have page , help / advice create improve way / function phone call in info table.

at moment, code looks like: [i know deprecated sql , nice sqli this.]

<? $menuid = "100"; $imageid = "50"; // ** talk 'imagedirectory' table mysql_select_db($database_db, $basedb); $query_displayimage = "select * imagedirectory menuid = ".$menuid." , imageid = ".$imageid.""; $displayimage = mysql_query($query_displayimage, $basedb) or die(mysql_error()); $row_displayimage= mysql_fetch_assoc($displayimage); ?> <img src="/images/assets/<?php echo $menuid; ?>-<?php echo $imageid; ?>-<?php echo $row_displayimage['urlslug']; ?>.jpg" alt="<?php echo $row_displayimage['alttext']; ?>" />

i figure there has improve way because if there 10 images on page, pretty intense way of doing it.

since seem know mysql_* deprecated, assuming have read on, , using mysqli_* instead.

you needn't query database every time. mysqli_query() returns mysqli_result, can iterate over, , read using functions mysqli_fetch_assoc(). here 1 way of doing it:

<?php // store query in variable. $query_displayimage = "select * imagedirectory"; // query database. $displayimage = mysqli_query($query_displayimage, $basedb); // check errors. $dberrors = mysqli_error($basedb); if (count($dberrors)) { print_r($dberrors); die(); } // iterate on returned resource. while ($row_displayimage = mysql_fetch_assoc($displayimage)) { echo '<img src="/images/assets/' . $menuid . '-' . $imageid . '-' . $row_displayimage['urlslug'] . '.jpg" alt="' . $row_displayimage['alttext'] . '" />'; } ?>

hope helped.

edit:

you can utilize code in function, too. example:

<?php function printimage($menuid, $imageid) { $query_displayimage = "select * imagedirectory"; $displayimage = mysqli_query($query_displayimage, $basedb); $dberrors = mysqli_error($basedb); if (count($dberrors)) { print_r($dberrors); die(); } if ($row_displayimage = mysql_fetch_assoc($displayimage)) { echo '<img src="/images/assets/' . $menuid . '-' . $imageid . '-' . $row_displayimage['urlslug'] . '.jpg" alt="' . $row_displayimage['alttext'] . '" />'; } else // if there problem getting image { echo 'error getting image.'; } } ?>

and elsewhere in html, like:

<div> , here image! <?php printimage(20, 50); ?> </div>

php

sql server - How to calculate totals across columns with muliple criteria? -



sql server - How to calculate totals across columns with muliple criteria? -

i'm trying add together totals per grade level, of each programme code. there more 26 programme codes total, , scattered on 6 columns. need total programme codes school, grade, output shows.

i'm sorry have no code, don't know start on this.

dataset:

output desired:

the totals on output grouped school, gradelevel.

can sql this, if so, how please?

thank you!

this should started

select school_code ,grade_level ,sum(case when [program code 1] = 'a' or [program code 2] = 'a' or [program code 3] = 'a' or [program code 4] = 'a' or [program code 5] = 'a' or [program code 6] = 'a' 1 else 0 end )as ,sum(case when [program code 1] = 'b' or [program code 2] = 'b' or [program code 3] = 'b' or [program code 4] = 'b' or [program code 5] = 'b' or [program code 6] = 'b' 1 else 0 end )as b ,sum(case when [program code 1] = 'c' or [program code 2] = 'c' or [program code 3] = 'c' or [program code 4] = 'c' or [program code 5] = 'c' or [program code 6] = 'c' 1 else 0 end )as c --... repeat above or many programme codes have --whatever table need utilize grouping school_code ,grade_level

sql-server tsql

opengl - How do I render a 2D Sprite using WebGL? -



opengl - How do I render a 2D Sprite using WebGL? -

i'm struggling render 2d sprite canvas using dart , webgl. can find few examples of online; either 3d, or contain tons of spaghetti code no real explanation of they're doing. i'm trying simplest thing renders sprite.

so far, i've managed render greenish square (two triangles) on canvas. bit i'm struggling with, how alter greenish square using texture (the texture loaded , bound correctly, believe). think need changes shaders (to take texture co-ords, instead of colour) , pass texture coords relating vertices in buffer.

this code also exists in gist.

note: throwaway sample; of code lives in constructor; i'm not interested in how tidy code now; can tidy when can see sprite on screen!

note: i'm not interested in using third-party library; i'm doing larn webgl!

<!doctype html> <html> <head> <title>mysecondgame</title> </head> <body> <canvas width="1024" height="768"></canvas> <div style="display: none;"> <img id="img-player" src="assets/player.png" /> </div> <script id="vertex" type="x-shader"> attribute vec2 avertexposition; void main() { gl_position = vec4(avertexposition, 0.0, 1.0); } </script> <script id="fragment" type="x-shader"> #ifdef gl_es precision highp float; #endif uniform vec4 ucolor; void main() { gl_fragcolor = ucolor; } </script> <script type="application/dart"> import 'dart:async'; import 'dart:html'; import 'dart:math'; import 'dart:typed_data'; import 'dart:web_gl'; game game; main() { game = new game(document.queryselector('canvas')); } class game { renderingcontext _gl; buffer vbuffer; int numitems; texture playertexture; double elapsedtime; double fadeamount; game(canvaselement canvas) { _gl = canvas.getcontext3d(); playertexture = _gl.createtexture(); _gl.bindtexture(texture_2d, playertexture); _gl.teximage2duntyped(texture_2d, 0, rgba, rgba, unsigned_byte, document.queryselector('#img-player')); _gl.texparameteri(texture_2d, texture_mag_filter, nearest); _gl.texparameteri(texture_2d, texture_min_filter, linear_mipmap_nearest); _gl.generatemipmap(texture_2d); _gl.bindtexture(texture_2d, null); var vsscript = document.queryselector('#vertex'); var vs = _gl.createshader(vertex_shader); _gl.shadersource(vs, vsscript.text); _gl.compileshader(vs); var fsscript = document.queryselector('#fragment'); var fs = _gl.createshader(fragment_shader); _gl.shadersource(fs, fsscript.text); _gl.compileshader(fs); var programme = _gl.createprogram(); _gl.attachshader(program, vs); _gl.attachshader(program, fs); _gl.linkprogram(program); if (!_gl.getshaderparameter(vs, compile_status)) print(_gl.getshaderinfolog(vs)); if (!_gl.getshaderparameter(fs, compile_status)) print(_gl.getshaderinfolog(fs)); if (!_gl.getprogramparameter(program, link_status)) print(_gl.getprograminfolog(program)); var aspect = canvas.width / canvas.height; var vertices = new float32list.fromlist([ -0.5, 0.5 * aspect, 0.5, 0.5 * aspect, 0.5, -0.5 * aspect, // triangle 1 -0.5, 0.5 * aspect, 0.5,-0.5 * aspect, -0.5, -0.5 * aspect // triangle 2 ]); vbuffer = _gl.createbuffer(); _gl.bindbuffer(array_buffer, vbuffer); _gl.bufferdata(array_buffer, vertices, static_draw); numitems = vertices.length ~/ 2; _gl.useprogram(program); var ucolor = _gl.getuniformlocation(program, "ucolor"); _gl.uniform4fv(ucolor, new float32list.fromlist([0.0, 0.3, 0.0, 1.0])); var avertexposition = _gl.getattriblocation(program, "avertexposition"); _gl.enablevertexattribarray(avertexposition); _gl.vertexattribpointer(avertexposition, 2, float, false, 0, 0); window.animationframe.then(_gameloop); } _gameloop(num time) { elapsedtime = time; _update(); _render(); window.animationframe.then(_gameloop); } _update() { // utilize sine curve fading. sine -1-1, tweak 0 - 1. fadeamount = (sin(elapsedtime/1000) / 2) + 0.5; } _render() { // set colour clearing to. _gl.clearcolor(fadeamount, 1 - fadeamount, 0.0, 1.0); // clear. _gl.clear(renderingcontext.color_buffer_bit); _gl.bindtexture(texture_2d, playertexture); _gl.drawarrays(triangles, 0, numitems); _gl.bindtexture(texture_2d, null); } } </script> <script src="packages/browser/dart.js"></script> </body> </html>

(tagging opengl because believe solution same webgl/opengl).

ok, managed create work. can see total diff in gist here.

i might wrong; seems expecting set info in buffers while setting them up; couldn't find way info buffer. split code setup code:

vbuffer = _gl.createbuffer(); _gl.bindbuffer(array_buffer, vbuffer); _gl.bufferdata(array_buffer, vertices, static_draw); numitems = vertices.length ~/ 2; tbuffer = _gl.createbuffer(); _gl.bindbuffer(array_buffer, tbuffer); _gl.bufferdata(array_buffer, texturecoords, static_draw); avertexposition = _gl.getattriblocation(program, "avertexposition"); _gl.enablevertexattribarray(avertexposition); atexturecoord = _gl.getattriblocation(program, "atexturecoord"); _gl.enablevertexattribarray(atexturecoord); usampler = _gl.getuniformlocation(program, "usampler");

and rendering code:

_gl.bindbuffer(array_buffer, vbuffer); _gl.vertexattribpointer(avertexposition, 2, float, false, 0, 0); _gl.bindbuffer(array_buffer, tbuffer); _gl.vertexattribpointer(atexturecoord, 2, float, false, 0, 0); _gl.bindtexture(texture_2d, playertexture); _gl.uniform1i(usampler, 0); _gl.drawarrays(triangles, 0, numitems);

i'm not exclusively sure if right (it feels i'm sending same vertex , texturecoord every frame), it's working.

opengl opengl-es html5-canvas dart webgl

c# - Automapper parent-child self referencing loop -



c# - Automapper parent-child self referencing loop -

i'm trying map list model object kid has reference parent. json serialization throw "self referencing loop detected" error message. model classes:

public class event { public int id { get; set; } public string name { get; set; } public icollection<eventelement> eventelements { get; set; } ... } public class eventelement { public int id { get; set; } ... public int eventid { get; set; } public virtual event event { get; set; } }

i had tried tricks in automapper configuration. first, throw same error: mapper.createmap() .formember(vm => vm.eventelements, opt => opt.mapfrom(src => src.eventelements));

second, homecoming null each object in list: mapper.createmap().maxdepth(1);

how can event info childs without circular loop?

you need disable proxy creation in dbcontext below:

dbcontext.configuration.proxycreationenabled = false;

and utilize "include" lambda look in repository

public iqueryable<customer> getallcustomers() { homecoming dbset.asqueryable().include(s => s.statustype).include(s => s.customercategory); }

c# automapper-3

qsub - Can I use PBS environment variables inside the PBS directives of my script? -



qsub - Can I use PBS environment variables inside the PBS directives of my script? -

something like:

#pbs -t 0-99 #pbs -d "~/$pbs_arrayid.output"

what want here redefine working directory of each individual job in job array, using job's array id. valid code?

i need know before send cluster, because can't run tests there.

yes, can utilize of environment variables listed here in -d, -o, or -e.

pbs qsub torque

Django dictionary object shows nothing in template but prints to console -



Django dictionary object shows nothing in template but prints to console -

following django's tutorials https://docs.djangoproject.com/en/1.6/topics/db/sql/#executing-custom-sql-directly have called stored procedure , populated dictionary object.

views.py

@login_required def team_edit(request): user_instance = request.user user_id = user_instance.id cursor = connection.cursor() cursor.execute("call test(%s)", user_id) #call db stored procedure results = dictfetchall(cursor) print(results) homecoming render_to_response('team_edit.html',results, context_instance=requestcontext(request)) # converts list dict def dictfetchall(cursor): "returns rows cursor dict" desc = cursor.description homecoming [ dict(zip([col[0] col in desc], row)) row in cursor.fetchall() ]

printing print(results) shows in console:

[{'private_league_name': "root's league", 'host_user_id': 1}, {'private_league_name': "joe's league", 'host_user_id': 3}]

however list in template shows nothing:

<h2>results test</h2><br> <ul> {% key, value in results.items %} <li> {{ key }}: {{ value }}</li> {% endfor %} </ul>

why this?

you misunderstanding dictionary used when calling render_to_response. if phone call

return render_to_response('team_edit.html',{'customer_id' : 5}, context_instance=requestcontext(request))

i able use

{{customer_id}}

somewhere in template.

in case, want

return render_to_response('team_edit.html',{'results' : results}, context_instance=requestcontext(request))

however, notice results variable list, not dictionary, in template need like

{% result in results %} {% key, value in result %} ...

django django-templates django-views

javascript - Is it worth using Backbone on a site that isn't totally RESTful? -



javascript - Is it worth using Backbone on a site that isn't totally RESTful? -

i've got site isn't rest based , i'm auditing front-end , planning on re-writing it. enjoy using backbone, not taking total advantage of backbone (since site isn't single page app , i'm not consuming or bootstrapping info on page load fetch or updating sync.

does create sense maintain backbone around or should looking elsewhere? or on top of that, should create back-end more restful?

i still using non-rest projects because helps me organize code.

if codebase easier understand , easier maintain when utilize backbone when don't, there's no shame in using it. same goes of other frameworks out there.

javascript backbone.js

javascript - Get clicked object value with AngularJS -



javascript - Get clicked object value with AngularJS -

i'm trying rewrite live search feature using angularjs, can't find how can grab clicked item in list. see below:

<div id="searchresults" ng-show="speaker.list.length > 0"> <ul ng-repeat="person in speaker.list"> <li ng-click="speaker.updatefields()">{{person.name}}</li> </ul> </div>

in speaker.updatefields() method, how reference person.name? there different way should done?

thanks.

pass in!

<li ng-click="speaker.updatefields(person.name)">{{person.name}}</li>

and js

$scope.updatefield = function(name) { //console.log(name) }

javascript angularjs