Posts

Showing posts from June, 2012

python: running a loop over indexes of a sub list -

for items in things: while inputfloat != 0: thingsback[][1]=inputfloat//things[] inputfloat=inputfloat-(things[]*thingsback[][1]) things list of n elements, while thingsback list n sub-lists. want both things , thingsback start @ 0th element , loop through recursion. calculation inputfloat//things[] changes 1 index of j-th sublist in thingsback. know [] invalid syntax, used illustrative purposes. it seems there obvious solution, not seeing it. taking guess, think looking index of current item in loop? for index, items in enumerate(things): # stuff using index check out: accessing index in python 'for' loops

r - Error using DEXSeqDataSetFromHTSeq -

currently trying understand dexseq package. have design tsv file , 7 files contains counts. run following command library("dexseq"); design=read.table("dexseq_design.tsv", header=true, row.names=1); ecs = dexseqdatasetfromhtseq(countfiles=c("m0.txt", "m1.txt", "m2.txt", "m3.txt", "m4.txt", "m5.txt", "m6.txt", "m7.txt"), design=design, flattenedfile="genome.chr.gff"); the last command gives , error error in class(sampledata) %in% c("data.frame") : error in evaluating argument 'x' in selecting method function '%in%': error: argument "sampledata" missing, no default what error means , how fix it? while loading package dexseq there warning warning message: replacing previous import ‘ggplot2::position’ when loading ‘deseq2’

excel - Converting column into rows -

i have column of dates , numbers this: 24/01/2016 1 0.123 24/01/2016 2 0.121 24/01/2016 3 0.104 24/01/2016 4 0.116 24/01/2016 5 0.091 ... how can transform column in excel appears in three columns such: 24/01/2016 1 0.123 24/01/2016 2 0.121 24/01/2016 3 0.104 24/01/2016 4 0.116 24/01/2016 5 0.091 ... you can find answer here . in short, 1 of answers use following formula: =indirect(address((row($a1)-1)*3+column(a1),1))

PDFBox not returning the correct size of an image -

i new pdfbox , stuck @ finding height of image in inches. after couple of searches, piece of code working with: pdresources resources = apdpage.findresources(); graphicsstate = new pdgraphicsstate(apdpage.findcropbox()); pagewidth = apdpage.findcropbox().getwidth() / 72; pageheight = apdpage.findcropbox().getheight() / 72; @suppresswarnings("deprecation") map<string, pdxobjectimage> imageobjects = resources.getimages(); if (null == imageobjects || imageobjects.isempty()) return; (map.entry<string, pdxobjectimage> entryxobjects : imageobjects.entryset()) { pdxobjectimage image = entryxobjects.getvalue(); // system.out.println("bits per component: " + image.getbitspercomponent()); matrix ctmnew = graphicsstate.getcurrenttransformationmatrix(); float imagexscale = ctmnew.getxscale(); float imageyscale = ctmnew.getyscale();

go - Golang- invalid array bound -

when run code below error: school_mark.go:8: invalid array bound s my code: package main import "fmt" func main(){ var subj float64 fmt.println("enter how have subjects inn school: ") fmt.scanf("%f", &subj) s := subj var mark [s]float64 var float64 = 0; a<s; a++{ fmt.scanf("%f", &mark) } var total float64 var float64 i= 0; i<subj; i++{ total += mark[i] } fmt.println(total/subj) } what problem? spec: array types: the length part of array's type; must evaluate non-negative constant representable value of type int . your length in [s]float64 not constant. use slice instead of array type, , know have use integer type length, e.g.: var mark []float64 = make([]float64, int(s)) or short: mark := make([]float64, int(s)) going forward, use integer types (e.g. int ) indices. can declare in for like: for := 0; < len(mark); i++ {

css - Video background on a wordpress website not showing up properly on IE9 -

using jw player, trying embed video website background. using wordpress cms website. home page works on chrome , firefox, not show on ie 9. having hard time trying figure wrong. url website: demo website first of all, video doesn't cover whole background on resolution set width , height of video element to: video_wrapper{ width: 100%; height: 100%; } considering ie9 can explain wrong or provide screenshot?

How do C programs pass whitespace arguments to the libc system(3) calls? -

when c program calls system() run unix command, know it's possible pass arguments command, , according stackoverflow answer (from high-rep user), the system() call uses shell execute command . it surprised me see system("ls -lh >/dev/null 2>&1"); example system() call c program, since looks using same whitespace delimited "words" shell uses interactively. from standpoint sysadmin, i'd understand provisos , pitfalls when system() call going executed within c program on files or commands on system. passing whitespace-containing filenames shell script very issue-prone ; there similar issues when c program calling command? or make point blunter (though less exact): c program written novice break on whitespace-containing filenames shell script? there nothing in c source here, string pass system() run in shell context. shell parse string, c program doesn't. if @ system() function prototype : #include <stdlib.h>

java - camel handle exception when SFTP server is not available -

camel version 2.16.1 we have created sftp consumer route follows: from("sftp://fakeuser@fakehost:22" + "/?password=fakepassword" + "&pollstrategy=#pollstrategy" + "&recursive=true" + "&throwexceptiononconnectfailed=true" + "&delete=true" + "&consumer.bridgeerrorhandler=true" + "&maximumreconnectattempts=3") .onexception(exception.class).handled(true) .to("log:errorlog?level=error&showall=true&multiline=true") .setheader("any_message", constant("error occured!")) .handled(true) .end() .to((new file("c:/temp")).touri().tostring()); how configure route handle exception thrown when sftp host not available?. route cannot reach onexception section though consumer.bridgeerrorhandler=true , throwexceptiononconnectfailed=true , have custom made proxy. custom made proxy ne

java - Build rcp application show JavaSE not found when change commons-collections to 3.2.2 -

when build rcp application, show error: host plug-in javase_0.0.0 has not been found [java] [eclipse.generatefeature] inter-plug-in dependencies have not been satisfied. [java] [eclipse.generatefeature] bundle org.apache.commons.collections: [java] [eclipse.generatefeature] host plug-in javase_0.0.0 has not been found. i have changed commons-collections version 3.2.1 3.2.2 . java 1.7 , tested java 1.8 , has same problem. if rollback "commons-collections" 3.2.1, works. apache commons-collection requires (see manifest.mf): require-capability: osgi.ee;filter:="(&(osgi.ee=javase)(version=1.3))" if remove this, pde - build run. the question now: why pde build not recognize javase, version 1.3 ? build with java(tm) se runtime environment (build 1.7.0_51-b13)

sql - Inner Join vs Natural Join vs USING clause: are there any advantages? -

imagine have 2 simple tables, such as: create table departments(dept int primary key, name); create table employees(id primary key, fname, gname, dept int references departments(dept)); (simplified, of course). i have of following statements: select * employees e inner join departments d on e.dept=d.dept; select * employees e natural join departments d; select * employees e join departments d using(dept); a working example can found here: sql fiddle: http://sqlfiddle.com/#!15/864a5/13/10 they give same results — same rows. i have preferred first form because of flexibility, readability , predictability — define connected what. now, apart fact first form has duplicated column, there real advantage other 2 forms? or syntactic sugar? i can see disadvantage in latter forms expected have named primary , foreign keys same, not practical. now, apart fact first form has duplicated column, there real advantage other 2 forms? or syntactic sugar? tl;dr na

ruby - Rails 5 - Doorkeeper token create ( ArgumentError ) -

currently, i'm converting rails 4 app rails 5. i'm having error in doorkeeper in creating token. argumenterror (wrong number of arguments (given 2, expected 0..1)): app/controllers/oauth/tokens_controller.rb:4:in `create' class oauth::tokenscontroller < doorkeeper::tokenscontroller def create response = authorize_response self.headers.merge! response.headers self.response_body = if response.status == :ok json_success( response ) else json_fail( response ) end end end everything fine in rails 4.

r - Vector with function as elements -

Image
i'm try compute integral in r numerically : where cm , cf function know , gamma parameter known. what wanted compute integral a=18,19,20,...,65 hence basically, construct vector of size 48 in first element pi(18), second pi(19),untill pi(65). is possible in r ? i have tried compute integrand inside lambda (just try if works) in following way integrand <- vector(mode="numeric") (i in 1:48){ integrand[i] <- function(a.f){exp(0.83-0.071*a.f)* exp(-0.970774-0.077159*a.f)* (1/sqrt(((-0.67+0.133*a.f)^{2})*pi))*exp(-(1/(-0.67+0.133*a.f)^{2})*(i-a.f- 2)^{2})} } but obtain error: "incompatible types (from closure double) in subassignment type fix" therefore have no clue on how solving initial integral. if not mistaken, there. r powerful because vectorized, can use result: a.f <- 1:48 integrand <- exp(0.83-0.071*a.f)* exp(-0.970774-0.077159*a.f)* (1/sqrt(((-0.67+0.133*a.f)^2)*pi))* exp(-(1/(-0.67+0.133*a.f)^

function - "else" statement executed before "if" statement after `undo` is used in Python -

i have created following function allows user change shape of python turtle image he/she selects file dialog file dialog pops when specific button pressed: def turtleshape(iop = none): # "iop" supposed image path try: manipulateimage.config(state = normal) flipbutton.config(state = normal) mirrorbutton.config(state = normal) originalbutton.config(state = normal) resetturtle.config(state = normal) rotatebutton.config(state = normal) global klob # following "if-else" statement uses "iop" argument's value value "klob" if `iop` not `none` if iop != none: klob = iop print("lmcv") else: klob = filedialog.askopenfilename() print("klobby") global im im = image.open(klob) pictures.append(im) edited.clear() print(im) im.save(klob + '.gif', "gif")

python - Twilio conference moderation and participant name -

i set moderator first user joins conference , i'm using twilio-python doc me didn't see this. the first participant should moderator in order mute, kick, etc other 1 honest don't know if required i'm open "no need moderator this". also know if name related token in participant in order retrieve 1 instead of sid. ( didn't see in doc ) here server side code : @app.route('/call', methods=['get', 'post']) def call(): resp = twilio.twiml.response() from_value = request.values.get('from') = request.values.get('to') conferencename = request.values.get('conferencename') account_sid = os.environ.get("account_sid", account_sid) auth_token = os.environ.get("auth_token", auth_token) app_sid = os.environ.get("app_sid", app_sid) clienttwilio = twiliorestclient(account_sid, auth_token) elif to.startswith("conference

c# - How to point a Bind to a control inside a DataTemplate -

i have datagrid several datatemplates columns. column has button , column has textbox . need focus textbox after button has been clicked (both elements on same row). to manage focus use behavior on button need pass element focused. inside datatemplate i'm not sure on how can reference binding. any idea?

wordpress - Performance issue with ibmjstart/wp-bluemix-objectstorage -

my app running on wordpress in bluemix environment. have object storage service in bluemix environment store media files pictures. i using https://github.com/ibmjstart/wp-bluemix-objectstorage plugin upload media files directly object storage when saving media files dashboard. everything seems work - files saved object storage. however, when render pages contain lot of images, face huge lag - page takes 1 minute render. i have noticed images saved in wp_posts table url expect wordpress , row saved in wp_postmeta table mapping image object storage. during render of page row used change url of each image , believe why webpage slowing down. is there other solution or have missed out? i using ibm object storage v3 service still in beta version. have decided change object storage v1 , using v1.0 of ibmjstart/wp-bluemix-objectstorage plugin. my application running smoothly.

Difference and relationship between the hibernate session and connection pool? -

i confused hibernate session , connection pool, same thing? hibernate orm, layer between sql database , pojos. a connection pool provides way store , reuse java.sql.connection instances speed , robustness. a hibernate session wrapper around connection in order allow save pojos without directly writing sql. so hibernate session wrapper around connection . connection s held in connection pool. when call sessionfactory.opensession hibernate first takes connection supplied connection pool. creates session around connection , returns it.

how to read json within json in ios -

i have being fetched, need read whats inside data under sources "id": "cus_7ndkzw63kvtuy5", "object": "customer", "account_balance": 0, "created": 1453839669, "currency": "usd", "default_source": "card_17xdje2ezvkylo2cbnnle4ym", "delinquent": false, "description": null, "discount": null, "email": "someone@example.com", "livemode": false, "metadata": { }, "shipping": null, "sources": { "object": "list", "data": [ { "id": "card_17xdje2ezvkylo2cbnnle4ym", "object": "card", "address_city": null, "address_country": null, "address_line1": null, "address_line1_check": null, "address_line2

android - Not able to set text of textview from other activity -

i have main activity: public class mainactivity extends appcompatactivity { button btnadd; int a1 = 10; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); btnadd = (button) findviewbyid(r.id.btnadd); btnadd.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { final secondact sa = new secondact(); sa.ttl(a1); } }); } } and have other activity: public class secondact extends activity { public textview txt2; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.second); txt2 = (textview) findviewbyid(r.id.txt2); } public void numsum(int no) { txt2.settext(string.valueof(no)); } } activity_ma

regex - NGINX rewriting subfolder when folder already rewritten? -

i have /site/clients/anything rewriting /site/clients/index.php?action=$1 however want rewrite /site/clients/verify/anything to /site/clients/verify/index.php?vid=$1 things i've tried location / { try_files $uri $uri/ @extensionless-php; rewrite ^/site/clients/verify/(.+)$ /site/clients/verify/index.php?vid=$1; rewrite ^/site/clients/^(?!login|sign-up|verify\/.*$).*$ /site/clients/index.php?action=$1; index index.php index.html; } location ~ /site/clients/verify/(.+)$ { rewrite ^/site/clients/verify/(.+)$ /site/clients/verify/index.php?vid=$1; } location ~ /site/clients/^(?!login|sign-up|verify\/.*$).*$ { rewrite ^/site/clients/^(?!login|sign-up|verify\/.*$).*$ /site/clients/index.php?action=$ } location ~ /site/clients/^((?!login|sign-up|verify).)*$ { rewrite /site/clients/^((?!login|sign-up|verify).)*$ /site/clients/index.php?action=$1; } is possible? no progess has been made.

set color of grouped stacked column in highcharts -

i have requirement set color of stack column chart in relation previous stack. consider fiddle. http://jsfiddle.net/0n7g4a1e/ series: [{ name: 'john', data: [5, 3, 4, 7, 2], stack: 'actual' }, { name: 'john', data: [3, 4, 4, 2, 5], stack: 'budget' }] if jane - actual light green, jane - budget should dark green. should categories, apple through bananas. if john - acutal light blue, john - budget should dark blue. how can done? dont want specify each point color, fine automatic color gets selected, bugdet series should have shade darker actual. thanks. you need set colors highcharts in way, example, basing on default colors: var colors = highcharts.getoptions().colors.slice(0), // default colors dark = -0.5; colors[1] = highcharts.color(colors[0]).brighten(dark).get(); // using highcharts.color(), darker golor, using first color base colors[3] = highcharts.color(colors

how to use Promise with express in node.js? -

i using promise express. router.post('/registration', function(req, res) { var promise = require('promise'); var errorsarr = []; function username() { console.log("agyaaa"); return new promise(function(resolve, reject) { user.findone({ username: req.body.username }, function(err, user) { if(err) { reject(err) } else { console.log("yaha b agyaaa"); errorsarr.push({ msg: "username been taken." }); resolve(errorsarr); } }); }); } var username = username(); console.log(errorsarr); }); when log errorsarray , empty , don't know why. new in node.js. in advance. try following, , after please read following document https://www.promisejs.org/ understand how promises work. var promise = require('promise'); router.post('/registration',function(req,res,next) { function username() { console.log("agy

php - How to make Request default in Laravel 5.1 when none is given -

i using laravel 5.1 , need make default value when in field none given. so view looks like: <form name="search" method="post" action="/s"> country<input name="country" type="text"> field<input name="field" type="text"> <button type="submit" type="button">search</button> <input name="_token" value="{{ csrf_token() }}" type="hidden"> </form> the controller looks like: public function extendedpost(request $request){ $data = $request->all(); $request->input('field', 'random'); dd($data); } in laravel 5.1 documentation have: you may pass default value second argument input method. value returned if requested input value not present on request: $name = $request->input('name', 'sally'); so when have in "field" have:

Python Django What is the pythonic way to import modules -

i using django, django rest_framework build apis. directory structure looks this |-user_directory\ |-__init__.py |-models\ |-__init__.py |-contact.py |-views\ |-__init__.py |-contact.py |-myproject when writing views there lot of imports, moved them __init__.py. imports looks this file user_directory/__init__.py import logging, re, pdb logger = logging.getlogger("user_directory") file user_directory/views/__init__.py from django.http import jsonresponse rest_framework.decorators import api_view, authentication_classes, permission_classes rest_framework import status rest_status rest_framework.response import response lib.request_utils import validate_request, customtokenauthentication rest_framework.permissions import isauthenticated user_directory import * file user_directory/views/contact.py from user_directory.views import * user_directory.models.contact import contact now read @ many places doing from package import * consider

java - JxBrowser freezes whole application -

embedded jxbrowser java (swing) application. when error occurs freezes entire application ;( there way part jxbrowser error can continue work in application? best regards, pirol it's hard why error causes entire application freezing. example or steps reproduce in resolving issue. try checking dump of java threads when freezing happens. maybe error causes threads deadlock?

java - Creating parameterized Spring bean configuration -

is possible have parameterized bean template in can fill in place holders or pass arguments tell bean refer or value set? <bean id='basebean' abstract='true' argument='arg1'> <property...> . . <property name="tablename" value='arg1'> </bean> <bean id="derived1" parent='basebean(table1)' > . . </bean> <bean id="derived2" parent='basebean(table2)' > </bean> you can use propertyplaceholderconfigurer , define bean id's in properties file , control there.like use configure database properties.

angularjs - protractor different mock httpbackend responses -

i'm using mock module testing. when page gets loaded e.g. browser.get('http://localhost:5643/#/balance/import'); this api url below gets called , below response works fine. $httpbackend.whenget('https://localhost:44329/api/daystatus').respond( { 'dayid': 249, 'weekend': false, 'daystatustypeid': 5, 'balance': null } ); but when page gets loaded e.g. browser.get('http://localhost:5643/#/dashboard'); and calls api url in mock module but time want return different response. (because previous page loaded , ui test actions took place.) $httpbackend.whenget('https://localhost:44329/api/daystatus').respond( { 'dayid': 249, 'weekend': false, 'daystatustypeid': 7,

What is a branch in code coverage for javascript unit testing -

i use istanbul code coverage of unit tests in angularjs project. there 4 types of coverage , statement, branch, function , line coverage. statement, function , line allright don't understand "branch" is. explain branch is? thanks a branch runtime can choose whether can take 1 path or another. lets take following example: if(a) { foo(); } if(b) { bar(); } yay(); when reaching first line, can decide if wants go inside body of if(a) -statement. also, can decide not that. @ stage, we've seen 2 paths (one branch). the next statement after gets more interesting. can go inside if body , execute bar . can not that. remember we've had branch before. result may vary if foo called or not. so end 4 possible paths: not calling foo , not calling bar either calling foo , not calling bar not calling foo , calling bar calling both foo , bar the last yay executed, no matter if foo or bar called, doesn't count branch. code snippet

Empty User Object from Symfony after login -

i created login page symfony , twig. now, i'm trying retrieve username after login. seems, user object return securitycontroller empty , twig has rendering problem. need userobject? security.yml security: encoders: userbundle\entity\user: algorithm: bcrypt providers: in_memory: memory: ~ user_db_provider: entity: class: userbundle:user property: username firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: anonymous: ~ http_basic: ~ provider: user_db_provider form_login: login_path: /login check_path: /login_check logout: path: /logout target: / securitycontroller class securitycontroller extends controller{ /** * @route("/login", name="login_fo

android - Setting priority as PRIORITY_HIGH_ACCURACY in the LocationRequest keeps GPS on indefinitely -

i using googleapiclient track user location every 30 secs inside service , want accurate location points app depends on used priority_high_accuracy , setting keeps gps on entire duration of service , gps icon goes away after call removelocationupdates explicitly. i want following; in onlocationchanged callback location , send server , put gps sleep until next 30 secs elapse (i think might able save battery during period) not see way in reasonable way there no callbacks provided in locationrequest class. am missing here or how api designed? this setting keeps gps on entire duration of service, gps icon goes away after call removelocationupdates explicitly. that behavior implementers of play services. i think might able save battery during period the google engineers responsible portion of play services apparently disagree. example, takes while gps start receiving fixes, waits receive signals satellites. perhaps google engineers decided that, setinterv

php - Comparing array values in nested foreach -

i've 2 arrays: $rooms = [1,2,3,4,5,6,7,8,9]; $reserved_rooms = [4, 7]; i print array this: 1 2 3 room 4 reserved 5 6 room 7 reserved her code: $rooms = [1,2,3,4,5,6,7,8,9]; $reserved_rooms = [4, 7]; foreach($rooms $key=>$val){ foreach($reserved_rooms $val2){ if($val == $val2){ echo $val2." room reserved"; } else echo $val."<br>"; } } the result is: 1 1 2 2 3 3 4 room reserved4 5 5 6 6 7 7 room reserved8 8 9 9 you need move echo outside loop. $rooms = [1,2,3,4,5,6,7,8,9]; $reserved_rooms = [4, 7]; foreach($rooms $key=>$val){ $isreserved = false; // add foreach($reserved_rooms $val2){ if($val == $val2){ $isreserved = true; break; // reserved, no need check other values } } if ($isreserved) { // decide whether reserved or not echo $val." room reserved"; } else { echo $val.&q

numpy - Python histograms: Manually normalising counts and re-plotting as histogram -

Image
i tried searching similar, , closest thing find this helped me extract , manipulate data, can't figure out how re-plot histogram. have array of voltages, , have first plotted histogram of occurrences of voltages. want instead make histogram of events per hour ( y-axis of normal histogram divided number of hours took data ) , re-plot histogram manipulated y data. i have array contains number of events per hour ( composed of original y axis pyplot.hist divided number of hours data taken ), , bins histogram. have composed array using following code ( taken answer linked above ): import numpy import matplotlib.pyplot pyplot mydata = numpy.random.normal(-15, 1, 500) # seems have 'uneven' on either side of 0, otherwise code looks fine. fyi, actual data positive pyplot.figure(1) hist1 = pyplot.hist(mydata, bins=50, alpha=0.5, label='set 1', color='red') hist1_flux = [hist1[0]/5.0, 0.5*(hist1[1][1:]+hist1[1][:-1])] pyplot.figure(2) pyplot.bar(hist1_

Scala recursion function that removes number from list needs work -

i have recursive method in remove should zeroes given list. def removez(list:list[int], n:int):list[int] = list match { case nil => nil case h::t=> if (h == n) t else h :: removez(t,n) } this removes 1 0 list if list has multiple zeros won't. tried adding if else statement didn't work such as: if else(t==n) removez(t,n) how can have zeroes removed? that's because after first 0 return tail, have keep iterating: scala> def removez(list: list[int], n: int): list[int] = list match { | case nil => nil | case h :: t => | if (h == n) | removez(t, n) // 0 found, skip , iterate tail | else | h :: removez(t, n) | } removez: (list: list[int], n: int)list[int] scala> removez(list(1,0,2,0,3), 0) res0: list[int] = list(1, 2, 3)

c# - AmyuniPDF prints PDF document in wrong font (special characters) -

i using amyuni pdf creator .net print pdf using windows service. windows service running under local system user account. when tried print using above library, prints pdf in wrong font. see attachment ( wrong font in pdf printing ). this issue persists of printers such brother mfc-8890dw printer . but same printer above windows service, prints pdf when unchecked enable advanced printing features setting in above printer properties. see attachment ( disable advanced printing features ). using (filestream file1 = new filestream(pdffile, filemode.open, fileaccess.read)) { using (iacdocument doc1 = new iacdocument()) { doc1.open(file1, string.empty); doc1.copies = 1; bool printed = doc1.print(printer, false); } } but same windows service prints pdf correctly other printers such hp laserjet p1005 either enable advanced printing features checked or unchecked. without having access same printer using hard know happening. best guess

mysql - Create a last url column from current list of hits -

i have following columns: hit_id, visit_id, timestamp, page_url, page_next hit_id increments upwards visit_id id of visit , unique each visitor timestamp unix timestamp of hit page_url page being looked @ page_next page looked @ next i to add new column, page_last , previous page url go - should able extract page_url , page_next . not know why did not create column in first place, slight over-site really. is there anyway fill column using mysql trickery? page_last empty on initial hit on website (doesn't contain referrer website). i find name page_last ambiguous (does mean previous page? or last page on visit?). suggest change page_prev . the following comes close filling in, assuming no 1 visited same page multiple times in visit: select h.*, hprev.page_url page_prev hits h left outer join hits hprev on hprev.page_next = h.page_url , hprev.visit_id = h.visit_id if not true, need recent one. can using correlated subquery: select h.*

unix - xv6 KERNBASE limitation of process memory -

there question in xv6 book bothers me long time, , wondered if clarify on this kernbase limits amount of memory single process can use, might irritating on machine full 4 gb of ram. raising kernbase allow process use more memory? in opinion answer question no, since whole mechanism around xv6 designed work kernbase on specific address space. thanks answer. well, there issue here. all physical addresses supposed used mapped virtual addresses 0x80000000 , up. so, if move kernbase upawards, os can use less physical memory.

php - Laravel 5.1: How to set Route for update record -

i working laravel 5.1 i using routes of laravel. i used form/html insert/update, stuck in routing of update record. here route redirect edit page in routes.php route::get('/company/edit/{id}','companymastercontroller@edit'); in companymastercontroller.php public function edit($id) { $company = companymasters::find($id); return view('companymaster.edit', compact('company')); } my action in edit.blade.php {!! form::model($company,['method' => 'patch','action'=>['companymastercontroller@update','id'=>$company->id]]) !!} and route action in routes.php route::put('/company/update/{id}','companymastercontroller@update'); my controller action update. public function update($id) { $bookupdate=request::all(); $book= companymasters::find($id); $book->update($bookupdate); return redirect('/company/index'

c# - Render HTML and take screenshot/thumbnail -

as part of application developing, user can create document templates using html (or rather, web based rich text editor uses html). when user saves template, want able render html 'in memory' , grab thumbnail sized screenshot of output, user can see template looks in thumbnail. is possible in c#?

google cloud storage - GCS - Create bucket from App Engine - 403:Forbidden error -

i trying create gcs bucket using java api app engine project. i following error not further information. 403 forbidden { "code" : 403, "errors" : [ { "domain" : "global", "message" : "forbidden", "reason" : "forbidden" } ], "message" : "forbidden" } based on reading on internet, have checked following enable billing - done.. enable googlecloudstorage api - done .. inspite of doing these, see error. this how creating storage object --- httptransport = googlenethttptransport.newtrustedtransport(); json_factory = jacksonfactory.getdefaultinstance(); credential = googlecredential.getapplicationdefault(); //add scopes list<string> colls = new arraylist<string>(); colls.addall(storagescopes.all()); if (credential.createscopedrequired()) { credential = credential.createscoped(colls); } //build storage storage = new storage.builder(htt

c# - Create constant size Background Image in Wrap Panel in WPF -

i want implement container has list items scroll able setting wrap panel's background image image stretching according items of wrap panel. want make background fixed content can scrolled without stretching background image. using following code. <scrollviewer x:name="imagescrollviewer" verticalscrollbarvisibility="auto" horizontalscrollbarvisibility="disabled"> <wrappanel x:name="panel" orientation="horizontal" > <wrappanel.background> <visualbrush> <visualbrush.visual> <image name="pnlbackground"> <image.opacitymask> <lineargradientbrush startpoint="0,0.5" endpoint="1,0.5" > <gradientstop offset="0.0" color="#00000000" /&

angularjs - How to support ng-model in my custom input (angular directive) -

i'm working on angular directive form input kind of widget. user picks values using input , want result available in ng-model, that: <mydirective ng-model="mod"> </mydirective> i heard got lot easier in new versions of angular 1. upd saw similar question think way has been proposed of overengineering. posted short answer own question utilises link function. i think got 1 way it. suppose need directive consists of 1 input , 1 dropdown. want use form input ng-model. concatenated result going put ng-model. my solution in directive have bunch of ng-models watch scope.$watch. every time updated update ngmodel parameter injected scope. code looks this: directive: angular.module('oneclickregistration') .directive('awesomedir', function () { var tpl = "<div> \ <input type='text' ng-model='model.num' size='80' /> \ <select ng-model='model.unit'&g

sql - MySQL Query 2 records at top followed by the rest -

i'm stuck following problem. i have website example supermarket shopping items. people can search website items. want on search result page @ top 2 items displayed have selected on offer. there can lots more items on offer. so example, search shampoo, query display shampoo items in database table want 2 shampoo offer items @ top of query. there 2 or more shampoo offers in database table, other not shown. example names : table: id name c d ---------------------------------- 1 jack 1 1 2 joe 1 1 3 dave 3 0 4 sue 1 0 5 mike 1 1 6 steve 4 0 7 david 1 0 8 susan 4 1 9 marc 1 1 10 ronald 4 1 11 michael 4 1 example 1 query : c = 1 , d = 1 (but maximum of 2 'd' records, these 2 'd' records show @ top of result) d

python - How to get list of indexes of all occurences of the same value in list of lists? -

having list of lists, mylist = [[1, 3, 4], [3, 6, 7], [8, 0, -1, 3]] i need method list containing indexes of elements of value, '3' example. value of '3' such list of indexes should be [[0, 1], [1, 0], [2, 3]] thanks in advance. update : can have several instances of sought-for value ('3' in our case) in same sublist, like my_list = [[1, 3, 4], [3, 6, 7], [8, 0, -1, 3, 3]] so desired output [[0, 1], [1, 0], [2, 3], [2, 4]] . i suppose solution naive, here is: my_list = [[1, 3, 4], [3, 6, 7], [8, 0, -1, 3, 3]] value = 3 list_of_indexes = [] in range(len(my_list)): j in range(len(my_list[i])): if my_list[i][j] == value: index = i, j list_of_indexes.append(index) print list_of_indexes >>[(0, 1), (1, 0), (2, 3), (2, 4)]] it great see more compact solution assuming value appears once in each sublist, use following function, makes use of built in enumerate function , list c

java - In CustomLogoutSuccessHandler , The authentication object is always null -

i getting null authentication object in custom logoutsuccesshandler, not sure issue. :( here spring-security file: <sec:http auto-config="true" entry-point-ref="ssoprocessingfilterentrypoint" access-decision-manager-ref="affirmativebased"> <sec:intercept-url pattern="/afterauthn/**" access="${spring.security.role}" /> <sec:intercept-url pattern="/tenancy/**" access="${spring.security.role}" /> <!-- add permissions specific urls - i.e. iam.user.read /resources/** --> <sec:intercept-url pattern="/**" access="${default.permission}" /> <sec:logout invalidate-session="true" delete-cookies="true" success-handler-ref="customlogoutsuccesshandler" /> <sec:custom-filter ref="ssoauthenticationfilter" position="pre_auth_filt

node.js - How to detect from nodejs which JavaScript engine it is running on? -

there several forks of nodejs , of them support javascript engines other google's v8 engine. for node code see js engine running under, best way? the engines aware of are: google's v8 - engine supported official node.js , iojs fork. 1 of engines supported jxcore . mozilla's spidermonkey - 1 of engines supported jxcore . microsoft's chakracore - engine supported microsoft 's port of node.js , apparently 1 of engines supported jxcore though haven't got 1 work yet. ( i've asked separate question detecting fork of nodejs being used. question detecting js engine.) the process object contains lot of information running process (in case, node). my process.versions example, contains current version of v8: process: { versions: { http_parser: '2.5.0', node: '4.2.4', v8: '4.5.103.35', uv: '1.7.5', zlib: '1.2.8', ares: '1.10.1-dev',

angularjs - Event Handling in nvd3 -

i using nvd3 , trying add event handling while clicking on chart. face problems while implementing , not able solution due lack of documentation of nvd3. followed link , still following error in console: referenceerror: chart not defined can tell me missing or best solution event handling in nvd3. probably problem name of graph variable; make fiddle you. in example, "chart" name of graph variable. check out in case it's same. var chart = nv.models.multibarchart(); anyway, fiddle can see full code. if click on item, can see messages in console. http://jsfiddle.net/g952qb5c/

asp.net mvc - Microsoft Graph API auhetication for service apps -

we developing web application using microsoft graph , signed in user can, export calendar events third party calendar application. after initial export, need keep exported data in sync calendar changes via service app (a scheduled task running on server). need multi tenant application, people different organizations should able use service. right did authentication using oauth 2.0 , openid connect described in this sample . later understood access token using method cannot used in service app without user interaction. considering our scenario best way achieve this? i have read app-only authorization method this. if use authentication method, app need consented tenant administrator , these applications quite powerful in terms of data can access in office 365 organization. considering developing product used different organizations, feasible use method? to use client credentials oauth2.0 flow (aka "app-only" or service account access depending on who's doc

Formatting date in domForm.toJson in dojo -

in web application have changed dijit/form/datetextbox date format using constraints="{datepattern:'mm/dd/yyyy'}" attribute, when call form containing dijit/form/datetextbox using domform.tojson format changed yyyy/dd/mm why? how solve it dijit/form/datetextbox dojo/widget not dom . domform.tojson access dom 's value not dijit widget's get('value') function gives formatted output expect. to correct value - use dijit/form , use form.get("value") dijit form

c++ - std::thread constructor with no parameter -

according cppreference.com , std::thread constructor no parameter means: creates new thread object not represent thread. my questions are: why need constructor? , if create thread using constructor, how can "assign" thread function later? why don't have "run(function_address)" method when constructed no parameter, can specify function "run" thread . or, can construct thread callable parameter (function, functors, etc.) call "run()" method execute thread later. why std::thread not designed in way? your question suggests there might confusion , helpful separate ideas of thread of execution std::thread type, , separate both idea of "thread function". a thread of execution represents flow of control through program, corresponding os thread managed kernel. an object of type std::thread can associated thread of execution , or can "empty" , not refer thread of execution . there no such conc