Posts

Showing posts from May, 2013

How to add a "Body" to a python mime multipart(has attachment) email -

i using following snippet send email attachment. want add message in body describing attachment, how do it? email blank body. msg = mimemultipart() msg["from"] = emailfrom msg["to"] = emailto msg["subject"] = subject ctype, encoding = mimetypes.guess_type(filetosend) if ctype none or encoding not none: ctype = "application/octet-stream" maintype, subtype = ctype.split("/", 1) if maintype == "text": fp = open(filetosend) # note: should handle calculating charset attachment = mimetext(fp.read(), _subtype=subtype) fp.close() elif maintype == "image": fp = open(filetosend, "rb") attachment = mimeimage(fp.read(), _subtype=subtype) fp.close() elif maintype == "audio": fp = open(filetosend, "rb") attachment = mimeaudio(fp.read(), _subtype=subtype) fp.close()

Android camera2 CONTROL_AE_MODE_OFF and CONTROL_AF_MODE_CONTINUOUS_PICTURE -

i want set exact sensor_exposure_time , still have continuous_picture focus. according android documentation, set sensor_exposure_time need set control_ae_mode_off . in mode, can't set control_af_mode_continuous_picture , because works if control_ae_mode != off . so, looks it's impossible. camera fv-5 have continuous_picture focus , manual set sensor_exposure_time . how possible? device nexus5 you can indeed set control_mode auto (and control_af_mode whatever want) yet still set control_ae_mode off . i know documentation doesn't read allows this, time separate control of 2 on nexus 5. control_mode seems enforce overall control when set off , merely "suggests" when set auto . is, can override each of af/ae/awb using *_control_mode settings in latter case, not former.

swing - Is it possible in Java Applet to apply mouseover in a particular cell not in all cells of a table? -

i quiet new swing.i have jtable 6 columns. 5th cell in row want mouseover. can't attach image because need @ least 10 reputation add image. please me. in advance. html code same thing want in java applet <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>simple css based pulldowns</title> <meta http-equiv="content-type" content="text/html; charset=windows-1256" /> <style type="text/css"> <!-- /* set menu style */ .menuhead { font-weight: bold; font-size: larger; background-color: #a9a9a9;} .menuchoices { background-color: #dcdcdc; width: 200px;} .menu {color: #000000; text-decoration: none;} .menu a:hover {text-decoration: underline;} /* position menus */ #menu1 {position: absolute; top: 10px; left: 10px; width: 200px;} #m

java - How to configure mvn/Jrebel/wtp/gwt/eclipse to work smoothly with changes on the service interface -

i started investigate guice-rf-activities artifact new maven gwt plugin thomas broyer. i played little bit code , added function on greetingservice on serverside. followed down path , added required bits , bytes until code calling either greetserver or insultserver method. i found, simple sdm recompile did not make method available on server. restarting tomcat did not either. saving file in eclipse did not trigger compile properly. in end, running full module compile did trick. i see problem, change on service potentially give time coffee on large projects. there "trick", did not do, or complexity of requestfactory code generation heavy, cannot use sdm + jrebel or server restart change service interfaces? update: way described thomas (thanks!) works, if plan start tomcat maven tomcat target. update2: described launcherdir approach wtp/eclipse/mvn/jrebel run. if want use eclipse wtp tomcat launcher and, do, jrebel, compile server-classes on fly, jrebel

ajax - Triggering two page at once in PHP -

suppose, have 4 pages (index.php, progressbar.php, buffering.php, trackvalue.php). want accomplish is, 1 when submit value index.php has landed in progressbar.php. 2 progressbar.php will grab current status value txt file created buffering.php. 3 buffering.php receive value index.php while submitting value @ first. , page output progress value in txt file. so have trigger , send value buffering.php while clicks submit button have land in progressbar.php not in buffering.php. don't tell me include prgressbar.php in buffering.php because have capture real time data page. , buffering enable in buffering.php can't that. don't tell me disable output buffering, reason can't that. please suggest me how can trigger script in background along passing value. please suggest me how can trigger script in background along passing value. the php page have finish processing before complete return. to sounds trying do, need create event-driven code

android - Change color Text from CustomTextView -

by default change textcolor programatically : textview.settextcolor(color.red); i need have custom textview change typeface , color default, how can change textcolor customtextview class, here code. public class customtextview extends textview { public customtextview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); } public customtextview(context context, attributeset attrs) { super(context, attrs); } public customtextview(context context) { super(context); } public void settypeface(typeface tf, int style) { if(!isineditmode()) { if (style == typeface.bold) { super.settypeface(typeface.createfromasset(getcontext().getassets(), "fonts/lato-bold.ttf")); } else if(style == typeface.italic){ // constant used set lato-light. super.settypeface(typeface.createfromasset(getcontext().getassets(), "fonts/lato-light.ttf"));

c# - ComboBox not updating display value after change -

i have following combobox on tab: <combobox name="empnorulelistbox" isreadonly="true" itemssource="{binding adjustmentsettings.empnorulecollection}" displaymemberpath="description" selecteditem="{binding adjustmentsettings.selectedempnorule, mode=twoway}" issynchronizedwithcurrentitem="true" horizontalalignment="left" width="300" /> and adjustmentsettings model is: public class adjustmentsettingsmodel : modelbase<adjustmentsettingsmodel> { public string company { get; set; } public boolean reloademployeedata { get; set; } public boolean sortbyname { get; set; } public boolean applyjustificationrules { get; set; } public int32 seednumber { get; set; } public boolean scanformismatchedcodes { get; set; } public boolean reloadhrtables { get; set; } public empnorule selectedempnorule

html - Editing element inside another element in css -

i have 2 buttons. can move position of of them, want move specific button "home" left. here html code <ul class="fullsize-nav-ul"> <li class="nav-main-item menu-home"> <a href="http://atlanticsleeptherapeutics.com/?page_id=11"> <span>home</span> </a> </li> <li class="nav-main-item menu-who-we-are"> <a href="http://atlanticsleeptherapeutics.com/?page_id=15"> <span>who are</span> </a> </li> </ul> and css code move these 2 buttons .fullsize-nav-ul { position: relative; right: 20px; bottom: 150px; } i tried way, not work #fullsize-nav-ul li.nav-main-item menu-home a{ position: relative; right: 30px; } in example changed selector class selector ( .fullsize-nav-ul ) id selector ( #fullsize-nav-ul ). not sure typo, based

Python capture command send to unix, capture output and write to file -

import subprocess cmd = 'ifconfig -a' p = subprocess.popen(cmd, shell=true, stderr=subprocess.pipe) while true: out = p.stderr.read(1) if out == '' , p.poll() != none: break if out != '': sys.stdout.write(out) sys.stdout.flush() <<<how cmd sent , it's output>>> file = open('outputfile.txt', 'w+') file.write(out) file.close() from subprocess import popen, pipe, stdout cmd = ["ifconfig", "-a"] p = popen(cmd, stdout=pipe, stderr=stdout) stdout, stderr = p.communicate() print stdout capture output , write file: python ifconfig.py > outputfile.txt

angularjs - What is the difference between ngInclude and ngRoute -

i start using ngroute because ngrouter talk here lately started realizing nginclude working fine me , i'm wondering why seems using ngrouter instead. both load templates (or fragments) , can attach controller either or. benefit using ngroute can use href load template? don't mind using ng-click , changing nginclude value true. seems easier me i'm sure i'm missing something. the point of using router assign urls pages of app. can refresh current page, or send link current page friend, or bookmark current page, , land on that page, instead of landing on home page of app.

html - Mixing bootstrap with a non-responsive div contents? -

my boss has asked me update portion of our website using bootstrap, header. using static navbar our header, , rest of page mess of table soup (i think site written 10 years ago). way code structured right this: <div class="container"> < code navbar ></code navbar> <table> <content of website> </table> </div> it looks great on desktop on mobile falls apart , zooms top left corner of website. cannot see of header or 65% of webpage. using: <meta name="viewport" content="width=device-width, initial-scale=1.0"> rewriting page in bootstrap not option, re-use header across @ least 165 different html files. guess asking possible take non-responsive part of webpage, slap responsive element zooms-out contents based on screen size? cheers! your route of least resistance wrap table in <div class="table-responsive"></div> , like: <div class="conta

forms - jQuery Password match validation - Error message doesn't hide -

working on basic registration form. user supposed type in password, type in again , they're typing 'confirm password' box, should "passwords must match" if don't , not show error if match. it'll load no error displayed, , it'll show error while typing confirm box, after matching password put in error doesn't go away. need fix? jquery script: $(":password").change(function(){ if($("#passconfirm").val() != $("#password").val() ){ $("#matchtext").show() } else{ $("#matchtext)").hide(); } }); relevant section of form: password: <input type="password" id="password" placeholder="password" > </br> </br> confirm password: <input type="password" id="passconfirm" placeholder="password" > <span class="error" id="matchtext"

c++ - How do I properly organize my inheritance classes to take advantage of polymorphism? -

i trying redesign item class. having trouble picturing how things should work. current implementation: class item : public qgraphicsitem { public: typedef enum { polygontype = qgraphicsitem::usertype + 1 } shapetype; item() {...} item(const item &copyitem) // copy constructor { m_shapetype = copyitem.getitemshape(); m_color = copyitem.getitemcolor(); setpos(copyitem.pos()); ...} qrectf boundingrect() const; qpainterpath shape() const; void setitemshape(shapetype s) { m_shapetype = s; } shapetype getitemshape() const { return m_shapetype; } int type() const { return m_shapetype; } // replace above allow qgraphicsitem casts void setitemcolor(qcolor c) { m_color = c; } qcolor getitemcolor() const { return m_color; } .... protected: void paint(qpainter *painter, const qstyleoptiongraphicsitem *option, qwidget *widget); qcolor m_color; shapetype m_shapetype; .... }; qpaint

Extract part of xml file with python etree -

i have big xml file looks 1 below. have put part of it, >2gb, see structure. basicly subnetwork parents have same structure 1 showed below. want extract part of xml file <managedelementid string="xxxx" /> (where xxx input variable). here code , xml: <create> <subnetwork networktype="gsm" userlabel="bsc"> . . </subnetwork> <subnetwork networktype="wcdma" userlabel="rnc01"> . . </subnetwork> <subnetwork networktype="ipran" userlabel="ipran"> . . </subnetwork> <subnetwork networktype="wcdma" userlabel="rnc02"> <managedelement sourcetype="cello"> <managedelementid string="3galpas" /> <primarytype type="rbs" /> . . </managedelement> <managedelement s

excel - Sub Userform calendar populating on spreadsheet cell instead of on userform -

i have run across problem of using dtpicker dates. have added own calendar popup , when in usereform , click on box or button calendar populates date on original spreadsheet (it looks in last selected cell) instead of userform - textbox8. @ loss, works intended , other times doesn't , previous. private sub date_button_1_click() userform1.textbox8 = activecell 'this first calendar button & box frmcalendar.show_cal userform1.textbox8.value = g_sdate end sub private sub textbox8_enter() userform1.textbox8 = activecell g_bform = true frmcalendar.show_cal userform1.textbox8.value = g_sdate end sub i sure staring me in face. assistance great. thanks.

java - Implement a filter which in case of null return all the data -

how implement filter in case of null returns data? example if name null should excluded filter. way in head make 100k lines of code , test of combinations. stupid. dont want this. sure there better way. collection<ojects> filter(string name, integer age, integer number) ; note : line of code not correct: to call filter method: collection<ojects> ojects = filter(string name, integer age, integer number); also there lot of details missing in question, use guide: check if conditions filter null , return elements else filter: public collection<ojects> filter(string name, integer age, integer number) { // return object if no filter if (name == null && age == null && number == null) { collection<ojects> allojects = // objects wish return allojects; } // filters collection<ojects> filteredojects = new .... // filter name if (name != null && name.lenght > 0) { /

java - Canvas object must be the same instance that was previously returned by lockCanvas -

i have custom surfaceview method dodraw() draws background , bitmap. problem when run error caused by: java.lang.illegalargumentexception: canvas object must same instance returned lockcanvas i don't see why happening. don't declare other canvases anywhere else in code. have 2 other classes, mainactivity , surfaceviewexample. mainactivity has intent open surfaceviewexample, , surfaceviewexample has method called buttons. ourview class: package com.thatoneprogrammerkid.gameminimum; import android.content.context; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.canvas; import android.util.attributeset; import android.view.surfaceholder; import android.view.surfaceview; public class ourview extends surfaceview implements surfaceholder.callback { private surfaceholder holder; private bitmap testimg; public int xcoord = 500; public int ycoord = 500; public ourview(context context) { super(

Log4net - modify logging levels for individual logger and appender combinations -

i have 2 appenders, 1 (infoappender) levelmin info filter , 1 (debugappender) without filter. works great. can set minimum logging levels individual loggers using element. want have loggers logging info (and above) infoappender , debug (and above) debugappender, chatty logger (nhibernate) logging warn (and above) infoappender , info (and above) debugappender. i looked @ solution provided in log4net logging of 2 different levels 2 different appenders same logger , doesn't work me. have following configuration: <log4net> <appender name="infoappender" type="log4net.appender.rollingfileappender"> <file value="c:\logs\" /> <appendtofile value="true" /> <rollingstyle value="date" /> <datepattern value="'info.'yyyy-mm-dd'.log.txt'"/> <staticlogfilename value="false" /> <layout type="log4net.layout.patternlayout">

variables - How to get memory address in lua? -

have checked lua documentation , haven't found function ouput specific value memory address. there function in lua allows output memory address value? or if not string blabla = tostring(obj)

android - How to transform a nested list of double values into a Java class using RxJava? -

in android client receive json data backend: [ [ 1427378400000, 553 ], [ 1427382000000, 553 ] ] here routine loads data. using rxandroid , retrofit here. private void getproductlevels() { observable<list<list<double>>> responseobservable = mproductservice.readproductlevels(); appobservable.bindfragment(this, responseobservable) .subscribeon(schedulers.io()) .observeon(androidschedulers.mainthread()) // todo: transform list<list<double>> list<productlevel> .subscribe(new subscriber<list<list<double>>>() { @override public void oncompleted() {} @override public void onerror(throwable e) {} @override public void onnext(list<list<double>> response) {} }); } how can map inner list<double> specific java class such productlevel us

shell - Grep Arguments Not Working -

i have code grep through files in cpanel unsure arguments use in shell command. currently line of code going shell_exec(): $command = "`grep -il '.$term.' ./*`"; this searching files in folder script in. adding -r argument not fix nor -d recursive. i have tried make find . -exec grep -il '.$term.' {} \; which did not work. i want ignore case show file name , not contents, want root directory lower directories. would using --include in manner @ all? have no clue why -r , -d recursive wouldn't work.

android remove view from alertdialog -

hi have mainactivity class have listview populated rss items. when click on item list app shows me alertdialog can see in message box item details. problem after show alertdialog when close , open new item app crashes giving me error: fatal exception: main.lang.illegalstateexception: specified child has parent. must call removeview() on child's parent first. here java class: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); listview = (listview) findviewbyid(r.id.listview); wv = new webview(this); try { url = new url("http://www.unikore.it/index.php/ingegneria-informatica-home?format=feed"); } catch (malformedurlexception e) { e.printstacktrace(); } new readrsstask().execute(url); listview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override

jsp - JSTL Number parsing error -

i need current year integer value (e.g. 2015) stored in variable in jsp page. jstl tags i'm using: <jsp:usebean id="date" class="java.util.date" /> <fmt:formatdate var="currentyear" value="${date}" pattern="yyyy" /> <fmt:parsenumber var="currentyear" integeronly="true" type="number" value="${currentyear}" parselocale="en-us"/> and error i'm facing in tomcat log: [javax.servlet.servletexception: javax.servlet.jsp.jspexception: in <parsenumber>, value attribute can not parsed: "wed apr 29 00:42:30 cest 2015"] root cause java.text.parseexception: unparseable number: "wed apr 29 00:42:30 cest 2015" @ java.text.numberformat.parse(numberformat.java:350) @ org.apache.taglibs.standard.tag.common.fmt.parsenumbersupport.doendtag(parsenumbersupport.java:164) @ org.apache.jsp.new_.reports_jsp._jspx_meth_fmt_005fparsenumber_00

flask - HMAC SHA1 Digest in python -

i'm using moves api fitness data. instead of querying api on regular basis use storyline notifications . it works, request api i'm unable verify hmac sha1 signature provided in request. the documentation says: all notification requests signed base64 encoded hmac-sha1 signature. signature calculated hmac_sha1(<your client secret>,<request body>|<timestamp>|<nonce>), in other words client secret key , request body, timestamp , nonce concatenated message data. http headers not included in signature. headers x-moves-signature, x-moves-timestamp , x-moves-nonce contain signature, timestamp , nonce values. timestamp unix timestamp, seconds since jan 01 1970 00:00:00 gmt. my implementation: from hmac import new hmac_new hashlib import sha1 def check_signature(signature, timestamp, nonce, client_secret, request_body): msg = request_body + timestamp.encode('utf-8') + nonce.encode('utf-8') hmac = hmac_new(k

c - Passing multi-dimensional arrays into functions and editing values -

this question has answer here: how pass 2 dimensional char array function in c [duplicate] 1 answer i'm working on creating simple wordsearch generator having problem passing 2 dimensional array through function , editing value inside. have declared array in main such: char tablevalues[xsize-1][ysize-1]; i'm filling each point in array - in main, passing through function fills array random letters , returns. void filltable(char *tablevalues){ ( int = 0 ; < xsize ; i++ ){ ( int j = 0 ; j < ysize ; j++ ){ if ( tablevalues[i][j]=='-') tablevalues[i][j] = "abcdefghijklmnopqrstuvwxyz"[rand () % 26]; } } } my problem error gets flagged @ "tablevalues[i][j]" parts, i'm not sure how else i'd edit individual points in array pointers. appreciated, thanks i calling fu

java - javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: even i have created the certificate -

am getting below exception. javax.net.ssl.sslhandshakeexception: sun.security.validator.validatorexception: pkix path building failed: i installed certificates in below 2 ways. using installcert.java "domain.com" using keytool - import. but still getting above ssl handshake exception application. is there need add tomcat also? please me. working on past 2 days. in advance. thanks, harsha. check if certificate in manage trusted root certificates. if click on certificate , not secure, need add manage trusted root certificates. then if using eclipse or similar work, need put jsscacert file(made installcert.java) %java_home%\jdk_version\jre\lib\security , add in path of eclipse -djavax.net.ssl.truststore="path_to_jssecacerts"

Docker TLS Error on Ubuntu -

i trying learn docker in ubuntu 15.04 . when give command using docker " docker info ", arise following error: fata[0000] post http:///var/run/docker.sock/v1.17/containers/create: dial unix /var/run/docker.sock: no such file or directory. trying connect tls-enabled daemon without tls? i don't understand mean. somebody me fix error. if using boot2docker , running, should solve problem eval "$(boot2docker shellinit)"

file - NoneType Buffer interface error in windows 8 -

i making text editor, can imagine there lot of manipulating text files. when double click on .py file run in python.exe in windows, throws error of 'nonetype not support buffer interface' have ever heard "buffer" programming term in context of text files, believe problem somewhere in there. here code: from tkinter import * tkinter.filedialog import * tkinter.messagebox import * import os os.chdir(os.getenv('home')) current=none backup='' def newfile(): def create_file(entry): global current global root nonlocal create_in nonlocal name_it current = open(entry.get(),'w') root.title(create_in+'/'+current.name+' - aspus') name_it.destroy() create_in=askdirectory() if create_in!='': global root os.chdir(create_in) name_it=tk() name_it.title("name file?") prompt=label(name_it, text="enter name

javascript - Chaining promises with RxJS -

i'm new rxjs , frp in general. had idea of converting existing promise chain in expressjs application observable practice. aware isn't best example maybe can shed light. what i'm trying do : i have 2 promises - prom1 , prom2 i want prom1 run before prom2 if prom1 sends reject(err), want cancel prom2 before starts. i want error message prom1 returns available onerror method on observer. var prom1 = new promise(function(resolve, reject) { if (true) { reject('reason'); } resolve(true); }); var prom2 = new promise(function(resolve, reject) { resolve(true); }); // do here? i've tried far... var source1 = rx.observable.frompromise(prom1); var source2 = source1.flatmap(rx.observable.frompromise(prom2)); var subscription = source2.subscribe( function (result) { console.log('next: ' + result); }, // want error 'reason' made available here function (err) { console.log('error: ' + err); },

security - Detect SQL injection in Groovy dynamic SQL -

how can detect sql injection vulnerability in grails app dynamic native sql? what i'm looking can tell difference between this def sql = new sql(datasource) def dynamicwhereclause = "" if (params.col) { dynamicwhereclause = " , col = :col" } // ok because dynamic sql not concatenate user input def sqlstring = "select * tab ... ${dynamicwhereclause}" sql.rows(sqlstring, params) and this def sql = new sql(datasource) def dynamicwhereclause = "" if (params.col) { // not ok - directly concatenating user input dynamicwhereclause = " , col = '" + params.col + "'" } def sqlstring = "select * tab ... ${dynamicwhereclause}" sql.rows(sqlstring) sonarqube/findbugs has rule "prepared statement generated nonconstant string" not distinguish between safe 1 , dangerous one. other options out there? how using static analysis tool such "find security bugs" . see here

android - Is it possible to get info and overlay another app from my app? -

hi new topic maybe noob question couldn't find relevant on web asking here. want make application adds more interesting rich information app not related app. that is, imagine app overlay sports betting app 1 betting company odds companies around world , compare them original data in app can get(?) is possible? yes. first of use standout library overlay app want. , second thing use info running apps on device . you cannot access information of running app directly. still have hack access other app resources via creating context of other app installed on device. maybe information help.

php - Symfony 2 KNP Menu: add CSS class to link -

i'm using knpmenubundle symfony2 , couldn't find way add css class menu generated links. what tried set class child attribute, not given link possible children menus (submenus). $menu->addchild('agb', array('uri' => '#')) ->setattribute('divider_append', true) ->setchildenattribute('class', 'childclass'); this result following html <li> <a href="#"> agb </a> <ul class="childclass"> .... </ul> </li> but need this: <li> <a href="#" class="childclass"> agb </a> <ul> .... </ul> </li> how can this? $menu->addchild('agb', array('uri' => '#')) ->setattribute('divider_append', true) ->setlinkattribute('class', 'childclass'); easy :)

haskell: filtering Strings with a certain symbol e.g '!' in a List? -

i have list of strings : ["1*1", "ab!c", "cde2", "efghi!"] want sort out every string '!' . first idea : filter (map elem '!' (list)) list string map elem '!' (list), thats not working because checkups string , not elements of strings in list... thanks help! you mapped much. filter ('!' `elem`) list should work you.... explanation: you have list of strings [string] . string list of chars, because string = [char] ... so have list of lists. [[char]] since elem works checking if single element exists in list, can call elem on each list item outer list.

java - Hibernate two foreign keys on same table -

i have teacher entity has manytoone relationship on school . that's use case, teacher can join existing school, meaning school can have many teachers, there needs 1 owner, creator or admin of particular school. @entity @primarykeyjoincolumn(name = "teacher_id", referencedcolumnname = "id") public class teacher extends user { @joincolumn(name = "school_id") @manytoone(fetch = fetchtype.eager) private school school; school entity @entity public class school extends baseentity { @onetomany(cascade = cascadetype.all, mappedby = "school") private set<teacher> teachers; this works. proper way add owner column school entity. owner id of teacher created school. assigned once during creation of school. so when adding new teacher choose create new school assigning name it. when school created assign same teacher persisted id owner created school. adding onetoone on school entity seems work @ first, it's impossibl

ios - uiscrollview programmatically in autolayout -

Image
i new auto layout concept. adding scroll view programmatically, works in ios 8 in ios 7 scroll view not working, can 1 me how can work? uiscrollview *scroll = [[uiscrollview alloc]init]; [scroll settranslatesautoresizingmaskintoconstraints:no]; scroll.contentsize=cgsizemake(480, 700+100); [contactview addsubview:scroll]; nsdictionary *scrolldic = @{@"scrollview":scroll}; nsarray *scroll_h = [nslayoutconstraint constraintswithvisualformat:@"h:[scrollview(480)]" options:0 metrics:nil views:scrolldic]; nsarray *scroll_v = [nslayoutconstraint constraintswithvisualformat:@"v:[scrollview(568)]" options:0 metrics:nil views:scrolldic]; [scroll addconstraints:scroll_h]; [scroll addconstraints:scroll_v]; nsarray *scroll_posh = [nslayoutconstraint constraintswithvisualformat:@"h:|-0-[scrollview]" options:0 metrics:nil views:scrolldic]; nsarray *scroll_posv = [nslayoutconstraint constraintswithvisualformat:@"v:|-140-[scrollview]" opti

java - How to use Calendar.getInstance with specified Locale -

i trying use calendar.getinstance(locale l) specified locale , not working. cannot figure out doing wrong. the java doc. say: getinstance public static calendar getinstance(locale alocale) gets calendar using default time zone , specified locale. the calendar returned based on current time in default time zone given locale. parameters: alocale - locale week data returns: calendar. my code: public static void main (string[] args){ locale local = new locale("pt", "br"); calendar c = calendar.getinstance(local); // here using method system.out.println(c.gettime()); // , here, cannot figure out why not working dateformat dt = dateformat.getdateinstance(dateformat.long, local); string s = dt.format(c.gettime()); system.out.println(s); // here example in portuguese brasil } output: wed apr 29 10:18:16 brt 2015 29 de abril de 2015 should first print must in locale("pt", "br&

python - RK4 giving wrong result -

i'm trying numerically solve simple second order de x'' = -x. used new variable x'=v, have 2 equations. while seems simple, somehow produces result that's far of correct result. def f(x): return -x def rk4(f=f,h=2*pi/100,x0=1,v0=0,t0=0,n=100): '''rk4''' v=[v0] x=[x0] in range(n-1): v1= h*f(x[-1]) x1= h *(v[-1]) v2= h*f(x[-1]+1/2*x1) x2= h *(v[-1]+1/2*v1) v3= h*f(x[-1]+1/2*x2) x3= h *(v[-1]+1/2*v2) v4= h*f(x[-1]+x3) x4= h *f(v[-1]+v3) v.append(v[-1]+1/6 *(v1+2*v2+2*v3+v4)) x.append(x[-1]+1/6 *(x1+2*x2+2*x3+x4)) return x,v the weird thing if use rk45 coefficients, works fine. idea on wrong? def rk4(f=f,h=2*pi/100,x0=1,v0=0,t0=0,n=100): '''rk4''' v=[v0] x=[x0] in range(n-1): v1=h*f(x[-1]) x1=h *v[-1] v2=h*f(x[-1]+1/4*x1) x2=h *(v[-1]+1/4*v1) v3=h*f(x[-1

locking - Android 4.4.2 Load app automatically -

is possible have app automatically launched , running @ start of tablet in foreground? beside that, possible password lock app avoid beeing sent backgroud. this called when device gets started public class autostarter extends broadcastreceiver { public void onreceive(context context, intent intent) { if("android.intent.action.boot_completed".equals(intent.getaction())) { //do stuff } } }

laravel - Laravel4 old debug page -

Image
how can laravel 4 debugger page in laravel 5 debugger page here to install whoops package: composer require filp/whoops then use render exceptions editing app/exceptions/handler.php : <?php namespace app\exceptions; use exception; use whoops\run whoops; use illuminate\http\response; use illuminate\foundation\exceptions\handler exceptionhandler; use pragmarx\sdk\services\exceptionhandler\service\facade sdkexceptionhandler; class handler extends exceptionhandler { protected $dontreport = [ 'symfony\component\httpkernel\exception\httpexception' ]; public function report(exception $e) { return parent::report($e); } public function render($request, exception $e) { if ($this->ishttpexception($e)) { return $this->renderhttpexception($e); } if (env('app_debug')) { return $this->whoops($e); } return parent::ren

php - questions about password_hash() -

i have little question password_hash() function, create ramdom salt me? mean don't have specify this: 'salt' => mcrypt_create_iv(22, mcrypt_dev_urandom) because suppose function creates random , different salt each of password? another question, if use password_default in function password_hash in way : password_hash("rasmuslerdorf", password_default) use password_hash("rasmuslerdorf", password_bcrypt) ? salt automatically generated, can specify own in options. of php 5.5 default algorithm bcrypt can change on time.

javascript - Textarea increase ++ one row on enter and keypress using .attr() update -

i have textarea on want increase height 1 row on every enter , on each time when text goes row wile typing. have 3 conditions, when displayed want number used rows , set rows height based on this: one: var countrows = $("textarea").val().split(/\r|\r\n|\n/).length; two: when keypress == 13 used and three: when text goes row wile typing till have achived not working :| var countrows = $("textarea").val().split(/\r|\r\n|\n/).length; var keynum = 13; //enter keynum //for default state //not calculating $("textarea").attr("rows", countrows + 1); //for enter key //not working $("textarea").on('keypress', keynum, function() { $(this).attr("rows", countrows + 1); // alert("jjj"); }); //for case whentext goes row wile typing i want using .attr() , updating attribute "rows" when 1 more row added or removed. from https://stackoverflow.com/a/10080841/480

Run SQL Select query for date with date time picker in vb.net -

i working in microsoft visual studio 2013 windows desktop. using windows form applications sql end. creating schedule , need able search few of schedules columns smalldatetime data type. trying input date time clause not seem work. have tried in sql server management studio program no success. here code: msgbox(datetimepicker1.value.tostring("yyyy-mmy-dd")) try using conn1 new sqlconnection(connstring) conn1.open() using comm1 new sqlcommand("select col1, col2, col3, " _ & "col4, col5, col6, col7, col8, " _ & "col9, col10, col11, col12, " _ & "col13, col14, col15, " _ & "col16, col17, " _ & "col18, col19, " _ & "col20, col21 table1 left join table2 " _ & "on table2.col2 = table1.col2 left join t

c# - How to Position an Object Separately from Randomized Objects in Unity? -

in 2d game have randomized objects spawned 4 5 clones each time run game. problem have different object want spawn 1 clone, , position appear after last clone of randomized objects have in game. the objects randomization works in game, need separate object want spawned independently , after last clone of randomized objects. this code using 1 line of attempt spawn independent object: (the code taken this tutorial ) using unityengine; using system; using system.collections.generic; //allows use lists. using random = unityengine.random; //tells random use unity engine random number generator. namespace completed { public class boardmanager : monobehaviour { // using serializable allows embed class sub properties in inspector. [serializable] public class count { public int minimum; //minimum value our count class. public int maximum;