Posts

Showing posts from March, 2010

vb.net - Nested class & readonly properties -

outside class i'd able access cctv.camera.brightness property readonly, methods within cctv class should able modify brightness property. please can advise on how achieve this? i think need add interface exposes properties , hides others, i'm not sure of implementation. [note constructor , main sub contrived example , testing]. public class cctv public class camera public property name string public property brightness integer end class dim cameras new dictionary(of string, camera) public sub new() dim cam new camera cam.name = "driveway" cam.brightness = 5 cameras.add(cam.name, cam) end sub public sub changebrightness(value integer) cameras("driveway").brightness = value end sub end class sub main() dim mycctv = new cctv mycctv.changebrightness(10) if mycctv("driveway").brightness = 10 console.write("brightness 10") end sub get getter , setter

php - How to programatically create a simple HTML page using the permalink of another Wordpress post? -

i want create simple html page (not wordpress page) programmatically using permalink structure of existing post. e.g. existing post www.example.com/this-is-example-post i want create 3 more pages viz. www.example.com/this-is-example-post/index1 www.example.com/this-is-example-postindex2 www.example.com/this-is-example-post/index3 these urls need not real pages. need 3 different pages store different facebook meta. i'm building plugin. please guide. how can achieve it? am thinking twisted? i'm going crazy thinking it. :( please help. -------------edit--------------- after working on suggestions rahil, here's i'm now <?php add_action( 'init', 'xx_add_endpoint' ); function xx_add_endpoint() { add_rewrite_endpoint( 'index', ep_permalink ); } add_action( 'template_redirect', 'xx_render_endpoint' ); function xx_render_endpoint() { if ( ! is_singular() or ! get_query_var( 'index' ) ) {

javascript - Updating JSON Model in SAPUI5/OpenUI5 -

i have 1 json model, model/salesorder.json, { "headerset" : [] } the initialization, var salesordermodel = new sap.ui.model.json.jsonmodel("model/salesorder.json"); sap.ui.getcore().setmodel(salesordermodel, "somodel"); on time of creating sales order , creating 1 object have direct keys firstname , latname ,etc. , pushing headerset array without keys. var salesordermodel = this.getview().getmodel("somodel"); var salesorderdata = salesordermodel.getdata(); salesorderdata.headerset.push(soobject); salesordermodel.setdata(salesorderdata); suppose have 3 objects in model, need update specific object in model? how can that? master page view, <list id="listmyorder" growing="true" growingthreshold="10" growingscrolltoload="true" nodatatext="no drafts found" mode="singleselectmaster" items="{path : 'somodel>/headerset' }" select="handlemyorder

android - Share big Bitmap ImageView between two activities -

i have imageview in load large image (3264x2448). image altered effects before it's loaded imageview. after want load new activity, want show image first activity in second activity. so need way copy bitmap on second activity. i can't put in intent , because image big that? i need way share image between activities , because image altered in each activity . what way share image between different activities? try using picasso it has transform option use "create effects" in it caches saved bitmap on disk, when load next time in different activity, may load transformed one

html5 - Using application cache for storing CSS and Javascript files in MVC web application -

i'm using lot of frameworks in website ( knockout , bootstrap , jquery , jquery ui etc) causing load slow. practice store these javascript files (ex knockout.js ) , associated css files(ex bootstrap.css ) in application cache. looked in browser's application cache , of them store sprites, yet come across js caching using applicationcache won't improve load time application, that's cache headers for. best practice here to concatenate , compress assets change filenames of assets, example add hash based on contents, app.js becomes app.abc456.js set cache headers cache these assets ever. file names change each time, won't have problems it. "the applicationcache douchebag": http://alistapart.com/article/application-cache-is-a-douchebag unless have make app work offline, trust me, it's not worth it.

How do i restrict a Java random number generation -

here deal: have java code generates random number between 2 numbers , works fine. i'm trying achieve something. want in such way after first number has been generated, when recalls it, doesn't generate same number. instance, if number 4 generated, want included among possible generated numbers second time. make things little bit clear, here's code. int maximum=10; int minimum=1; int r; r = (int)(math.random() * maximum) + minimum; is there can make code above not generate particular number between 1 , 10? thanks. you fill collection , removed randomly selected number: list<integer> nums = new arraylist<>(); (int = /* start */; < /* end */; i++) { nums.add(i); } //elsewhere random rand = new random(); int = nums.remove(rand.nextint(/* end */); /* end */--; this may bit slower large amounts of numbers end result lower time-complexity on checks new numbers (whereas while loop in theory o(∞n) if i'm not mista

c# - Check if Username exists in Database -

i trying code register application form. in code below want check if username exists before save data in database. problem here code doesn't go "else" statement. miss something? kindly help public void usernamecheck() { string connetionstring = null; sqlconnection con; connetionstring = "data source=mcoeelimenem\\sqlexpress;initial catalog=database;integrated security=true"; con = new sqlconnection(connetionstring); sqlcommand cmd = new sqlcommand("select * register username= @username", con); cmd.parameters.addwithvalue("@username", this.textbox1.text); con.open(); sqldatareader dr = cmd.executereader(); while (dr.read()) { if (dr.hasrows == true) { messagebox.show("username = " + dr[1].tostring() + " exist"); break; } else {

android - Conditionally apply padding to Fragment when switching Fragments -

my activity first displays webview fragment must have 0 padding webview touches edges of screen. transitions scrollview fragment must have 12dp padding inside scrollview (and not activity) scroll bars @ edge content padded. if scrollview fragment part of two-pane activity layout, left side must padded. you try this: @override public void onstart() { super.onstart(); if(getresources().getconfiguration().orientation == configuration.orientation_landscape) { //modify padding } } edit: let's have first fragment showing list of items, , second fragment showing details, code, reusing detailsfragment instance if exists. public boolean multipane() { return getresources().getconfiguration().orientation == configuration.orientation_landscape; } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); if(multipane()) { detailsfragment details = (details

security - Data authorization and OAuth -

i know if there way within oauth limit data user can see once token has been accessed. example, in 'photo sharing' sample 1 application contains list of photos , application wants access photos printing purposes. how can user indicate photo print service should see subset of photos? maybe want printing service see photos .jpg extension, or photos after date, or 'tag'. can additional authorization requirements populated? have java application , using spring security oauth2 , can accomplish this. thanks for instance, can use 'scope' purpose. define custom 'scope', , endpoint of service should interpret custom scope , behave based on that. for example, define 'pic_jpeg' scope name , describe scope in api document "'pic_jpeg' scope required access jpeg pictures." a client application access authorization endpoint parameter 'scope=pic_jpeg scopex scopey', , oauth 2.0 authorization server implementation

c# - WCF Authentication - An error occurred when verifying security for the message -

i have problem connecting wcf service clientcredentialtype="username" . when run code below error faultexception: error occurred when verifying security message. when playing around of binding values access denied. . fiddler says there no authorization header , cannot find username or password in request either. here excerpts config: <system.webserver> <modules runallmanagedmodulesforallrequests="true"/> </system.webserver> <services> <service name="inventoryservices.mobileapi" behaviorconfiguration="custombehaviour"> <endpoint address="" binding="basichttpbinding" bindingconfiguration="securehttpbinding" contract="inventoryservices.imobileapi"/> <endpoint address="mex" binding="mexhttpsbinding" contract=&

datafeed - Archer GRC: Importing multiple sources of data into an application -

i'd have data different sources imported application data feed differentiate between 2 sources. sources come ms sql database , csv file shared drive. you can add value lists through ms sql , csv file imports. based on import type can assign values fields.

sql server - Import data from 64-bit ODBC provider -

i'm trying migrate postgis database sql-server 2008 spatial database. postgresql installs 64 bit odbc driver. if try import data postgresql odbc provider ssms error: error [im014] [microsoft][odbc driver manager] specified dsn contains architecture mismatch between driver , application which assume means can't connect 64-bit driver, ssms 32-bit. any advice how solve this? the odbc driver architecture must match architecture of application, odbc driver library that's loaded in-process. so if app 32-bit, odbc driver must 32-bit well, irrespective of whether it's 32-bit or 64-bit postgresql server.

pygame - Proper way to pass an object to a function [python] -

i'm working on shooter game in python using pygame , have question proper way pass object function. each player in game assigned team upon joining game. there class called team keeps track of status of team (score, number of players, etc.). team objects stored in list. sometimes, function need @ and/or modify team object. i'd know of following 2 methods better way pass team object function. method 1: each team object has attribute integer called teamid. each teamid unique. if function needs access team object, passed teamid, search through list of teams until finds object appropriate teamid , use object. example: def functionthatneedsteam(teamid): team = getteambyid(teamid) dosomething() return functionthatneedsteam(teamid) method 2: if function needs access team object, passed team object itself. example: def functionthatneedsteam(team): dosomething() return functionthatneedsteam(teamobject) i've seen both of these methods used

java - JPanel size not being set -

Image
i'm working on irc bot , today create gui it. i'm trying create column layout has 2 parts, left , right. left side show console output, right contain controls (joining channels, commands etc). i'm having issues creating 2 columns. have jpanel whole width , height of window , has border of 10 pixels, , have 2 panels within that; left , right. the left , right panels reason taking whole size of window, , right panel overlapping everything. here's example picture: http://i.imgur.com/lc4vhvh.png white right panel, should half size , have identical black panel on left of it. here's current code, sorry if it's messy, new whole swing gui.. help. package tk.taylerking.gribbybot; import java.awt.color; import java.awt.dimension; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.keyevent; import java.util.arraylist; import java.util.hashmap; import javax.swing.borderfactory; import javax.swing.swingutilities

linux - PHP fwrite doesn't update the file using the append mode -

the following code working doesn't update contents of file created. i can see file contents have changed (the size increased) when download file server it's empty. file chmod 666 , parent directory well. its linux server running apache , php. i've tried using fflush force flush contents. <?php header("location: http://www.example.com"); $handle = fopen("log.txt", "a"); foreach($_post $variable => $value) { fwrite($handle, $variable); fwrite($handle, '='); fwrite($handle, $value); fwrite($handle, '\r\n'); } fwrite($handle, '\r\n'); fflush($handle); fclose($handle); ?> what problem? thanks! i think practice check if file writable is_writable if can opened checking value returned fopen , way code right. try this: $filename = "log.txt"; $mode = "a"; // let's make sure file exists , writable first. if (is_writable($filename)) { // in our example

c# - Javascript same domain information sharing -

i have website holds 1 setting - number user clicked. i want user see number , able change @ time. until using cookies achieve this. stumbled across error : when user opens address website : http://servername/pick he sees number. when opens address : http://servername.serverdomain/pick he sees diffirent number. , in browser settings see 2 cookies : 1 domain "servername" , 1 domain "servername.serverdomain". is there way share same cookie without relaying on wether user specified domain name? if not, there way without cookies? note : have full control on client , server side (asp.net mvc) you can't share cookies different domains, can use 1 domain primary domain issue cookie , read cookie other domains should redirect domain, read cookie , redirect value in query string. similar, google redirects sign-in requests google.com, google+, docs etc account.gooogle.com or microsoft msn, hotmail, etc login.live.com , back.

mysql - My JOIN query on multiple tables is very slow -

my current query advanced search takes 60 secs complete. suggestions improving this? database: mysql webserver: apache - php (pdo) current code structure: select b.title, count(*) num library.physicalinfo left join library.bibliographicinfo b on a.bookid = b.bibliographicinfoid left join library.authors c on b.bibliographicinfoid = c.bookid left join library.bookauthors d on c.bookauthorid = d.personid left join library.series e on b.bibliographicinfoid = e.bookid left join library.bookslocation f on a.location = f.booklocationid left join library.publishstatement g on b.bibliographicinfoid=g.bookid left join library.publisher h on g.publisherid = h.publisherid ( b.title '%سلام%' or d.name '%سلام%' or f.location '%سلام%' or g.place '%سلام%' or g.year '%سلام%' or h.name '%سلام%' ) limit 0, 30 i've created index

Is this C structure assignment statement legal? -

here code example followed question: #include <stdio.h> #include <string.h> struct st { char stringfield[100]; int intfield; }; typedef struct st st; void test(st *parameterstruct) { st localstruct; strcpy(localstruct.stringfield, "hello"); localstruct.intfield = 5; *parameterstruct = localstruct; } int main() { st mystruct; strcpy( mystruct.stringfield, "xxx" ); mystruct.intfield = 9; printf("%s,%i\n", mystruct.stringfield, mystruct.intfield ); test(&mystruct); printf("%s,%i\n", mystruct.stringfield, mystruct.intfield); return 0; } output: xxx,9 hello,5 i thinking since structure 'localstruct' created inside function (not using malloc) had local scope , memory locations stored free overridden once function stopped executing. however, tried running sample program , executed no issues. thinking second print statement going print gibberish screen since

c# - Guarantees on documented/implicitly documented/undocumented behavior -

looking @ concurrentdictionary documentation says following: represents thread-safe collection of key/value pairs can accessed multiple threads concurrently. now when reading makes me think can call method in concurrentdictionary api , thread safe...but meant include explicit implementations aswell, have guarantee? my example if want atomic operation remove item concurrentdictionary if value value. so can this: var concurrentdictionary = new concurrentdictionary<string, string>(); concurrentdictionary.tryadd("hey", "ho"); ((icollection<keyvaluepair<string, string>>) concurrentdictionary).remove(new keyvaluepair<string, string>("hey", "ho")); now have looked in source code , operation both atomic , thread safe, fact not on concurrentdictionary api mean shouldn't use it...or maybe using collection shouldn't doing it. i can take 1 step further , write following extension method: public stati

curl - Encoding Issue and PHP -

i' using php curl page. post data page , when output response bunch of characters this: ‹˙˙”mkÂ@e÷ţŠ i realize encoding problem. after set default charset utf-8 in php.ini output different still unreadable: �����mk�@e when go page , manually submit form page displays fine in browser, when output trough php using curl make post , output response unreadable. how fix this, how set encodings , where? i using ce characters , had similar problems before: did not having pages utf-8 everywhere page encoding, need check of files - php, js, css etc. - physically encoded in utf-8 too. for purpose using great notepad++, go encoding -> convert utf-8 notepad++ not know saved file(s) in utf-8 , thinks example ansi: if not notice , save problem may repeat once again, learned somewhere nice little trick: use convert utf-8"in notepad++ + put somewhere @ top of files (i using php show php example): <?php //Útf-8 ľščťžýáíéúäôň # script here ?> this way reco

java - TLE for WILLITST (SPOJ) -

i've written code in java below question, , getting correct answer on machine. when submit on spoj, giving tle (time limit exceeded) error. can please me in correcting / improvising this? [question] : http://www.spoj.com/problems/willitst/ here code tried: import java.io.bufferedreader; import java.io.inputstreamreader; import java.math.biginteger; import java.util.arraylist; class willitst { public static void main(string[] args) throws exception { bufferedreader br=new bufferedreader(new inputstreamreader(system.in)); biginteger n=biginteger.valueof(long.parselong(br.readline())); arraylist<biginteger> al=new arraylist<biginteger>(); biginteger x=biginteger.valueof(2); biginteger y=biginteger.valueof(3); while(n.compareto(biginteger.one)==1){ al.add(n); if(n.mod(x) == biginteger.zero) n=n.divide(x); else n=y.multiply(n).add(y); if(al.contains(

ubuntu 12.04 - Why is mysql running with --skip-networking? -

i have ubuntu 12.04, mysql version 5.5.35. /etc/mysql/my.cnf file has no --skip-networking or --skip-grant-tables attributes. annotated following line: # instead of skip-networking default listen on # localhost more compatible , not less secure. bind-address = localhost however when "ps aux | grep mysql" following comes back: root 28880 0.0 0.0 60068 1904 ? s jun02 0:00 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking mysql 28881 0.0 1.1 615828 43844 ? sl jun02 3:35 /usr/sbin/mysqld --skip-grant-tables --skip-networking why running attributes? can still connect jdbc localhost if attributes on? how turn them off? the mysql server not running correctly. had kill process manually , start using "sudo service mysql start". running on correct port , without --skip-networking , --skip-grant-tables.

c# - how to put items in entity classes for multiple tables -

i'm beginner working asp.net entity framework database first. there 2 tables need take data from, , 2 class entities entity framework created already. have code below. using (project_dbentities context=new project_dbentities()) { list<firstinternship> lst=new list<firstinternship>(); lst = context.firstinternships.sqlquery("select * firstinternships ").tolist<firstinternship>(); repeater1.datasource = lst; repeater1.databind(); } this code brings firstinternship table items. have fields in student table. changed code below dont know how hold fields in classes when joining tables. using (project_dbentities context=new project_dbentities()) { list<firstinternship> lst=new list<firstinternship>(); lst = context.firstinternships.sqlquery("select * firstinternships f join students s on s.id=fi.stu

sql - Insert into partitioned table return violates check constraint but shouldn't -

i've table in postgresql , want partitioned. structure below table "dtd1"."logadminactivity" ( "username" character varying( 200 ) not null, "action" character varying( 100 ) not null, "pk" character varying( 5 ) not null, "tabel" character varying( 200 )not null, "timestamp" timestamp without time zone ); then i've create partition table inherit tabel "dtd1"."logadminactivity" above this: create table "dtd1".logadminactivity_kategori ( check ('tabel'='kategori') ) inherits ("dtd1"."logadminactivity"); create table "dtd1".logadminactivity_subyek ( check ('tabel'='subyek') ) inherits ("dtd1"."logadminactivity"); ... create table "dtd1".logadminactivity_satuan ( check ('tabel'='satuan') ) inherits ("dtd1"."l

python - Can't get raw_input to return a number -

print "how old you?", age = raw_input() print "how tall in inches?", height = raw_input() print "how weigh in pounds", weight = raw_input() print "so, %r years old, %r inches tall, , %d kilograms." % ( age, height, weight / 2.2) so new code , code. when use terminal compile it, this: how old you? 1 how tall in inches? 1 how weigh in pounds 1 traceback (most recent call last): file "ex11.py", line 9, in <module> age, height, weight / 2.2) typeerror: unsupported operand type(s) /: 'str' , 'float' can please explain me did wrong? raw_input returns string object. need explicitly convert number object if plan use such (perform mathematical operations on it): weight = int(raw_input()) #or weight = float(raw_input()) use int if number integer. otherwise, use float if input can have decimal part such 10.1 .

go - Complex conditional statement in golang -

i started learning golang , revel. im trying understand below if statement does. seems doing type check, dont see conditional achieves. appreciate if can tell me whats happening here. thanks if str, ok := obj.(string); ok { return len(str) > 0 } it tries convert obj (which of abstract interface probably) string, checks if worked, , enters if turned out okay. written more sparsely can viewed as: // type assertion/conversion of obj string. // if obj isn't string, ok false str, ok := obj.(string) // run if we're talking string if ok { return len(str) > 0 } what go safe casting interface real type. if without ok part, program panic if obj isn't string. i.e code crash program if obj isn't string: str := obj.(string) return len(str) > 0 you can read more type assertions in docs: http://golang.org/ref/spec#type_assertions

ios - Blur Effect using Swift language in iPhone -

i've been trying implement blur effect using uiimageview in xcode 6 (swift language), i'm trying implement below imageview blurred. i cannot make work, i'm asking guys stack overflow me, please. how can done? the code wrote far is: class blurimage: uiimageview { init(frame: cgrect) { super.init(frame: frame) var blur:uiblureffect = uiblureffect(style: uiblureffectstyle.light) var effectview:uivisualeffectview = uivisualeffectview (effect: blur) } } you need assign frame effect blur view , add subview class blurimage: uiimageview { init(frame: cgrect) { super.init(frame: frame) var blur:uiblureffect = uiblureffect(style: uiblureffectstyle.light) var effectview:uivisualeffectview = uivisualeffectview (effect: blur) effectview.frame = frame addsubview(effectview) } }

ios - Error while adding phone gap platform with Xcode 6.0-beta -

when using command cordova platform add ios i getting issues creating ios project... xcode-select: error: tool 'xcodebuild' requires xcode, active developer directory '/library/developer/commandlinetools' command line tools instance cordova can run in xcode version 4.6 or greater. error: /users/ykorshev/.cordova/lib/ios/cordova/3.5.0/bin/create: command failed exit code 2 @ childprocess.whendone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23) @ childprocess.eventemitter.emit (events.js:98:17) @ maybeclose (child_process.js:753:16) @ process.childprocess._handle.onexit (child_process.js:820:5) xcode beta 6 xcode command line developer tools installed. using mac os x v10.9.3 use this: sudo xcode-select -s /applications/xcode6-beta.app/ this works fine me

python - How to get all the months during a two dates -

i have 2 dates let's 04-2012 , 05-2014 i need find way months , years between 2 dates. for example: 04-2012 05-2012 ... 04-2014 05-2014 i tried loop through range cloudn't stop @ last month. one way of doint follows: from datetime import datetime, timedelta d1 = '04-2012' d2 = '05-2014' t1 = datetime.strptime(d1, "%m-%y") t2 = datetime.strptime(d2, "%m-%y") delta = timedelta(days=20) out_dates = [] while t1 <= t2: date_str = t1.strftime('%m-%y') if date_str not in out_dates: out_dates.append(date_str) t1 += delta print(out_dates) % gives: ['04-2012', '05-2012', '06-2012', '07-2012', '08-2012', '09-2012', '10-2012', '11-2012', '12-2012', '01-2013', '02-2013', '03-2013', '04-2013', '05-2013', '06-2013', '07-2013', '08-2013', '09-2013', 

javascript - Create a dynamic JQuery to disable a dropdown -

i working servlet , jsp. have jsp form in have drop down list getting generated dynamically of have 3 options in drop down list. html code -- <form id='form' method='post' action='/test/'> <select id="type" name="typeone"> <optgroup id="first" name="first" label="firstdiv"> <option value="value1" id="001">valuee1 count</option> <option value="value2" id="002">value2</option> <option value="value3" id="003">value3 </option> </optgroup> </select> </form> now need disable few of options in above drop down list using jquery. below jquery in disabling 001 , 002 options have hardcoded id's in below jquery - <script> $(document).ready(function () { $(function () { $("#type option[id='001']").prop("disabl

Jmeter on running test plan log out issue -

i'm testing log in/out functionality in application. on log in, i'm inserting database entry, log out. my test setup jmeter: recording test plan using workbench -> add -> non - test elements -> http(s) test script recorder. [login/logout] run test plan. on running test plan, user log in entry inserted database, on log out, user entry not deleted database. can suggest i'm doing wrong? add config element -> http cookie manager should work

java - A more elegant way to handle different requests in the same servlet -

this question has answer here: design patterns web based applications 5 answers this code of servlet: protected void processrequest(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { string result = (string)request.getparameter("action"); switch (result) { case "init": request.setattribute("countrieslist", signupbean.getcontrieslist()); string arg = "/signup.jsp"; requestdispatcher dispatcher = this.getservletcontext().getrequestdispatcher(arg); dispatcher.forward(request, response); break; case "submit": //code handle request break; } } when click on link signup?action=init servlet

android - Change Image by clicking imageView in getView() of Adapter -

goal: want when ever click image inside list item make changes in database textview (as number of likes increases) change image represent list item liked. error: whenever click image makes changes in database , increases count of corresponding textview. but change images of other list items of clicked item. pleas me following code: public class populartabrowadapter extends baseadapter { list<apidatamodel> videolist; private activity activity; private static layoutinflater inflater = null; imageloader imageloader; populardatasource datasource; int pos; viewholder holder; listview mlistview; public populartabrowadapter(activity activity, list<apidatamodel> videolist, listview list) { this.activity = activity; this.videolist = videolist; inflater = (layoutinflater) this.activity .getsystemservice(context.layout_inflater_service); imageloader = new imageloader(activity); mlistview = list; this.datasource = new po

ubuntu - which user's privileges python program uses to execute command via subprocess? -

i have stabled password less login between 2 ubuntu system run following command $scp file user@hostname2:/tmp/ it works fine , got file transferred without asking password. when try execute same through following python statement- subprocess.check_output(['scp', file, r'user@hostname2:/tmp/']) i not able copy files remote computer, bit curious user's privileges python program uses execute command via subprocess ? how can debug such programs ?

objective c - Customize iOS component to make something like pickerview -

Image
how can make picker/slider or whatever view? it given me designer , have no idea how make it! this not easy task, there different roads can take, 1 makes more sense me subclass uicontrol . uicontrol subclass of uiview , main difference it's ready work target-action pattern , gives possibility track touches without adding gesture recognizer. lot of ui interactive elements concrete subclasses of uicontrol , instance uibutton . ray's site has interesting tutorial how that. harder part integrating autolayout programmatically make adapt size of views. log hard road provides reliable solution, think can achieve similar compositing own uiview subclass using customized slider , labels.

php - automatically populate arrays -

strangely enough haven't found question or answers problem (should quite basic), ask here. in php if have array named myarray don't know contents of, can't this: $myarray[20] = "some string"; because entry 20 may exist. so there way automatically insert string last entry, nothing overwritten in array? you add new item array like: $myarray[] = "some string"; this automatically add end of existing array without overwriting existing array entries.

Configure Liferay tomcat on port 443 -

i want liferay portal accessible https on port 443. default accessible on port 8080. after changing port in server.xml in tomcat unable access liferay. using liferay 6.1 ce on ubuntu 12.04 lts. configure ssl tomcat serve please have follwoing link liferay portal ssl configuration

javascript - How can I add a <thead> section to a marionette collectionview with tagName: 'table'? -

i have collection view looks this: var personview = marionette.itemview.extend({ tagname: 'tr', template: function (model) { return _.template("<td><%= data.firstname %></td><td><%= data.lastname %></td>", { firstname: model.firstname, lastname: model.lastname }, { variable: 'data' }); } }), personcollectionview = marionette.collectionview.extend({ tagname: 'table', itemview: personview }); it works fine, can't figure out best way add <thead> section table. thought of changing tagname: 'table' tagname: 'tbody' , adding thead section in layout displays collection view, doesn't clean approach. indeed, if use collection view elsewhere, have reproduce thead section in layout... proposed way of doing this? p.s see https://github.com/shawninder/table-collection-views work

class - Why can't Swift initializers call convenience initializers on their superclass? -

Image
consider 2 classes: class { var x: int init(x: int) { self.x = x } convenience init() { self.init(x: 0) } } class b: { init() { super.init() // error: must call designated initializer of superclass 'a' } } i don't see why isn't allowed. ultimately, each class's designated initializer called values need, why need repeat myself in b 's init specifying default value x again, when convenience init in a fine? this rule 1 of "initializer chaining" rules specified in swift programming guide, reads: rule 1: designated initializers must call designated initializer immediate superclass. https://developer.apple.com/library/content/documentation/swift/conceptual/swift_programming_language/initialization.html emphasis mine. designated initializers cannot call convenience initializers. there diagram goes along rules demonstrate initializer "directions" allowed:

OptaPlanner Xml configuration and entitySubclass is not configured as a planning entity error -

i new optaplanner , having diffculty in configuring solution. have anotated of classes correctly getting following error when solver runs. a planning entity instance of entitysubclass (class org.optaplanner.core.impl.score.director.drools.droolsscoredirector) not configured planning entity. if class (droolsscoredirector) (or superclass thereof) not entityclass ([...part]), check solution implementation's annotated methods. if is, check solver configuration here xml configuration using. <?xml version="1.0" encoding="utf-8"?> <solver> <solutionclass>(package name).sheetnesting</solutionclass> <planningentityclass>(package name).part</planningentityclass> <scoredirectorfactory> <scoredefinitiontype>hard_soft</scoredefinitiontype> <scoredrl>/resources/drools/nestingrules.drl</scoredrl> </scoredirectorfactory> <termination> <maximu

java - Connection was forcibly closed by the remote host -

i have java.nio.channels.socketchannel in jscsi implamantation disconnecting when try open driver size greater 4gb. iscsi rfc says basicheadersegment.bhs_fixed_size may 48, position can read bytes on channel. java doc says 5 types of errors, app throwing last 1 doesn't specific information. 1 - notyetconnectedexception 2 - closedchannelexception 3 - asynchronouscloseexception 4 - closedbyinterruptexception 5 - ioexception public final int read(final socketchannel schannel) throws internetscsiexception, ioexception, digestexception { // read basic header segment first determine total length of // protocol data unit. clear(); final bytebuffer bhs = bytebuffer.allocate(basicheadersegment.bhs_fixed_size); int len = 0; while (len < basicheadersegment.bhs_fixed_size) { int lens = schannel.read(bhs); if (lens == -1) { // channel closed @ target (e.g. target // not support multiple connections) // throw new closedchannelexception(); return

wordpress - Conditional formatting of single.php based on previous page? -

here's 1 that's been eating @ me. i've got collection of 12 posts called "products" have been assigned categories, let's "military", "trucking", "construction", , "railroad". lot of them overlap, product 1 may applicable both military , trucking , product 2 railroad, example. easy enough. here's gets fun. military page (which using 1 template) bringing in of products have been assigned military category , same trucking (which using different template). , good, when click through product 1, want retain template of page had been on. so basically, how have formatting single.php generated based on page entered from? possible? what on page load have page check cookie of previous page id. check layout page id , serve that. put in footer.php file: global $wp_query; // global query object $post_id = $wp_query->post->id; // set id variable setcookie('last_id', $post_id, false, '/'

C# windows form save recently browsed file history -

i wrote app in c# allows user select directory , simple things on files in directory. want add listbox saves recent 5 selected directories. don't want hook app db because it's simple app. can save values txt file don't think that's best practice. there built-in features in visual studio windows form application allows me that? (i tried *.resx file , doesn't seems work such purpose.) the use of settings can feature. sample go project properties , add new propertie type stringcollection . can manipulate propertie sample collection add ‚remove paths. take in tutorial : http://blog.csharphelper.com/2011/08/18/use-a-setting-that-contains-a-string-collection-in-c.aspx

Node.js handle ENOTFOUND error for http request on invalid host -

i have simple http request function followed couple of sample function calls: var http = require('http'); function makehttprequest(host, path){ var options = { host: host, path: path }; callback = function(response) { var str = ''; //another chunk of data has been recieved, append `str`, don't use @ response.on('data', function (chunk) { str += chunk; }); //the whole response has been recieved, callback response.on('end', function () { console.log('success'); }); response.on('error', function (e) { console.log('how function execute?'); }); } http.request(options, callback).end(); } makehttprequest('ec2-1-2-3-4.compute-1.amazonaws.com','thepage.html') //makehttprequest('google.com','/')//sanity check, 1 works fine running this, get: events

javascript - PhysicsJS - spinning aggregates of newtonian bodies -

i've been playing physicsjs , noticed odd behavior bodies attract each other using 'newtonian' behavior. one example of behavior on "newton's revenge" demo . @ first, bodies start glom expected. however, once lots of them have collected in 1 aggregation, whole thing begins spin faster , faster. centrifugal force dominates gravity , fly apart. any ideas why happens? seems break conservation of energy/angular momentum. maybe related this issue bodies in contact 1 being unstable ? assuming hard-to-fix bug in physicsjs, there easy workaround prevent happening?

android - How to prompt the user to unlock the lockscreen, when he/she click on the lockscreen widget? -

i have made 1 widget shows rss-feed site. when clicked upon, opens respective link. upto here. now when place on lockscreen, responds same on homescreen. want when user clicks on widget, prompts user first unlock screen , open browser. how achieve this? appreciated. please let me know if more information required. thanks.

runtime - deployed pb App transaction not connected -

i have deployed pb app created pb12.5 classic. pb winform app. have managed deployed on test unit test performance. have created custom runtime packager. runtime packager have created consists of basic pb runtime dll, pbdwe125.dll, pbshr125.dll pbsnc125.dll, pbvm125.dll per sybase's instruction in infocenter.sybase.com. i have packaged microsoft dlls atl71.dll, libjcc.dll, libjtml.dll, msvcp71.dll, msvcp100.dll, msvcr71.dll, msvcr100.dll , nlwnsck.dll. all of these dlls installed in c:\program files\sybase\shared\powerbuilder. my problem is, pb app running when try establish connection database server prompt "transaction not connected" is pbsnc problem? tried registering using regsvr32 , didnt work. have used pb runtime packager still no luck. have tried app path registry , link directory stated above , still no luck... my question is there can make work? win 7 has c++ runtime libraries installed right? what can cause of "transaction not connected&

How to Identify product purchased or not form in app purchase in Window Store App -

how identify product purchased or not form in app purchase in window store app while processing purchase. if user click cancel instead of buy. how cancel button event. await currentapp.requestproductpurchaseasync("..."); if (currentapp.licenseinformation.productlicenses["..."].isactive) { ... } else { ... }

java - Basic sample program of Spen SDK throws Run time exception -

Image
i writing basic android app involving spen sdk. xml file is:- <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity"> <framelayout android:id="@+id/canvas_container" android:layout_width="wrap_content" android:layout_height="wrap_content"> <com.samsung.sdraw.canvasview android:id="@+id/canvas_view" android:layout_width="wrap_content" android