Posts

Showing posts from May, 2012

javascript - Vaadin application gets hanged -

i using vaadin development of web applications. using vaadin charts in application. when go chart window entire application getting hanged. following error given in browser console: highcharts error #16 highcharts defined in page this error happens second time highcharts or highstock loaded in same page, highcharts namespace defined. keep in mind highcharts.chart constructor , features of highcharts included in highstock, if running chart , stockchart in combination, need load highstock.js file. also when check tomcat log following notification: license warning vaadin charts commercial product. after 30 days of evaluation use, must either acquire license or stop using it. more information commercial vaadin add-on license available @ https://vaadin.com/license/cval-2.0 . you may obtain valid license subscribing vaadin pro account @ https://vaadin.com/pro or purchasing perpetual license @ https://vaadin.com/directory . a

Windows phone 8.1 javascript+html local toast notification -

i display local toast notification on wp8.1 app build javascript , html. found how c# , xaml can't find anywhere how js , html. can display hello world, later on figure out myself. ok figured out. here message displays toast. , in manifest have enable toast notifications. function toast(message) { document.getelementbyid("klik").innerhtml = "bla"; var toasttextelements = toastxml.getelementsbytagname("text"); toasttextelements[0].appendchild(toastxml.createtextnode(message)); var toastnode = toastxml.selectsinglenode("/toast"); toastnode.setattribute("duration", "long"); var audio = toastxml.createelement("audio"); toastnode.appendchild(audio); var toast = new notifications.toastnotification(toastxml); var toastnotifier = notifications.toastnotificationmanager.createtoastnotifier(); toastnotifier.show(toast); }

.htaccess rewrite URL - and playground -

i have following url: http://example.com/reviews/view-course?courseid=933 which i'd show as: http://example.com/933/somethingdynamichere this i'm trying blank page: rewriterule ^([^/]*)$ /reviews/view-course?courseid=$1 [l] is there better way this? also, importantly, there playground can try changes , see results on fly can learn more? update i have html5 angular rewrite rules in file total follows: #angular html5 rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] rewriterule ^(.*) /reviews/index.html [nc,l] your pattern not matching desired pretty uri. use rule: rewriterule ^(\d+)/[^/]+/?$ reviews/view-course?courseid=$1 [l,qsa]

POST not working after rewrite .htaccess -

my forms not working after adding rewrite .htaccess. found many topics similar problem neither have solution issue. grateful if take look. there is: rewriteengine on rewritebase / rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r=301,l] rewritecond %{request_filename} !-d rewritecond %{request_filename}.php -f rewriterule ^(.*?)/?$ $1.php [nc,l] and here post code:) <?php function send_email ($to_email, $from_email, $from_name, $subject, $msg, $showinfo) { //split email array, if given if (is_array($to_email)) { $to_email_string = implode(', ', $to_email); } else { $to_email_string = $to_email; } // build content $message = '<html><body>'; $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $message .= "<tr style='background: #eee;'><td><strong>imie nazwisko: </strong> </td><td>" .

Connecting to MySQL via a batch file -

i've configured batch file check web hosted db every 30 seconds or see if value in 1 field has been set 1. i'm happy how works , results come through fine. however 1 issue have once in while script unable connect sql server. when happens script errors out , batch file stops. the connection line using is: mysql --host=xxx.xxx.xxx --port=3306 --force --user=wmc --password=xxxxxxxxx --database=xxx < xxx.sql the sql file @ end contains commands want run. read documentation said --force should make script continue after error still errors out when can't connect sql server. there way can trap error? your main problem seems error handling. change script able detect failure , retry until successful. quick test a rough test did on own system check error level pseudo environmental variable: test.bat d:\xampp\mysql\bin\mysql --host=127.0.0.1 --port=3306 --force --user=root2 --password= --database=saasplex < test.sql echo exit code %errorlevel%

Clojure parse JSON objects and extract specific key -

given have json file contents: [ { "email": "benb@mit.edu" }, { "email": "aphacker@mit.edu" }, { "email": "eval@mit.edu" }, { "email": "prolog@mit.edu" }, { "email": "bugs@mit.edu" }, { "email": "morebugs@mit.edu" }, { "email": "test@mit.edu" }, { "email": "google@google.com" } ] how can parse file , value each email tag need perform operations using values. example: retrieve list of emails (benb@mit.edu, aphacker@mit.edu...) for each element in list pass value function. understand how pass function, , have come across get-in function im not sure how use in context. optionally, if possible wish file stored benb@mit.edu aphacker@mit.edu ... which more practical. know how write file , such im not sure how extract email data. slurp rea

css3 - Mixins Gradient for IE8 -

i trying make less mixin graditent wotk in ie8, know can use gradient in ie8 this filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#1e5799', endcolorstr='#7db9e8',gradienttype=0 ); /* ie6-9 */ this juwt example, need make custom mixin create ie8, css have background-image: linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%); background-image: -o-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%); background-image: -moz-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%); background-image: -webkit-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%); background-image: -ms-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%); what need modified less mixins created .gradient (@startcolor: #eee, @endcolor: white) { background-color: @startcolor; background: -webkit-gradient(linear, left top, left bottom, from(@startcolor

php - How to write global functions in Yii2 and access them in any view (not the custom way) -

yii1.1 had ccomponent class had cbasecontroller base class ccontroller. there /protected/components/controller.php class enabled function in class accessed in view. yii2 no longer possess ccomponent class. yii2 guide indicates "yii 2.0 breaks ccomponent class in 1.1 2 classes: yii\base\object , yii\base\component". know how write global functions in yii2 , them in view, in yii1.1 using /protected/components/controller.php? a couple of similar topics discuss custom answers , know whether there official way of doing that, not custom way. follow step: 1) create following directory "backend/components" 2) create "backendcontroller.php" controller in "components" folder <?php namespace backend\components; use yii; class backendcontroller extends \yii\web\controller { public function init(){ parent::init(); } public function hello(){ return "hello yii2

linux - How to extract name of all files contained in a folder into a .txt file? -

i want extract name of files contained in folder .txt file ex: when type ls command in terminal shows list files , folder names. can store these names in .txt file. you can redirect output of ls command file > so: ls > files.txt note overwrite previous contents of files.txt . append, use >> instead so: ls >> files.txt

excel - VBA: Cell designations not being evaluated -

i have following code in vb: activecell.formula = " = companyname " & " & " & "r[-12]c[-3]" & " & " & "vlookup(rc[-6],r3c7:r22c18,9)" i want cell has in it: = companyname & d25 & vlookup(a26,$g$3:$r$22,9) instead, cell = companyname & r[-12]c[-3] & vlookup(rc[-6],r3c7:r22c18,9)" basically, cell designations not being evaluated. what doing wrong? change activecell.formula activecell.formular1c1 by using ".formula", expects cells referenced in "a1" fashion, , therefore doesn't know how compute r/c references, , appears see whole thing string instead of formula (also may need remove spaces between &'s).

winapi - Using unique_ptr / shared_ptr with API functions returning resources as out parameters via pointer -

i’m catching c++ 11/14 stuff in current project. have trouble using unique_ptr / shared_ptr api functions returning resources out parameters via pointer. let’s consider dsgetdcname(..., __out pdomain_controller_info* ppdci) example. before c++11 there widespread pattern work windows apis. have riia class holds pdomain_controller_info , calls netapibufferfree in destructor, , has pdomain_controller_info* operator&() can write: info_ptr spinfo; dsgetdcname(..., &spinfo); now c++ 11/14 see lot of articles advocating unique_ptr / shared_ptr custom deleter release resource in proper way. , works when resource returned r-value function ( loadlibrary example of this). one solution found attach raw-pointer smart pointer after api call: pdomain_controller_info pdci = nullptr; dsgetdcname(..., &pdci); std::unique_ptr<domain_controller_info, decltype(&netapibufferfree)> spinfo(pdci, &netapibufferfree); however, not way like. far understand, new sm

Setting time intervals for a plot [R] -

to previous question , dataset, how can use 20 minutes time interval. i tried both of solution both of them showing same results. data set isn't taking values when trying convert different time interval (say 20 minute). is possible convert data.frame() instead rather data.table(). 1 of answer given akrun: x y date time 1 2 1-1-01 15:00 2 5 1-1-01 17:00 3 1 1-1-01 18:00 5 7 1-1-01 21:00 2 6 1-1-01 22:00 6 3 1-1-01 23:00 9 2 2-1-01 01:00 6 1 2-1-01 04:00 ..... library(data.table) dt <- setdt(df1)[, {tmp <- as.numeric(substr(time,1,2)) list(time=sprintf('%02d:00', min(tmp):max(tmp)))}, date] df1[dt, on=c('date', 'time')] dt <- setdt(df1)[, list(time=sprintf('%02d:00', 0:23)) , date] res <- df1[dt, on=c('date', 'time') ][,{tmp <- which(!(is.na(x) & is.na(y))) .sd[tmp[1l]:tmp[length(tmp)]]}] res library(zoo) res[, c('x',

c++ - OOP menu system -

i trying make menu system (with submenus) using qgraphics qt4.8. composite pattern sounds solution got stuck. this uml diagram: http://i.stack.imgur.com/jgwpq.png the objects structured tree. +-------------+ |root |+---------------------+ +-------------+| | + | | | | | | | | | v v +-------<++ +----------+ +----------------+ |leaf1 | +---+|menunode1 | | menunode2 |+--------+ +---------+ | +----------+ +----------------+ | | + + | | | | | v v v v +---------+ +-----------+ +-------------+ +-------------+ |leaf2 | |leaf3 | | menunode

c# - Using a generic type in a Sitecore view rendering with Glass Mapper -

setup models pocos, virtual required glass mapper. using system.collections.generic; using glass.mapper.sc.configuration.attributes; using glass.mapper.sc.fields; namespace sample { public class parent<t> { [sitecoreid] public virtual guid id { get; set; } public virtual string title { get; set; } public virtual ienumerable<t> children { get; set; } } public class article { [sitecoreid] public virtual guid id { get; set; } public virtual string title { get; set; } public virtual string text { get; set; } } public class teaser { [sitecoreid] public virtual guid id { get; set; } public virtual string title { get; set; } public virtual image banner { get; set; } } } views referenced sitecore view renderings, model pointing sample.parent (see below sitecore model definitions). @inherits glass.mapper.sc.web.mvc.glassview<samp

javascript - AngularJs complex model based on drop down selection -

Image
not having lot of experience complex angular js models, i'd ask advice or help. please @ following picture. shows i'm trying accomplish. i need store number of patients center each year in drop down. when select year, input fields should blank (or populated data db). when switch 2012, input data should still present. data should submitted when button pressed. i have hard time figuring out how model , data binding should like. ideas appreciated. hopefully try may idea you. please have it. plunker: http://plnkr.co/edit/ndrk1uaoe0dkrhfssguh?p=preview code: $scope.qty = 1; $scope.cost = 2; $scope.incurr = 'eur'; $scope.currencies = ['usd', 'eur', 'cny']; $scope.usdrates = [ { quantity:0,cost:0}]; $scope.change = function() { if($scope.usdtoforeignrates === 'usd') { $scope.usdrates[0].quantity = 25; $scope.usdrates[0].cost = 30; $scope.qty =$scope.usdrates[0].quantity; $scope.cost = $scope.usdrates

Pycharm python console: variables defined in startup script not set on console startup -

i added startup.py script run whenever launch python console. script contains following: #!/usr/bin/env python abc import cde module user='me' the starting script used pycharm set following: import sys,osprint('python %s on %s' % (sys.version, sys.platform)) sys.path.extend([working_dir_and_python_paths]) os.system("{0} 1".format(os.environ.get("pythonstartup"))) where pythonstartup points location of startup.py described above. the problem when launch python console pycharm, module imports correctly, variable user not set. when type 'user' , press enter, get nameerror: name 'user' not defined

Why is LAST_VALUE() not working in SQL Server? -

Image
here's data have (note 1 entity id / employee id, there multiple. 1 entity id can have multiple employee ids under it): select entityid, employeeid, payperiodstart, isfulltime dbo.payroll employeeid = 316691 , payperiodstart <= '12/31/2014' , payperiodend >= '1/1/2014'; i want grab last "isfulltime" value each entityid & employeeid combo. i tried doing this: select entityid, employeeid, last_value(isfulltime) on (partition entityid, employeeid order entityid, employeeid, payperiodstart) lastisfulltimevalue dbo.payroll employeeid = 316691 , payperiodstart <= '12/31/2014' , payperiodend >= '1/1/2014'; but i'm getting this: the query should return 1 row each entityid / employeeid. what doing wrong? i believe looking use row_number() , last value based on payperiodstart date: select t.entityid ,t.employe

windows - Automation Microsoft SQL Server 2008 R2 using Python(pywinauto) -

i creating microsoft sql server management studio automation tool using python . problem can't select child_tree (northwind) database it's selecting parent_tree (databases). need more, clicking child_tree(northwind) right click option (ex. tasks-> backup). me best automation code. in advance. import pywinauto import socket import binascii host = socket.gethostname() #getting system host name n2 = int('0b111000001100001011100110111001101110111011011110111001001100100', 2) #password n1 = int('0b111010101110011011001010111001001101110011000010110110101100101', 2) # username n = int('0b1110011011001010111001001110110011001010111001001101110011000010110110101100101', 2) #servername av if (host == "systemhostxxx" or host == "systemhostyyy"): # checking host name try: pwa_app = pywinauto.application.application() path = pwa_app.start_(r"c:/program files (x86)/microsoft sql server/100/tools/binn/vsshell

jquery - How to get accordion menu closed by default on load -

i have jquery code make lists act accordion. accordion open on page load. can please tell me how close on page load? $(document).ready(function () { $('#nav > li > a').click(function() { if ($(this).attr('class') != 'active') { $('#nav li ul').slideup(); $(this).next().slidetoggle(); $('#nav li a').removeclass('active'); $(this).addclass('active'); } }); }); please tell me how edit keep accordion closed on page load. i dont know html code is, if want hide accordion content, think can $(window).load(function() {}); when document has finished loading, can hide accordion content hide() , or slideup() or whatever function (or maybe when dom ready?) (or if possible. throw in css hide it, though didn't ask it, i'm throwing out there sake of it) check out here or snippet bellow: $(document).ready(function() { $('#n

javascript - Bind part of string to Angular scope variable -

i'm pulling json data server. inside json object i'm returning, have strings want able use placeholders dynamically insert values entered user in ui. my understanding $compile for, can't seem work. i'm not sure if possible or if i'm approaching wrong way. edit: not sure if i'm explaining well. got little further , updated plunk , code below a simplified example ( view plunk ): view: <body ng-controller="mainctrl"> <input ng-model="name" type="text" /> <p ng-bind-html="myval">{{myval}}</p> <p>{{name}}</p> </body> angular app: var app = angular.module('plunker', ['ngsanitize']); app.controller('mainctrl', function($scope, $compile, datasvc) { init(); function init() { $scope.data = datasvc.getdata(); $scope.name = ''; } $scope.$watch('name', function(newval, oldval) { var c = $compile('

java - How to Extract JSON value outside of Array -

at moment can loop through json array '' pos " , store variables within array list. what i'm trying do: how can parse tour & date outside " pos " array? i store values in " tour " & " date " 2 separate string variables. my understanding: json.getjsonarray() can't used in case, json.getjsonarray(tag_messages); pulls in "pos" array data. json structure: { "pos": [ { "pos": "", "person": "", "thur": "", "score": "", "round": "" }, { "pos": "2", "person": "john", "thur": "", "score": "16", "round": "3" }, { "pos": &qu

sql server - T-SQL: How to have an Auto-Increment variable -

i writing set of complex xml queries. lot of them hierarchical queries select x , (select y tbl2 xml) table1 xml etc. wish way add auto increment variable add here this: select @incr [@id], x [@title], (select @incr [@id], y [@title] tbl2 xml path('node')) table1 xml path('node') i wish variable @incr return integer increments every time use it. is there easy solution this?

arrays and strings in c -

i break string sequence " " , stick array. code have not work: int main(void) { char s[] = "this string"; char* x = null; unsigned int = 0; (char *p = strtok(s," "); p != null; p = strtok(null, " ")) { x[i] = *p; puts(x[i]); i++; } return 0; } it gives me following error: error: array initializer must initializer list i @ loss on how accomplish in c. x[0] = "this" , x[1] = "is" , on. appreciated, have searched answer , read tutorials still cant come right answer. appreciated. thanks! there 2 problems code: you trying grow array go. not possible in c without using dynamic allocation realloc , or pre-allocating sufficient space, , using of it. you trying store results of strtok future use. in general, not safe, because tokens point original string. safer copy each token separate space. here how code pre-allocated space 100 tokens: int main(void) {

php - Creating a Form class doesnt work in Symfony, shows no error -

i trying create simple form in symfony form class. code shows no error not displayed in browser. has idea doing wrong? controller namespace reusebundle\controller; use symfony\bundle\frameworkbundle\controller\controller; use symfony\component\httpfoundation\request; use reusebundle\entity\company; use reusebundle\reuseforms\createcompany; class companycontroller extends controller { public function newaction() { $company = new company(); $form = $this->createform(new createcompany(),$company, array( 'action'=>$this->generateurl('reuse_create'), 'method'=>'post' )); $form->add('submit', 'submit', array('label'=>'create company')); return $this->render('reusebundle:default:create.html.twig', array( 'form'=>$form->createview() )); } public function createaction(request $request) { } } form class <?php namespa

c# - Filling an entire MenuButton with an Image -

Image
i'm trying create wpf menu consists out of 5 simple buttons filled entire single image. i've created following xaml: <menu x:name="menumain" height="40" margin="0,0,0,0" verticalalignment="top" horizontalalignment="stretch"> <menuitem x:name="menuitemprint" width="40" height="40"> <menuitem.icon> <image source="resources/images/yes.png" width="40" height="40"/> </menuitem.icon> </menuitem> <menuitem x:name="menuitemclear" width="40" height="40"> <menuitem.icon> <image source="resources/images/yes.png" width="40" height="40"/> </menuitem.icon> </menuitem> <menuitem x:name="menuitemsettings" width="40" height="40"> <menu

Precision Related Error in C++ -

while building software getting error: ../src/internet/model/nampt-socket.cc: in member function ‘ns3::ptr<ns3::namptsubflow> ns3::namptsocket::switchtomultipathmode()’: ../src/internet/model/nampt-socket.cc:881:14: error: cast ‘ns3::namptsocket*’ ‘uint32_t {aka unsigned int}’ loses precision [-fpermissive] (uint32_t)this, ^ waf: leaving directory `/home/vikas/ns-allinone-3.14.1/ns-3.14.1/build' build failed -> task in 'ns3-internet' failed (exit status 1): {task 140476688662992: cxx nampt-socket.cc -> nampt-socket.cc.1.o} ['/usr/bin/g++', '-o0', '-ggdb', '-g3', '-wall', '-werror', '-wno-error=deprecated-declarations', '-fstrict-aliasing', '-wstrict-aliasing', '-fpic', '-pthread', '-ibuild', '-i.', '-dns3_assert_enable', '-dns3_log_enable', '-dsqlite3=1', '-dhave_if_tun_h=1', '-denable_gsl',

java - SSL error with urllib -

i'm getting sslerror when i'm trying scrape website beautifulsoup4 i'm using urllib open link. got work in java jsoup (scraper java) generating certificate website i'm trying scrape here . possible use certificate in python? file generated called jssecacerts renamed cacerts. this code i'm using: def open(url, postdata=none): if postdata not none: postdata = urlencode(postdata) postdata = postdata.encode('utf-8') return browser.open(url, postdata).read() def login(i): cj = http.cookiejar.cookiejar() global browser browser = urllib.request.build_opener(urllib.request.httpcookieprocessor(cj)) post = {'timezoneoffset': timezoneoffset, 'userid': userid, 'pwd': pwd, } open(login_url, post) the error: process process-1: traceback (most recent call last): process process-2: traceback (most recent call last): file "c:\python34\lib\urllib\r

go - Golang implementing database funcs using interfaces -

sorry bit dummy questions, i'm kinda stuck. so, i'm implementing wrapper above database driver application, , need keep portable possible. came decision interfaces perfect match task. so, have database struct variables , app-specific methods, , 2 interface functions: query(request string) error flush() int? string?? struct?? slice????, error now got main question. how do return data type "flush()" doesn't know? can return interface, , if can, how work that? second question pretty basic, still isn't clear me. so, have database struct 2 methods designed implemented package user use db driver want. ho write , how future implementation (there example on tour of go, it's interface different structs similar methods) hope you'll me find understanding :) yes, flush can have signiture; flush() interface{}, error how implement? reasonable method bodies should you; type mydbdriver struct { //fields } func (d *mydbdriver) query(r

sql - Query to get specific patterns from column -

one of table column contains below value. all files (*.*)|*.*|bitmap (*.bmp)|*.bmp|microsoft word document (*.docx)|*.docx|gif (*.gif)|*.gif|jpeg (*.jpg)|*.jpg|png (*.png)|*.png|adobe reader (*.pdf)|*.pdf|tiff (*.tif)|*.tif i need query fetch bmp,docx,gif,jpg,png,pdf,tif above values. these values present in brackets. is want ? select * your_table column_with_types in ('(.bmp)','(.docx)','(.gif)','(.jpg)','(.png)','(.pdf)','(.tif)')

bash - Screen CS:GO server cvar change -

i want send commands screen .sh script. start csgo server with: screen -s cs ./srcds_run -game csgo -usercon how can send command csgo server like: sv_cheats 1 from screen manpage: -x send specified command running screen session. at https://unix.stackexchange.com/questions/13953/sending-text-input-to-a-detached-screen find similar question. so specific problem solution be: screen -s cs -x stuff "sv_scheats 1"

r - Validate() function for multiple conditions in Shiny, Rstudio -

i have wrote simplified version of code able give me direction go in. trying validate() process in shiny prevent function spc_macro running if fails. know can write multiple need clauses can make validate process fail independently need these clauses combined. example: below have validation clauses of mean=1, sigma=1, phase1=15, , userk=3.1. trying validate function return false sigma(which stop function running) if theses values set together. if user input mean=1, sigma=1, phase1=15 , userk=3.8 validate pass , function run. wondering if possible make multiple failing combinations. have run 3 simulations , these ones trying prevent being rerun user. sim 1: mean=1, sigma=1, phase1=15, userk=3.1 sim 2: mean=2, sigma=2, phase1=30, userk=3.6 sim 3: mean=2, sigma=2, phase1=30, userk=4.0 `%then%` <- shiny:::`%or%` mean<-c(1,2,3) sd<-c(1,2,3) phase1<-c(15,20,25,30) k<-(c(3,3.2,3.4,3.6,3.8,4.0)) shinyserver(function(input, output) { output$mean <- renderui({ sel

c# - How to read values from config.json in Console Application -

i installed asp.net 5 , created console application in visual studio. i've added file, config.json, root folder of project. it looks this: { "data": { "targetfolderlocations": { "testfolder1": "some path", "testfolder2": "another path" } } } my program.cs looks this public void main(string[] args) { var configurationbuilder = new configurationbuilder(environment.currentdirectory) .addjsonfile("config.json") .addenvironmentvariables(); configuration = configurationbuilder.build(); //doesn't work...null time var test = configuration.get("data:targetfolderlocations"); console.readline(); } how can access targetfolderlocations key code? have type following: public class foldersettings { public dictionary<string, string> targetfolderlocations { get; set; } } you can use configu

javascript - Regex not working properly with info from API -

i'm having weird problem. i'm running script in adobe's extendscript toolkit (to use photoshop) info api, , regex extract 6 digit number part of it, part being: ' save 585190 j.crew ou + 591580 polo ralph lauren ou ' the api working fine, , script (i've replaced website hidden protect identity): currentpid = activedocument.name.substring(0,6) reply = ""; conn = new socket(); conn.open ("hidden.com:80", "binary") conn.write ("get http://hidden.com/api/products/" + currentpid + "/for-studio?content-type=application/json http/1.0\r\nhost:website.com\r\nconnection: close\r\n\r\n"); reply = conn.read(999999); var result = reply.substr(reply.indexof("\r\n\r\n")+4); var showme = json.parse(result) conn.close(); mycomments = showme.comments myregex = new regexp("(?!" + currentpid + ")\\d{6}"); var posspid = (mycomments.match(myregex)); however, when run this,

java - All combinations of alphanumeric string, better way? -

the input "alphanumeric" function string consists of alphanumeric characters lower case, example "hello123hello". want able check upper/lower case letter combinations string through check( ) function. (eg. hello123hello 1 of combinations checked). have written code in java store matching string arraylist, know if there better way without arraylist. also, correct in saying worst case runtime of o(2^n)? note: check function returns either true or false, depending on whether correct string passed function. public static string alphanumeric(string input) { arraylist<string> list = new arraylist<string>(); alphahelper(input, "", list); return list.get(0); } private static void alphahelper(string in, string current, arraylist<string> list) { if (in.length() == 0) { if (check(current)) { list.add(current); } } else if (character.isletter(in.charat(0))) { alphahelper(in.substring(1),c

React Native Retrieve Actual Image Sizes -

i able know actual size of network-loaded image has been passed <image /> have tried using onlayout work out size (as taken here https://github.com/facebook/react-native/issues/858 ) seems return sanitised size after it's been pushed through layout engine. i tried looking onloadstart, onload, onloadend, onprogress see if there other information available cannot seem of these fire. have declared follows: onimageloadstart: function(e){ console.log("onimageloadstart"); }, onimageload: function(e){ console.log("onimageload"); }, onimageloadend: function(e){ console.log("onimageloadend"); }, onimageprogress: function(e){ console.log("onimageprogress"); }, onimageerror: function(e){ console.log("onimageerror"); }, render: function (e) { return ( <image source={{uri: "http://adomain.com/myimageurl.jpg"}} style={[this.props.style, this.sta

python - Django / xhtml2pdf - object has no attribute 'encode' -

i'm having hard time producing pdf's in django. per previous question i'm running same error. when run following code 'list' object has no attribute 'encode' , pdf saved in media folder plain text file. think object being referred sections queryset. @login_required def generate_pdf(request, slug): # prepare context document = get_object_or_404(document, slug=slug) sections = \ get_list_or_404(section.objects.filter (associated_document__startswith=document.slug)) data = {'document': document, 'sections': sections} # render html content through html template context template = get_template('lld/lld_pdf.html') html = template.render(context(data)) file = open('/home/project/media/test.pdf', "w+b") print type(document) print type(sections) print type(data) print type(template) print type(html) print type(file) pisastatu

javascript - Check if element value starts with 'http', if true change class of element -

i want check series of elements same class see if value starts 'http' if true elements should have new class added. $('#btn').click(function () { if ($('span.value').text().indexof('http') == 0 ) { $('span.value').addclass('url'); } else { $('span.value').addclass('noturl'); } }); this jsfiddle i've got far, it's adding new class elements ones don't start 'http'. i'm not sure problem is? you need iterate on each span individually: $('#btn').click(function () { $('span.value').each(function () { if ($(this).text().indexof('http') == 0) { $(this).addclass('url'); } else { $(this).addclass('noturl'); } }) }); jsfiddle example

ios - EXC_BAD_INSTRUCTION when trying to pass data to UIViews -

i created call of uiview in draw graph. trying pass new data , have update. when run app on simulator , click tab in the controller housing view in, receive error: thread 1: exc_bad_instruction (code=exc_1386_invop, subcode=0x0) at line: let maxvalue = graphpoints.maxelement() here code view: @ibdesignable class graphview: uiview { var graphpoints :[int]! override init(frame: cgrect) { super.init(frame: frame) } init(graphpoints: [int]) { self.graphpoints = graphpoints super.init(frame: cgrectzero) } required init?(coder adecoder: nscoder) { super.init(coder: adecoder) } @ibinspectable var startcolor: uicolor = uicolor.redcolor() @ibinspectable var endcolor: uicolor = uicolor.greencolor() override func drawrect(rect: cgrect) { let width = rect.width let height = rect.height //set background clipping area let path = uibezierpath(roundedrect: rect, byroundingcorners: uirectcorner.allcorners, cornerradii: cgsize(wi

java - Error in importing facebook SDK -

i using android studio version 1.2 , going use facebook sdk create application allow user post in wall. when import module or facebook sdk getting error. error:(15, 0) not find property 'android_build_sdk_version' on project ':facebook'. my downloaded sdk latest one. name of zip file when downloaded. facebook-android-sdk-4.4.1 this build.gradle have. apply plugin: 'com.android.application' android { compilesdkversion 22 buildtoolsversion "23.0.0 rc3" defaultconfig { applicationid "com.example.jerex.facebook" minsdkversion 14 targetsdkversion 22 versioncode 1 versionname "1.0" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } repositories { mavencentral() } dependencies { compile filetree(dir: 'libs', includ

storage - How can I save some user data locally on my Xamarin Forms app? -

i have simple xamarin forms app. i've got simple poco object (eg. user instance or list of recent tweets or orders or whatever). how can store object locally device? lets imagine serialize json. also, how secure data? part of keychains, etc? auto backed up? cheers! you have couple options. sqlite. option cross-platform , works if have lot of data. added bonus of transaction support , async support well. edit : in past suggested using sqlite.net-pcl . due issues involving android 7.0 support (and apparent sunsetting of support) recommend making use of project forked from: sqlite-net local storage. there's great nuget supports cross-platform storage. more information see pclstorage there's application.current.properties implemented in xamarin.forms allow simple key-value pairs of data. i think you'll have investigate , find out route serves needs best. as far security, depends on put data on each device. android stores app data in secure a

android - SimpleDraweeView rounded inside scrollview -

Image
i'm trying migrate uil facebook's fresco lib. far looks fine when put rounded image inside scrollview weird behaviour: while scrolling bottom, image overlaps action bar , keeps there when go up. this code: <com.facebook.drawee.view.simpledraweeview android:id="@+id/img_item_detail_avatar" android:layout_width="70dp" android:layout_height="70dp" android:layout_gravity="center_vertical|right" fresco:actualimagescaletype="centercrop" fresco:placeholderimage="@drawable/icn_avatar_mini" fresco:roundascircle="true" fresco:viewaspectratio="1" /> also, i'm experiencing same behaviour inside listviews. have had similar issue? how can solve it? after couple of weeks, able solve issue! i've changed actionbar android.support.v7.widget.tool