Posts

Showing posts from July, 2015

php - error with submitting a form in wordpress -

i've created plugin (simple form) , shortcode.php file: <?php add_shortcode('contact_form','contact_form'); function contact_form(){ if (isset($_post['submit'])){ global $wpdb, $table_prefix; $name = $_post['name']; $data = array('name'=>$name,'message'=>'message'); $wpdb->insert($table_prefix.'contact_form',$data,array('%s','%s')); echo 'added'; } ?> <form method="post" action="" id="contact_form"> name: <input type="text" name="name"><br> <input type="submit" name="submit" value="submit"> </form> <?php } when submit form, if write sth in text field, says 'the page doesn't exist' if leave empty, submits form. problem? have used shortcode in page. see this question

deep learning - Error in testing Caffe's Alexnet caffe model -

i trained caffe's alexnet model testing more efficient model. since training pedestrians image size 64 x 80 images. made changes prototxt files match trained image size. according tutorial , better set convolution filter size match input image size. filter sizes have slight changes original alexnet's provided prototxt files (i trained , tested alexnet's original prototxt files , same error @ same line mentioned below). according calculation, image sizes after passing each layer be 80x64x3 -> conv1 -> 38x30x96 38x30x96 -> pools -> 18x14x96 18x14x96 -> conv2 -> 19x15x256 19x15x256 -> pool2 -> 9x7x256 9x7x256 -> conv3 -> 9x7x384 9x7x384 -> conv4 -> 9x7x384 9x7x384 -> conv5 -> 9x7x256 9x7x256 -> pool5 -> 4x3x256 the error @ fc6 layer , line number 714 of test_predict_imagenet.cpp . use test_predict_imagenet.cpp file test model. check_eq(target_blobs[j]->width(), source_layer.blobs(j).width()); the error

Popup verify native password android -

i want user type password , press ok button, , check whether device's password. if app close , if not pop try again. new materialdialog.builder(finished.this) .title("to exit enter phone password") .inputtype(inputtype.type_class_text | inputtype.type_text_variation_password) .positivetext(r.string.ok) .negativetext(r.string.cancle) .input(r.string.input_hint, integer.parseint(""), new materialdialog.inputcallback() { @override public void oninput(materialdialog dialog, charsequence input) { // } }) .callback(new materialdialog.buttoncallback() { @override public void onpositive(materialdialog dialog) { onbackpressed();

html - How to Center-Justify links in CSS? -

how can center-justify list of links in css? this similar question: how center-justify text in css? , except using links instead of text. fiddle answer there ( http://jsfiddle.net/l4pzm/ ) doesn't work when use links instead of text. this how did in above fiddle: .center-justified { margin: 0 auto; text-align: justify; width: 30em; } here fiddle created: http://jsfiddle.net/hsm4w0p5/ <div class="center-justified"><p> <a href="1">first </a><a href="2">second</a><br> <a href="3">third <a href="4">fourth </a><a href="5">fifth</a></p> </div> as can see in example above, links aren't justified. want make word "second" aligned right match word "fifth". i don't think possible using text-align: justify, can use flexbox similar: html: <div class="center-justified"> <div

python 2.7 - "xml.sax._exceptions.SAXReaderNotAvailable: No parsers found" when run in jenkins -

so i'm working towards having automated staging deployments via jenkins , ansible. part of using script called ec2.py ansible in order dynamically retrieve list of matching servers deploy to. ssh-ing jenkins server , running script jenkins user, script runs expected. however, running script within jenkins leads following error: error: inventory script (ec2/ec2.py) had execution error: traceback (most recent call last): file "/opt/bitnami/apps/jenkins/jenkins_home/jobs/deploy api/workspace/deploy/ec2/ec2.py", line 1262, in <module> ec2inventory() file "/opt/bitnami/apps/jenkins/jenkins_home/jobs/deploy api/workspace/deploy/ec2/ec2.py", line 159, in __init__ self.do_api_calls_update_cache() file "/opt/bitnami/apps/jenkins/jenkins_home/jobs/deploy api/workspace/deploy/ec2/ec2.py", line 386, in do_api_calls_update_cache self.get_instances_by_region(region) file "/opt/bitnami/apps/jenkins/jenkins_home/jobs/deploy api/workspace/deploy/ec2

spring - Receive wrong representation of non-unicode characters in request to controller ("Ðо" instead of "Сыр") -

here controller: @requestmapping(value = "/item/products", method = requestmethod.get) @responsebody public productdto[] getproducts(pageable pageable, @requestparam(value = "searchdto", required = false) string serializeddto) throws ioexception { i send request: ...item/products?page=0&size=10&sort=status,asc&sort=id,asc&searchdto={"name":"Сыр"} "Сыр" - cyrillic and in controller receive this: serializeddto = {"name":"Ðо"} instead of this: serializeddto = {"name":"Сыр"} problem in encoding, have tried lot of things didn't work. i'm doing wrong? if need more code/materials provide it. if using tomcat consider default ignoring url parameters encoding. maven plugin add next configuration: <plugin> <groupid>org.apache.tomcat.maven</groupid> <artifactid>tomcat7-maven-plugin</artifactid&g

php - How can I include css and js file in codeigniter -

i trying toinclude css file in following code. config : $config['base_url'] = 'http://localhost/asoft/projects/ci_search'; $config['site_url'] = 'http://localhost/asoft/projects/ci_search/index.php'; $config['js'] = 'assets/js'; view: <link rel="stylesheet" href="<?php echo $base?>/<?php echo $css?>/style.css"> <link rel="stylesheet" href="<?php echo $base?>/<?php echo $css?>/bootstrap.min.css"> <script src="<?php echo $base?>/<?php echo $js?>/jquery.min.js"></script> <script src="<?php echo $base?>/<?php echo $js?>/jquery.js"></script> <script src="<?php echo $base?>/<?php echo $js?>/bootstrap.min.js"></script> i put css file in ci_search/css , js file in ci_search/assets/js got error undefined variable css , undefined variable js.please provide

jquery - How to post back form? -

i need make form using razor , devexpress controls. when user opens devexpress popup control there appear form fields needs enter. here view: @model models.request @html.devexpress().popupcontrol( settings => { settings.name = "newrequest"; settings.callbackroutevalues = new { controller = "request", action = "requestform" }; settings.enableclientsideapi = true; settings.width = 450; settings.showheader = true; settings.showshadow = true; settings.popupanimationtype = animationtype.fade; settings.allowdragging = true; settings.modal = true; settings.setcontent( () => { using ( html.beginform( )) { viewcontext.writer.write( "<div id = 'products'>" ); foreach(var product in model.products) { html.renderpartial( "productpartial", product ); } viewcontext.writer.write( "</

html - Styling A Navbar Button With Bootstrap -

here link test page: http://goo.gl/j8bs8p i'm trying navbar button have same styles basic button. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav navbar-left"> <li class="hidden"> <a href="#page-top"></a> </li> <li> <a class="page-scroll" href="#page-top">home</a> </li> <li> <a class="page-scroll" href="#services">about</a> </li> <li> <a class="page-scroll" href="#portfolio">services</a> </li> <li> <a class="page-scroll" href="

android - What do you call the stat breakdown when creating a new character on Ragnarok Online? -

i remember when creating character in ro, there hexagonal object different points either str, agi, dex, etc , when click of points 3d shape in middle adjust reflect values. i want know called can research how implement on android , in circular border 5 points. if have ant libs can implement appreciated! attached sample image of stat distribution https://lh4.googleusercontent.com/proxy/2eedcqzyzr9mxmtbikgclwl62fnurjtjfeemrsbuzn_kjkdumy_1mthurmbn4iixxjv5rfzscgas1xe0hq3-mvy7fbwp9i8oiukj_pmgaxvgaw=w360-h270-nc these named spider web chart or radar charts . here's library: github link

java - How to access an Existing JFrame Form? -

i'm having little problem accessing existing jframe form (i'm doing in netbeans way): public class framea extends javax.swing.jframe { frameb b; //creates new jframe called b framea = this; //this jframe assigned variable string x; public framea() { initcomponents(); } private void btnclickme (java.awt.event.actionevent evt) { x = jtextfield1.gettext(); b = new frameb(); //creates new instance of frameb b.setvisible (true); //opens new jframe a.setvisible(false); //hides or closes current jframe } public string getme () { return x; //attempts value of x } } public class frameb extends javax.swing.jframe { framea = this.framea(); //calls existing jframe framea string clickie = a.getme(); //attempts x variable framea //assigns variable display on textarea jtextarea1.settext(clickie); public frameb() { initcompon

node.js - Using Sequelize with Redshift -

is possible use sequelize redshift ? if not, alternatives? need orm node.js built-in support transactions, hence sails.js not option. i've looked @ bookshelf , not find support redshift either. i've been able sequelize @ least connect redshift (and make simple select query) these options: var sequelize = require('sequelize'); sequelize.hstore.types.postgres.oids.push('dummy'); // avoid auto-detection , typarray/pg_type error module.exports = new sequelize(process.env.redshift_database, process.env.redshift_user, process.env.redshift_password, { host: process.env.redshift_host, port: process.env.redshift_port, dialect: 'postgres', pool: false, keepdefaulttimezone: true, // avoid set timezone databaseversion: '8.0.2' // avoid show server_version });

c# - insert data from asp.net page to my database with tables which have foreign key -

i'm beginner asp.net programmer , project online shopping classes have problem in i have 4 tables foreign key between them... create table [dbo].[orderdetails] ( [orderid] int not null, [classid] int not null, constraint [pk_orderdetails] primary key clustered ([orderid] asc, [classid] asc) ); create table [dbo].[order] ( [orderid] int identity (300, 1) not null, [customerid] int not null, constraint [pk_order] primary key clustered ([orderid] asc) ); create table [dbo].[customer] ( [customerid] int identity (200, 1) not null, [firstname] nvarchar (50) not null, [lastname] nvarchar (50) not null, [phone] int not null, constraint [pk_table_1] primary key clustered ([customerid] asc) ); create table [dbo].[class] ( [classid] int identity (100, 1) not null, [numofclass] int not null, [numofstud] int not null, [totalprice] int not null, constraint [pk_class]

xhtml - javascript removeAttribute() doesn't remove "disabled" -

subject #2: <input type="text" name="subject2" id="sub2" class="i2" size="20" disabled> <br> <button onclick="document.getelementbyid('sub2').removeattribute('disabled')"> add subject</button> this wrote, when press button input field becomes white (becomes useable) second, , returns grey , disabled. did wrong? thank you js fiddle demo

Add Style on image object using JavaScript in Canvas -

i'm trying add z-index on image. used setattribute style not working. please figure out issue // hero image var heroready = false; var heroimage = new image(); heroimage.onload = function () { heroready = true; }; heroimage.setattribute("src", "img/car.png"); heroimage.setattribute("style", "z-index:5;"); you should use "style". https://developer.mozilla.org/en-us/docs/web/api/htmlelement/style heroimage.style.zindex = "5"; here's an example play with. snippet: var div = document.getelementbyid("something"); div.style.position = "absolute"; div.style.width = "200px"; div.style.height = "200px"; div.style.backgroundcolor = "blue"; div.style.zindex = "2"; function onclick() { (div.style.zindex == "2") ? div.style.zindex = "0" : div.style.zindex = "2"; } #another { z-index: 1; widt

javascript - Validate field/attribute in CRM Dynamics forms using js -

i have problem in validating attribute on form in crm dynamics. added javascript code validate attribute value based on business rules. , added 2 events, form on save , field on change, the question is: 1- best way validate on attribute? 2- in case of using way, how can stop saving form or passing valid ? i believe that's way validate input. in case want stop save in case 1 of validations fails following: check "pass execution context" during registration of save event handler. add parameter function that's called during save procedure. in case validation fails call following code: execobj.geteventargs().preventdefault() you can find more details here - https://msdn.microsoft.com/en-us/library/gg509060.aspx

Create base docker centos image with python 2.7.8 -

i've found this walks through creating base bare-metal centos image. want install additional yum packages, download python 2.7.8 , build it. i had in dockerfile , working like: # set base image ubuntu centos:7 # file author / maintainer maintainer sam mohamed # update sources list run yum -y update run yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel xz-libs gcc g++ build-essential make # install python 2.7.8 run curl -o /root/python-2.7.9.tar.xz https://www.python.org/ftp/python/2.7.9/python-2.7.9.tar.xz run tar -xf /root/python-2.7.9.tar.xz -c /root run cd /root/python-2.7.9 && ./configure --prefix=/usr/local && make && make altinstall # copy application folder inside container add `pwd` /opt/iws_project # download setuptools , install pip , virtualenv run wget https://bootstrap.pypa.io/ez_setup.py -o - | /usr/local/bin/python2.7 run /usr/local/bin/easy_install-2.7 pip run /usr/local/bin/pip2.7 install virtualenv # create vi

os.walk ignore directorys and its content -

i'm trying ignore directory , files in in specific path , code x = open(wbcmd, 'a') x.write('set path="c:\program files\winrar\";%path% c:/program files/winrar/\n') x.write('rar.exe -r "backup.rar" -m5 -ep1') chkdict = {} setdef = chkdict.setdefault root, dirs, files in os.walk(foldername): if ignoreddirs in dirs: continue file in files: ext = path.splitext(file)[1] if ext in ignored: continue if not ext in chkdict: print("%s" % setdef(ext,ext)) x.write(" *%s" % setdef(ext,ext)) x.write(" *makefile *depend *readme\npause") x.close del chkdict ignoreddirs array looks this ignoreddirs = ["bin"] dirs , ignoreddirs both lists of strings. therefore, dirs not contain ignoreddirs . may, contain of elements. 1 way check check intersection: if len(set(ignoreddirs).intersection(set(dirs))) > 0: conti

encryption - Swi Prolog Read Write with Files -

so i've been trying make encryption predicate , got work input keyboared , standard output i'm failing make work files,so need fixing it. need take text in messagefile apply encryption , write outfile. encrypt(messagefile,key,outfile):- read(x),q(x,key,r),!,string_to_list(s,r), write(s). as said works standard input\output: 9 ?- encrypt(x,a,y). | abcdef. bcdefg true. if relevant , .pl file in.txt , out.txt in d:\folder you can open file with: open(messagefile, read, read), you can use read/2 read prolog term file stream: read(read, term), ps: notice string_to_list/2 deprecated , string_codes/2 up-to-date equivalent.

java - Generate Random String Containing Alpha-Numeric and Special Chars? -

i'm interested in generating (secure) random string following properties: atleast 1 upper case letter atleast 1 lower case letter atleast 1 digit 0-9 atleast 1 special char chars $&@?<>~!%# the length of string should 12-13 digits/chars long. i know there class in apache commons can generate random strings there no option include special chars. i'm aware of other similar questions on none of them address these requirements. i've tried following far: import java.security.securerandom; public final class sessionidentifiergenerator { private securerandom random = new securerandom(); public string nextsessionid() { return new biginteger(130, random).tostring(32); } } but not contain char set each of 4 points. i tried: static final string ab = "0123456789abcdefghijklmnopqrstuvwxyz"; static random rnd = new random(); string randomstring( int len ) { stringbuilder sb = new stringbuilder( len ); for(in

ruby on rails - How to write proper rspec test for controller -

i have controller called application controller next method want write test for: def require_admin p current_user.role return if current_user && current_user.role == 'admin' flash[:error] = "you not admin" redirect_to root_path end how write proper test it, , kind of test should be? you shouldn't test implementation. try testing 'how should controller action behave non-admin user', might this: context 'user not admin' before user.role = 'not_admin' :some_action end 'is redirected root_path' expect(response).to redirect_to('/') end ... end

python - Django Tastypie hidden PK -

i using latest tastypie , have hit snag. need hide pks people can't see service growth. models have uuidfield . using detail_uri_name field , gives me uuid instead of id/ pk requests, far. the problem have when go put or patch resource_uri . thinks new resource doesn't have id , duplicate key errors trying create new record. ideas? here resource. class userresource(modelresource): class meta: detail_uri_name='uuid' queryset = user.objects.all() resource_name = 'user' always_return_data = true authentication = sessionauthentication() authorization = authorization() excludes=['id', 'password', 'created', 'approved', 'password_reset_code', 'password_reset_datetime'] def prepend_urls(self): return [ url(r'^(?p<resource_name>%s)/(?p<uuid>[\w\.-]+)/$' % self._meta.resource_name, self.wrap_view('dispatch_deta

php grabbing rss feeds from too many sources -

the website working on has several rss resources blogs inputed users, number of resources growing/changing. at point resources many updated in 1 call (otherwise takes long , makes script crash). what alternatives exist make possible update feeds multiple growing resources? in php if possible... or supposed done through node.js? you should write queue system or http://gearman.org/

java 8 - Not able to see Spring MVC option while creating project in STS -

i know question has been asked in stackoverflow already. i have downloaded spring sts 3.7.0 , installed in machine. operating system: fedora 20 jdk - java 1.8.0_45 i trying create spring mvc project option not coming up. when have downloaded spring sts windows 7 64 bit , java 1.7.0_67, spring mvc option coming create project.so understood there no problem sts problem lies java , os. also have learned below link http://forum.spring.io/forum/spring-projects/springsource-tool-suite/724542-cannot-see-spring-mvc-project-template-in-sts-3-4-for-eclipse-kepler the properties ssl.socketfactory.provider , ssl.serversocketfactory.provider culprit. but not sure, in file need edit properties , values need set etc,. not using ibm java @ all. it great if 1 helps me in resolving issue.

javascript - Rails translations issue with i18n-js -

i'm using http://github.com/fnando/i18n-js gem javascript translation. here translation yml: en: js: test: "<strong>%{name}</strong> created board." in js, run "name" param "$&". console.log(i18n.t('js.test', {name: "$&"})) unfortunately, show message this: %{name} created board, while expect message should be: $& created board. there problem special character "&" gem? , how solve this? the problem in code is, interpolation not working used %{name} in translation file. have use: {{name}} instead make interpolation work. so, change: test: "<strong>%{name}</strong> created board." to this: test: "<strong>{{name}}</strong> created board." and should work!

python - Installed pytesser, but can't import it -

i trying install pytesser use ocr in script. readme in .zip source says: pytesser has no installation functionality in release. extract pytesser.zip directory other scripts. i extracted pytesser_v0.0.1.zip c:\python27\lib\site-packages\pytesser . however, when try import in vs2013 (using from pytesser import * ), no module named pytesser error. what doing wrong? using python 2.7, way. know pil isn't supported in python 3+. thanks! update: found may able add modules editing pythonpath variable, seems both hacky , unreliable. update 2: yay, got tumbleweed badge! update 3: here files in c:\python27\lib\site-packages\pytesser: directory of c:\python27\lib\site-packages\pytesser 16 aug 2015 03:55 pm <dir> . 16 aug 2015 03:55 pm <dir> .. 16 aug 2015 03:55 pm 273 authors 16 aug 2015 03:55 pm 48 changelog 16 aug 2015 03:55 pm 424 errors.py 16 aug 2015 03:55 pm 1

c# - AutoSuggestBox query selected textbox -

Image
i using autosuggestbox control display results, such: <autosuggestbox width="192" placeholdertext="search" horizontalalignment="right" itemssource="{binding searchresults}"> <i:interaction.behaviors> ... </i:interaction.behaviors> <autosuggestbox.itemtemplate> <datatemplate> <textblock> <run text="{binding name}" /> <run text="(" /><run text="{binding origin_country[0]}" /><run text=")" /> </textblock> </datatemplate> </autosuggestbox.itemtemplate>

c++11 - Are the implicit move ctor/assignmet operations noexcept? What about implicit copy operations? -

the question titles says all. need know if default copy/move assignment/ctors implemented implicitly compiler declared noexcept . the standard says: an inheriting constructor (12.9) , implicitly declared special member function (clause 12) have exception-specification. if f inheriting constructor or implicitly declared default constructor, copy constructor, move constructor, destructor, copy assignment operator, or move assignment operator, implicit exception-specification specifies type-id t if , if t allowed exception-specification of function directly invoked f’s implicit definition; f allows exceptions if function directly invokes allows exceptions, , f has exception-specification noexcept(true) if every function directly invokes allows no exceptions. so if implicitly declared copy/move assignment/ctors of class not need call marked noexcept(false) have noexcept(true) specifier. functions need called copy/move assignment/ctors of base class

c regex not finding string -

i'm trying create collection of regexes in c, no success. currently i'm trying find include statements following regex: (#include <.+>)|(#include \".+\") here code: #include <stdio.h> #include <stdlib.h> #include <regex.h> char *regex_str = "(#include <.+>)|(#include \".+\")"; char *str = "#include <stdio.h>"; regex_t regex; int reti; int main() { /* compile regex */ reti = regcomp(&regex, regex_str, 0); if (reti) { printf("could not compile regex.\n"); exit(1); } /* exec regex */ reti = regexec(&regex, str, 0, null, 0); if (!reti) { printf("match\n"); } else if (reti == reg_nomatch) { printf("no match\n"); } else { regerror(reti, &regex, str, sizeof(str)); printf("regex match failed: %s\n", str); exit(1); } /* free compiled regular e

sockets - ICMP in Windows 10 Universal Apps -

i able icmp network diagnostics windows 10 universal app, including ping, traceroute, etc. however appear system.net.networkinformation.ping class isn't available store apps , when creating new system.net.sockets.socket protocoltype.icmp not available when try. all information can find on internet topic relates windows 8.1 apps , want know if new has been added api in windows 10 allow me produce icmp ping, etc. i've seen suggestions use raw sockets appears these no longer allowed on client versions of windows. my preferred language c# i'm ok using c++ if gives me advantage. note: checking network status not sufficient. i'm wanting test connection specific machines on network, want proper icmp ping. the system.net.networkinformation.ping dot net class wrapper win32 ip helper functions. uwp apps run in protected environment, , result, many win32, com, , crt api calls might compromise security of platform not allowed. windows runtime apps , uni

Error when coding a graph class in C++ -

i know debugging other people's code can frustrating want find out what's wrong mine. it's incomplete graph lot of functions not implemented yet. got stage , got stuck. it's graph of adjacent list. has vertices , edges. got error cannot understand. can explain how error had come about? error c:\users\jialee\documents\codeblocks\shortestpath\graph.cpp: in constructor 'edge::edge(vertex, weight)': c:\users\jialee\documents\codeblocks\shortestpath\graph.cpp:34:33: error: no matching function call 'vertex::vertex()' and code #include <forward_list> #include <string> using namespace std; const int max_size = 10000; typedef int weight; class vertex { public: vertex(string name, int num); string city_name; int city_num; }; class edge{ public: edge(vertex v, weight w); vertex associated_vertex; weight weight; }; class graph{ public: graph(int size); }; vertex::vertex(string name, int num){ c

user interface - Convert UI file to Python Using pyuic4 Issue -

i'm trying convert ui file python using pyuic4 "the system cannot find path specified". ( pyuic4 mainwindow.ui > mainwindow.py ) i'm not sure why since i've given command line exact location of file (pyuic4) in anaconda. if use pyuic5 conversion without problem ( pyuic5 mainwindow.ui > mainwindow.py ). i'm using windows anaconda3. have ideas problem might be? i ran myself. looks anaconda build has issue. pyuic4.bat has machine dependent paths need changed match system. original pyuic4.bat text (notice path) @"c:\aroot\stage\python" "c:\aroot\stage\lib\site-packages\pyqt4\uic\pyuic.py" %1 %2 %3 %4 %5 %6 %7 %8 %9 correct anaconda text: @"c:\anaconda\python" "c:\anaconda\lib\site-packages\pyqt4\uic\pyuic.py" %1 %2 %3 %4 %5 %6 %7 %8 %9 correct anaconda3 text: @"c:\anaconda3\python" "c:\anaconda3\lib\site-packages\pyqt4\uic\pyuic.py" %1 %2 %3 %4 %5 %6 %7 %8 %9

c# - Capture desktop exclude (under) my active window -

Image
there many questions capture active window or desktop include active window question different: i want capture desktop under wpf window. created sample project base on following code: using (var screenbmp = new bitmap((int)elementsize.width,(int)elementsize.height, system.drawing.imaging.pixelformat.format32bppargb)) { using (var bmpgraphics = graphics.fromimage(screenbmp)) { bmpgraphics.copyfromscreen((int) topleftpoint.x, (int)topleftpoint.y, 0, 0, screenbmp.size); return imaging.createbitmapsourcefromhbitmap( screenbmp.gethbitmap(), intptr.zero, int32rect.empty, bitmapsizeoptions.fromemptyoptions()); } } it can capture desktop element copyfromscreen result picture of element but want capture desktop under element, not include element in window. note: element (for example rectangle) background semi-transparent or none-transparent (has image or so

Swift array reference issue -

here code: var productslist:[product] switch category { case 0: productslist = self.sharedinstance.productslist1 case 1: productslist = self.sharedinstance.productslist2 default: productslist = self.sharedinstance.productslist3 } productdic in products { let product = product() // set product attributes here. productslist.append(product) } println(productslist) println(self.sharedinstance.productslist1) println(self.sharedinstance.productslist2) println(self.sharedinstance.productslist3) the output: productslist contains added content productslist1 , productslist2 , productslist3 empty. in understanding, productslist should refer 1 of productslist1, productslist2 , productslist3 depending on category. can explain why productslist1, productslist2 , productslist3 empty? thanks in advance. assigning array sharedinstance results in array being copied. you need

Find a model by its referenced model (child?) in Ruby on Rails -

rails nooby here, looking tips. i've looked around on site , rails website , can't seem find i'm looking for. i have account class class account < activerecord::base has_one :access_token, dependent: :destroy has_secure_password and of course class accesstoken < activerecord::base what want able in controllers account.find_by_access_token or that. there way in rails? assuming column's name accesstoken named token , try: class account < activerecord::base def self.find_by_token(token) account.joins(:access_token).where(access_tokens: { token: token } ) end end and use this: account.find_by_token('xxxxxxx')

java - Unable to access jlabel across the program -

i new java, hence basic question. i having trouble in accessing field (jlabel in case) throughout program. code follows : import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.*; public class accessvariable { public static void main(string[] args) { //basic setup of display frame jframe frame=new jframe(); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setsize(400, 400); jpanel panel=new jpanel(); //text field take user input jtextfield txt= new jtextfield(10); //adding action listener text field txt.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { if (true) { //if condition not checking here, make enter loop jlabel j =new jlabel("access successful"); //a jlabel created inside system.out.println("inside j : "+j.gettext()); /

docusignapi - Single Sign on for DocuSign -

we have application open docusign console in iframe. issue having open new tab, log on docusign , user can see console in iframe documents. common way people using automatically logon docusign through applications ? see sso documentation says looks @ persons email domain authenticate them.... our users have many different email domains. your application can use api console view user. session correspond user credentials in api request , skip logon step. api call url can embed in iframe. e.g.: post https://demo.docusign.net/restapi/v2/accounts/55555/views/console , url this: { "url": "https://demo.docusign.net/member/startinsession.aspx?startconsole=1&t=00000000-0000-0000-0000-000000000000&accountid=00000000-0000-0000-0000-000000000000" } edit: if need "sending view" (sometimes called "the tagger") envelope can post using url this: https://{server}/restapi/{apiversion}/accounts/{accountid}/envelopes/{envelopeid}/v

Clojure range with a specific start and infinite end -

according docs range function has 4 forms: (range) 0 - infinity (range end) 0 - end (range start end) start - end (range start end step) start - end skipping step so how declare range representing x infinity? i may asking how reference infinity, (range x infinity) might work? (iterate inc x) give lazy, infinite sequence of numbers starting x .

java - How can I retrieve the output of an outputstream -

i'm aware outputstreams meant writing data. want retrieve own output , know out has protected access in filteroutputstream. there loop or shortcut can .out field of output stream ? socket socket = new socket("localhost,4000); dataoutputstream data = new dataoutputstream(socket.getoutputstream()); data.writeutf("hi"); system.out.println(data.out); // want achieve. to out field, derive subclass of dataoutputstream , make output stream publicly retrievable: class yourdataoutputstream extends dataoutputstream { public outputstream getout() { return out; } } however, if want capture data sent out on socket, not want, since return output stream object returned socket. could, however, write subclass of filteroutputstream overrides write() methods print out data coming through, or store in array or file, before writing data underlying output stream. override methods like: public void write(int databyte) { system.out.println(databyt

ios - xcodebuild stuck on codesign? how to disable prompt? -

i'm trying continuous integration set up, circleci ios. has done great job of writing details of this: http://mazyod.com/blog/2015/03/26/marry-circleci-to-hockey/ however, xcodebuild gets stuck, , looks it's waiting codesign: /usr/bin/codesign --force --sign... the log shows has been running on hour. guess that... command waiting input or something? if so, how force use keychain i've created using distribution cert/private key ? here's script (add-keys.sh) looks like: #!/bin/sh security -v create-keychain -p $key_password ios-build.keychain security -v import ./utils/build_tools/custom_builds/apple.cer -k ~/library/keychains/ios-build.keychain -t /usr/bin/codesign security -v import ./utils/build_tools/custom_builds/distribution.cer -k ~/library/keychains/ios-build.keychain -t /usr/bin/codesign security -v import ./utils/build_tools/custom_builds/distribution_cert_private_key.p12 -k ~/library/keychains/ios-build.keychain -p $key_password -t /usr/bin/cod

What is the proper syntax for the Less Than/Equal operator in MyBatis 3? -

how use less equal in mybatis 3. <select id="getlog" resultmap="baseresultmap" parametertype="java.lang.string"> select * from( select * table1 col1 =#{col1,jdbctype=varchar} order date desc ) table2 rownum <= 20 </select> i show examples greater than/equal operator , less than/equal operators: rownum &gt;= 20 rownum &lt;= 20 or, readability, can wrap them in cdata rownum <![cdata[ >= ]]> 20 rownum <![cdata[ <= ]]> 20

java - Why isn't this multithreaded code faster? -

this java code. before, calls batchgenerateresult sequentially lengthy process, want try multithreading , have each 1 of them run @ same time. when test it, new time same old time. expected new time faster. know whats wrong? public class plutomake { public static string classdir; public static void main(string[] args) throws jsonexception, ioexception, interruptedexception { // determine path class file, use current directory string classdirfile = plutomake.class.getresource("plutomake.class") .getpath(); classdir = classdirfile.substring(0, classdirfile.lastindexof("/") + 1); // input arguments final string logopath; final string filename; if (args.length < 2) { logopath = classdir + "tests/android.png"; filename = "result.png"; } else { logopath = args[0]; filename = args[1]; } // make sure logo image exists file logofile = new file(logopath);