Posts

Showing posts from April, 2011

android - ImageSwitcher in fragment throws illegalstateexception but works in an activity -

my code works when in activity. however, decided change fragment, , throws illegalstateexception viewswitcher. can't figure out wrong. in summary, have images use placeholders. when upload image button clicked, fetches uri returned path , uses replace placeholder image in imageswitcher. here's code: private button buttonupload; private imageswitcher imageswitcher; private imagebutton imagebutton0; private imagebutton imagebutton1; private imagebutton imagebutton2; private imagebutton imagebutton3; private imagebutton imagebutton4; private arraylist<string> photoarray; int counter = 0; private static int load_image_results=1; private static int placeholder_image = r.drawable.placeholder_2; int[] imgs = {r.drawable.pic1, r.drawable.pic2, r.drawable.pic3,r.drawable.pic4,r.drawable.pic5}; @override public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate) { // todo auto-generated method stub view rootview = inflater.in

How to put screen reader focus on colorbox popup with jQuery? -

for 508 purposes, need screen readers focus go color box popup. how can jquery? i need know code can put on on load of page make focus go colorbox when user clicks on link , opens. i put class on link within colorbox popup content , added tpl <script> (function($) { $(document).ready(function() { $('a.colorbox-load').click(function(event) { $(".colorbox-link").focus(); }) }) })(jquery); </script>

python - matplotlib figure inset whitespace -

Image
i'm making figure includes inset. cannot figure out how whitespace on removed. i've tried using tight_sublot() still leaves whitespace near inset i'd remove. suggestions? import numpy np mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot plt import silicon2_data data = silicon2_data.out fig = plt.figure() ax = fig.add_subplot(111, projection='3d') temperature in data: xs = temperature[:,0] ys = temperature[:,1] zs = temperature[:,2] ax.scatter(xs, ys, zs) ax.set_zbound(0, 1.4) ax.set_xlabel(r'$2\theta$ (degrees)') ax.set_ylabel('temperature (k)') ax.set_zlabel(r'intensity ($10^5$cts/sec)') #inset ax2 = fig.add_axes([0.15, 0.62, 0.25, 0.25]) ax2.plot(data[3,:,0], data[3,:,2],'bo') ax2.plot(data[7,:,0], data[7,:,2],'rx') ax2.legend(('16k', '18k'), loc=0, fontsize ='small') ax2.set_ybound(0, 1.4) plt.tight_layout() plt.show() this i'm trying make: aft

javascript - Doesn't work the onclick event in my Phonegap app -

my name borja , started programming phonegap , first issue related non-existent executing of .js files. index.html code : <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, user-scalable=no"> <link href="css/jquery.mobile-1.4.3.min.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="css/font-awesome.min.css" /> <link rel="stylesheet" href="css/jquerymobile.nativedroid.css" /> <link rel="stylesheet" href="css/jquerymobile.nativedroid.light.css" id='jqmndtheme' /> <link rel="stylesheet" href="css/jquerymobile.nativedroid.color.green.css" id='jqmndcolor' /> <link rel="stylesheet" href="css/custom.css" /> <script src="js/jquery-1.9.1.min.js"></script> &

ios - enterprise provision vs ad hoc provision -

here situation: enterprise provision profile doesn't seem work on particular app. actually, seems work because starts quit after launch screen. have verify app work if use ad-hoc provision profile. have verify same enterprise provision profile works different apps well. i don't know info should put here :-( wondering maybe need include entitlement files enterprise provision not needed ad-hoc? === tks matt's suggestion. following error: dyld error message: library not loaded: @rpath/libswiftcore.dylib referenced from: /private/var/mobile/containers/bundle/application/90ef4c24-3bdb-4c14-9fe3-5b29ebf53b6b/mapview.app/mapview reason: no suitable image found. did find: /private/var/mobile/containers/bundle/application/90ef4c24-3bdb-4c14-9fe3-5b29ebf53b6b/mapview.app/frameworks/libswiftcore.dylib: mmap() error 1 @ address=0x100118000, size=0x0018c000 segment=__text in segment::map() mapping /private/var/mobile/containers/bundle/application/90ef

preg_replace multiple strings between brackets (php/regex) -

i have string [test](test\\-test\\-abc) abcde\\- i have [test](test-test-abc) abcde\\- i need replace \\- - regex/preg_replace. need replace string between parenthesis. found solution replaces first occurance. $result = preg_replace("/(\[.*?\])(\(.*?)(\\\\-)(.*?\))/", '$1$2-$4', $str); you can use preg_replace_callback : $str = '[test](test\\\\-test\\\\-abc) abcde\\\\-'; $txt = preg_replace_callback('~\([^)]+\)~', function ($m) { return str_replace('\\\\-', '-', $m[0]); }, $str); echo $txt; //=> [test](test-test-abc) abcde\\-

javascript - jQuery Each Loop Not updating HTML in variable -

i have variable html stores html: <tr class="odd"> <td class="charge1">0</td> <td class="nc1">0</td> </tr> <tr class="even"> <td class="charge2">0</td> <td class="nc2">0</td> </tr> <tr class="odd"> <td class="charge3">250</td> <td class="nc3">0</td> </tr> basically need add values td class starting charge values td class starting nc , replace value in td class starting nc sum. values in both td 's in each row change, code needs dynamic. example, resulting hmtl in variable should be: <tr class="odd"> <td class="charge1">0</td> <td class="nc1">0</td> </tr> <tr class="even"> <td class="charge2">0</td> <td class="nc2">

actionscript 3 - Serial communication with Arduino and serproxy to flash. Expected result just in test mode -

i have arduino 3 sensors connected. every 100ms arduino print new line on serial 3 updated values separated #: ex.: 23#11#50_18_1_14_48_0_226_0_16_33_64_2_1_97_36_128_24_170 26#12#50_18_1_14_48_0_226_0_16_33_64_2_1_97_36_128_24_170 33#11#50_18_1_14_48_0_226_0_16_33_64_2_1_97_36_128_24_170 48#10#50_18_1_14_48_0_226_0_16_33_64_2_1_97_36_128_24_170 using serproxy pass values flash , as3 socket functions can trace serial output in test mode (ctrl+enter). @ point works expected. when publish , run swf file can receive serial data not expected... every 100ms receive part of output. not same part , not full expected output receive in test mode. could related security? here flash code receive data: var datasocket:socket = new socket("localhost",5333); datasocket.addeventlistener(progressevent.socket_data, socketdatahandler); function socketdatahandler(event:progressevent):void { var sensvalue:string; sensvalue = datasocket.rea

numbers - finding values of x and y using Octal Base system -

in finding values of x , y , if (x567) + (2yx5) = (71yx) ( in base 8) proceeded under. i assumed x=abc , y=def , followed. (abc+010 def+101 110+abc 111+101)=(111 001 def abc) //adding ()+()=() , equating lhs=rhs. abc=111-010=101 5 in base 8 , def=001-101 -4 x=5 , y=-4 now question answer mentioned in book x=4 , y=3 . is above method correct.if so,then what's issue here ?? you can't compare digits beginning significant digit, because don't know carry digit below. digit cannot have negative value. you can start least significant digit, because there no carry: 7 + 5 = 14 so x = 4 carry of 1 @ next digit. can rewrite equation to: (4567) + (2y45) = (71y4) now can @ second least significant digit (the carry in mind): 6 + 4 + 1 (carry) = 13 so y = 3 , carry of 1. the whole equation is: (4567) + (2345) = (7134) which true octal system.

excel - How to repeat all column values for each row in another column -

i have table has 2 columns: height width 400 200 500 300 600 400 700 800 ... and need create second table next repeat entire column height each value in width column, whilst copying, every possible combination: height width 400 200 500 200 600 200 700 200 800 200 400 300 500 300 600 300 700 300 800 300 the simplest way think of running nested loops. might need modify code below depending on structure of sheets, should going. sub loops() dim n_height, n_width, c integer thisworkbook.sheets("sheet1") n_height = .cells(rows.count, 1).end(xlup).row 'assuming height in column n_width = .cells(rows.count, 2).end(xlup).row 'assuming width in column b c = 2 = 2 n_height j = 2 n_width .range("d" & c).value = .range("a" & i).value 'prints heights in column d .range("e" & c).value = .range("b" & j).value 'prints widths in column e

linux - Splitting out timestamp/key/value pairs from bash -

hi have file full of data; time stamps beginning of line. need break down file , print each line individually. how can accomplish using bash , (if needed) standard unix tools (sed, awk, etc)? the time stamp field goes 08:30:00:324810: onward .. example 17:30:00:324810: . number of field following time stamp varies; there 1 x number of fields . need find time stamp format , insert page break. 08:30:00:324810: usg_07y bidyield=1.99788141 bid=99.20312500 08:30:00:325271: usg_07y askyield=1.98578274 ask=99.28125000 08:30:00:325535: usg_10y ask=0.00000000 08:30:01:324881: usg_07y bidyield=2.02938740 askyield=1.97127853 bid=99.00000000 ask=99.37500000 08:30:01:377021: usg_05y bid=0.00000000 ask=0.00000000 thanking u in advance matt it trivial. read file array , find timestamp , output newline before it: #!/bin/bash set -f # inhibit globbing (filename expansion) declare -i cnt=0 # simple counter a=( $(<"$1&qu

indexoutofboundsexception - java.lang.ArrayIndexOutOfBoundsException: 10 please assist me -

for reason when run code, java.lang.arrayindexoutofboundsexception: 10 error. public class customerrecords { static customer[] c = new customer [10]; public static void main (string[] args) throws exception { menu (); } public static void menu () throws exception { int option = 0; string blank = ""; { string stroption = ""; char choption = ' '; option = 0; system.out.println ("main menu\n1. add new customer information\n2. view customer records \n3. exit"); system.out.println ("\n"); choption = (char) system.in.read (); while (choption >= '0' && choption <= '9') { stroption += choption; choption = (char) system.in.read (); } option = integer.parseint (stroption); system

java - Validating an objects arguments -

i'm not sure how validate info of object's arguments(parameters? if can explain difference, great!). basically, default values of variables need 1.0 when run below 1.0, doesn't take consideration if statements have put up. example, negative values stay negative.how can make if below 1.0, must set 1.0? thank you! private double length; private double width; private double height; public box(double l, double w, double h){ length=l; if(l<1.0) l=1.0; width=w; if(w<1.0) w=1.0; height=h; if(h<1.0) h=1.0; } public void setlength(double l){ if(l<1.0) l=1.0; } public void setwidth(double w){ if(w<1.0) w=1.0; } public void setheight(double h){ if(h<1.0) h=1.0; } here main box box3= new box(7,8,9); box box4= new box(-1.0,-2.0,-3.0); you setting local variables instead of members, have different names : private double length; private double width; private double h

.htaccess - redirecting URLs that have listing IDs attached -

i'm attempting redirect following page traveltechjobs.com/display-job/42770/entry-level-travel-counselor--tep-extraordinary-customer-service.html to http://hottraveljobs.com/display-job/42746/dedicated-account-specialist--american-express-global-business-travel-(florham-park,-nj).html and furthermore, have same happen item on site /display-job/ after .com redirect mirror on hottraveljobs. i attempted few methods, query redirect rules , redirect match no luck or 'listing id not defined' result. is possible, or have manually create 1 every page wish redirect? i not know if that's want do: .htaccess root folder: rewriteengine on rewriterule ^display-job/(\d+/) http://hottraveljobs.com/display-job/$1 [r=302,l] change [r=302] [r=301] when test work well.

c# - Disable SSL client certificate on *some* WebAPI controllers? -

Image
edit future readers : unfortunately, bounty awarded answer doesn't work; nothing can now. read own answer below (through testing) - confirmed work minimal code changes we have azure cloud service (webrole) that's entirely in asp.net webapi 2.2 (no mvc, front end angular). of our controllers/rest endpoints talk 3rd party cloud service on ssl (client cert auth/mutual auth) , rest of controllers/endpoints talk html5/angularjs front end, on ssl (but more traditional server auth ssl). don't have non-ssl endpoint. we've enabled client ssl via cloud service startup task like: if not defined appcmd set appcmd=%systemroot%\system32\inetsrv\appcmd.exe %appcmd% unlock config /section:system.webserver/security/access issue: setting site-wide when users hit first page (say https://domain.com , returns index.html angularjs) browser asks them client ssl cert. (image below) if there way either limit client ssl certificate requests webapi controllers talk 3rd par

php - Advanced Custom Fields Repeater inside product category (woocommerce) -

i using acf 5. have set repeater on product categories. i'm struggling how output information. inside acrhive-product loop , updating following template contains content gets outputting: <?php while ( have_posts() ) : the_post(); ?> <?php wc_get_template_part( 'content', 'product_cat' ); ?> <?php endwhile; // end of loop. ?> in content-product_cat.php have following each loop repeater. basic information shows, title, woocommerce category image etc. repeater added categories can't show. <?php $terms = get_field('attributes', 'product_cat_'.$term->term_id); if($terms): ?> <ul> <?php foreach( $terms $term ): ?> <li> <?php the_sub_field('attribute'); ?> </li> <?php endforeach; ?> </ul> <?php endif; ?> any thoughts appreciated printed out args first: <?php

Android setText() method not working when calling data from Java class -

i'm having trouble getting android app display right information in textviews. toasts added ensure variables being passed alright kw1, kw2 , kw3. object 'user' being passed ok, , can manually set textview settext("example") want change text in textview array results returned searchsuggest() method using following code: for (int index3 = 0; index3 < validrecipe; index3++){ recipetext[index3].settext((setrecipes.recipes[temp[index3]].getname())); } setrecipes name of java class recipes hardcoded - suggestmethod() implemented within until couldn't work , copied code here. (which explains why method no longer called anything, , within oncreate()). does know why text in textviews aren't changing? sorry asking, i've been sitting here fore numerous hours googling , can't find definitive answer. relatively new programming , beginner in android, basic related linking java classes android activites. let me know if need other cod

node.js - Can't configure Socketio: TypeError: Object #<Server> has no method 'configure' -

i'm trying simple token authorization socketio outlined in docs . node throws: typeerror: object #<server> has no method 'configure' when try configure socketio io.configure . idea why configuration method wouldn't available? var express = require('express') , app = express() , server = require('http').server(app) , io = require('socket.io')(server) io.configure(function (){ io.set('authorization', function (handshakedata, callback) { ... }) full stacktrace: /users/administrator/dev/chat-example/lib/io.js:9 io.configure(function (){ ^ typeerror: object #<server> has no method 'configure' @ module.exports (/users/administrator/dev/chat-example/lib/io.js:9:6) @ object.<anonymous> (/users/administrator/dev/chat-example/app.js:4:29) @ module._compile (module.js:456:26) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ fun

How can I get the server name for where node.js is running? -

i want add line point different database depending on server running node.js on (localhost vs test.com, etc). how server name in node.js? is, server side equivalent location.host? var os = require('os'); os.hostname(); link

java - Is it possible to listen the click of a bluetooth button? -

i want launch remotely http request through android app. is possible use example bluetooth selfie button http://www.dx.com/fr/p/wireless-bluetooth-v3-0-selfie-camera-remote-controller-shutter-for-ios-android-devices-black-353773#.viiaizgg8kq in order execute http request ? so question : possible listen click of bluetooth button ? if how ? this bluetooth button aimed @ taking pictures. or see hardware action remotely http request ? best regards, you can achieve this. not sure particular bluetooth button, have done others, principle should same. these buttons paired bluetooth keyboards device. once connected activity gets signals corresponds keyboard key clicks (usually enter key, triggers shutter in standard camera app). means can overwrite onkeydown(int keycode, keyevent event) , check if keycode bluetooth button sends. if case, http request, or whatever else like. in order connect button, have write own broadcast receiver , listen different actions. take

wiki - How do I stop Redmine from automatically referencing issues? -

when working on page wiki, put couple of numerical list items , have centred image on page inbetween steps, so: # step 1 # step 2 p=. !someimage.png! figure 1 - image caption #3 step 3 # step 4 but when redmine renders step 3, automatically references issue #3 instead of continuing numbering @ "3." have read on textile syntax wiki using #3 start numbering @ "3." not case in redmine wiki. is there way stop behaviour? have looked other solutions not able retain centred images when trying force ordered list continue numbering. thanks :) this should work # step 1 # step 2 p=. !someimage.png! figure 1 - image caption # step 3 # step 4 remind: redmine based on textile has own tags.

javascript - jQuery DataTables plugin: add column headers dynamically -

i interested in creating function creates datatables dynamically the data parameter passed in function. below wrote far, datatables can add rows dynamically, not column header - can use here (i've read dt api, didn't find there). var table2 = $('#example2').datatable({ "paging" : true, "ordering" : true, }); // header row table2.columns().header(data["header"]).draw(); // create rows (var prop in data["staff"]) { table2.row.add([ data["staff"][prop].name, data["staff"][prop].position, data["staff"][prop].office, data["staff"][prop].age, data["staff"][prop].start_date, data["staff"][prop].salary ]).draw(); } the data passed function: var data = { "header": [ "name", "position", "office", "

php - Redirect not working with header("Location: -

i've searched can't seem figure 1 out. have config.php searches active session , if found passes user through, if not fowards login.php page. config.php grabs orginal url , posts login.php can redirect them page going originally. from there should pretty simple, authenticate , use redirect variable forward browser original page. it's not working that. forwards me login.php , says "object moved". redirects if put header("location: /index.php"); not if use variable in login.php below. any appreciated! php (config.php): <?php session_start(); // put somewhere in config file define('session_expire',3600); // in seconds // check passage of time, force log-out session expire time if(isset($_session['last_activity']) && (time() - strtotime($_session['last_activity']) > session_expire)) { // destroy session session_unset(); session_destroy(); } // if user logged in , unexpired, update activity if(isset($_se

three.js - Pan is the only working thing for OrbitControls -

i trying program solar system can orbit around , pan added orbitcontrols project , pan working fine reason rotate , zoom aren't working. have tried copying other people's examples , cannot figure out wrong mine. don't know if computer, have no reason believe be. <!doctype html> <html> <head> <title>example 01.02 - first scene</title> <script type="text/javascript" src="../libs/three.js"></script> <script type="text/javascript" src="../libs/jquery-1.9.0.js"></script> <script type="text/javascript" src="../libs/stats.js"></script> <script type="text/javascript" src="../libs/dat.gui.js"></script> <script type="text/javascript" src="../libs/orbitcontrols.js"></script> <script type="text/javascript" src="../libs/chroma.js"></sc

android - Can someone please explain or walkthrough a progress bar as a timer -

yes, know android developers site. i've scoured internet day trying figure out happening here , how can incorporate timer kegel app i'm trying make (personal use because don't ones on market). anyhow, i'm not familiar handlers or threads , how used. if point me in right direction, appreciate it. public class myactivity extends activity { private static final int progress = 0x1; private progressbar mprogress; private int mprogressstatus = 0; private handler mhandler = new handler(); protected void oncreate(bundle icicle) { super.oncreate(icicle); setcontentview(r.layout.progressbar_activity); mprogress = (progressbar) findviewbyid(r.id.progress_bar); // start lengthy operation in background thread new thread(new runnable() { public void run() { while (mprogressstatus < 100) { mprogressstatus = dowork(); // update progress bar mhandler.post(new runnabl

Rewrite Rule with dynamic link -

i trying rewrite rule: from: http://example.com/login.php?new= "dynamic string" to: http://example.com/signup/?new_user= "dynamic string" my code: rewriterule ^login.php(.*)$ /signup/$1 but cant right result... get: http://example.com/?new_user= "dynamic string" worked me: rewritecond %{query_string} new=(.*) rewriterule ^login.php(.*)$ /signup/?new_user=%1 [r=301,l]

How to apply combination of multiple functions in R in a smart manner? -

lets assume have 4 functions. these sample functions. in real scenario functions more complicated. f1= function(data){ data1= data*2 return (data1) } f2= function(data){ data1= data*4 return (data1) } f3= function(data){ data1= data*data return (data1) } f4= function(data){ data1= data**5 return (data1) } data = matrix(1:100,10,10) now want apply combination of these function , see output of each f1 f2 f1 f3 f1 f4 ... f1 f2 f3, f1 f2 f4.... f1 f2 f3 f4. my question how apply combination of these functions smartly. first, put functions in list ff <- list(f1=f1,f2=f2,f3=f3,f4=f4) then here's helper function generate list of possible combinations of elements list allcomb <- function(x) { do.call("c", lapply(seq_along(x), function(n) combn(x,n, simplify=false))) } then, can generate lists of functions can pass reduce() apply them sequentially data (and i've added setnames() identify each result came from) se

ios - How do you pass an array through a PHP web server URL? -

This summary is not available. Please click here to view the post.

java - reading an arraylist collection from binary files and assigning each element in new array -

previously, have wrote arraylist data binary file called (itstatebinary.dat) and trying read arraylist binary file, assign each of element in arraylist array. so far have this: public carowner[] readlistfrombinary() throws exception { string filename = "itstatebinary.dat"; fileinputstream instream = new fileinputstream(filename); objectinputstream objectinputfile = new objectinputstream(instream); //need create carowner[] object called temp , return } readlistfrombinary() method reads arraylist collection binary file (ltstatebinary.dat). then, each arraylist object item written newly created carowner[] called temp. temp returned calling method. edit: public carowner[] readlistfrombinary() throws exception { string filename = "itstatebinary.dat"; fileinputstream instream = new fileinputstream(filename); objectinputstream objectinputfile = new objectinputstream(instream); arraylist<carowner> read = (arraylist

angularjs - How to add a directive onto a node in an ng-repeat only once -

i have feature tour directive similar joyride works adding directive onto dom element highlights element during user walk through. example: <button test-drive-step test-drive-text="to activate search click here" test-drive-next-label="next">search</button> my question if want place on list of elements , point out single element using feature how that? example if node wanted place test-drive-step directive on in ng-repeat how limit directive 1 element out of items rather all? for example, <li ng-repeat="item in items" test-drive-step ...>{{item.name}}</item> that place test-drive-step directive on every element in items, want on first element. how limit first element? one option pass in conditional directive, telling whether apply itself. for example can use $index === 0 test whether on first ng-repeat element ( $index being ng-repeat element on). so <li ng-repeat="item in i

xcode - Linking error when building TutorialHelloWorld in UnityPro4.6.0f3, Xcode5.0.2 (5A3005) and IOS 8.1.1 -

i did best follow tutorial "webinar 10:fundamentals of metaio sdk unity" ( https://www.youtube.com/watch?v=aw47ekrkedw ) use different version of metaio me(i'm using metaio sdk (version 22/05/2014)). i manage produce project in xcode imported form unitypro. after add: "libxml2.dylib" , "metaiosdk" xcode project; , build project, 130 errors , 7 warnings. the warning before error list says: "ld: warning: directory not found option '-l"/users/900lbs-intern02/desktop/metaio-test/libraries"' and top error says: "std::__1::basic_string, std::__1::allocator >::insert(unsigned long, unsigned long, char)", referenced from:" i tried solve warning doing suggested in( ‘ld: warning: directory not found option’ ). before building again, cleaned project(command+shift+option + k) , following 7 warnigs , 1 error(i show last warning , error): ld: warning: directory not found option '-l"/users/900lbs-

animation - Plotting a quadratic equation in Delphi/Lazarus -

i trying animate object's position using quadratic equation rapid-start-slow-stop kind of movement. this available in delphi xe6 using delphi xe2 , lazarus , have created own animation handling system works great actually. i have linear formula , half-sinus formula, want quadratic formula. the half-sinus formula move object rapidly @ start , slows down, want more exaggerated curve, rapid @ start , slows down lot , halts. unfotunately have no code available since code looking for. i have used our dear friend mr google, no luck finding information can comprehend. basically needed formula gives floating point number rangin 0 1. i take delta of position of object needs moved , multiply formula needed. in animation system have 2 values regarding animation process: var currentpos, resolution: single; the value "currentpos" represents position of formula. instance sinus can apply "currentpos" angle, or x axis of plot, , "resolution" ma

python 3.x - Django Formset Custom Field Exclusion -

i created form has 2 radio buttons (male/female). below have input box first name , last name. if use formset replicate form, include radio buttons every input box , wanted exclude that. assume once user select "male" names should matches gender selection. the output should so: o male o female first name: _______________ last name: _______________ first name: _______________ last name: _______________ ... forms.py django import forms class nameform (forms.form): gender = ( ('male', 'male'), ('female', 'female') ) gender = forms.choicefield (widget = forms.radioselect, choices = gender) first_name = forms.charfield (max_length = 20) last_name = forms.charfield (max_length = 20) shell output: >>> django.forms.formsets import formset_factory >>> nameform.forms import nameform >>> >>> nameformset = formset_factory (nameform, = 2) >>> f

php - Wrap Symfony form fields in a div in Twig -

given simple form build: $form = add('a') ->add('b') ->add('c') ->add('d') ->add('e') ->add('f'); i'd wrap div tag around abc , def, so: <div class="section1"> <input type="text" name="a" /> <input type="text" name="b" /> <input type="text" name="c" /> </div> <div class="section2"> <input type="text" name="d" /> <input type="text" name="e" /> <input type="text" name="f" /> </div> problem is, able use symfony form component project. there way twig render form fields in groups above? need specify logic says simliar "start section 1 'a' , section 2 'd'", way if fields change inbetween (say remove field name 'b') form still work

4 bit Binary Addition in C++ -

we given assignment make program takes 2 decimal numbers input , performs binary addition in background outputs decimal sum. seem getting wrong results despite how think code logic correct. my current sum gives me 0. correct answer should 24. #include <iostream> #include <sstream> #include <string> using namespace std; int add(int, int); int decbin(int); int bindec(long); int binadd(string, string); int main() { int = 15; int b = 9; int z; z = add(a,b); cout << z; return 0; } int add(int a, int b) { int z; ostringstream x, y; x << decbin(a); y << decbin(b); z = binadd(x.str(), y.str()); return z; } int decbin(int x) { int d[16]; int = 0; int j; int ans; while(x > 0) { d[i] = x % 2; i++; x = x / 2; } for(j = - 1; j >= 0; j--) { ans = d[j]; } return ans; } int bindec(int x) { int bin, dec = 0, rem, b

Octave error: dyld: Library not loaded: /usr/X11/lib/libfreetype.6.dylib -

when try open octave, following error: $ exec '/applications/octave.app/contents/resources/bin/octave' dyld: library not loaded: /usr/x11/lib/libfreetype.6.dylib referenced from: /applications/octave.app/contents/resources/bin/octave-3.4.0 reason: no suitable image found. did find: /usr/local/lib/libfreetype.6.dylib: mach-o, wrong architecture /applications/octave.app/contents/resources/bin/octave: line 68: 60135 trace/bpt trap: 5 octave_home="${octave_home}" path="${path}" dyld_library_path="${dyld_library_path}" cc="${cc}" cxx="${cxx}" cflags="${cflags}" cppflags="${cppflags}" cxxflags="${cxxflags}" fflags="${fflags}" ldflags="${ldflags}" dl_ldflags="${dl_ldflags}" sed="$sed" magick_home="${root}" fontconfig_path="${root}/etc/fonts" "${root}/bin/octave-3.4.0" "$@" [process completed] i don't

security - Safety of Self-signed certificate in a point-to-point socket with SSL -

i confirm understood using self-signed certificates if used point-to-point socket ssl. suppose have 1 client , 1 server. generate self-signed certificate , install certificate on both server , client. machines otherwise accept no other certificates. does mean in order mitm attacks, attacker must physically hack 1 of machines obtain certificate? what other vulnerabilities setup present if these 2 machines using certificate? thanks! yes, correct. in scenario describe, certificate used convenient way move public key machine. if configure client , server trust certificate, communication secure long can keep private key safe. other attack vectors exploiting other vulnerabilities in application or operating system runs in.

java - How to iterate HashMap without entrySet -

in original java source, must use entryset iterate hashmap, instance: (map.entry<string, string> e : new hash<string, string>().entryset()) { } i expect more simple way iterate hashmap following: package ro.ex; import java.util.hashmap; import java.util.map; /** * created roroco on 11/17/14. */ class hash<k, v> extends hashmap<k, v> { // how implement? } public class ex2 { public static void main(string[] args) { // expect (hash.entry<string, string > e : new hash<string, string>()) { } } } my question is how implement it? implement iterable<map.entry<k, v>> : class hash<k, v> extends hashmap<k, v> implements iterable<map.entry<k, v>> { @override public iterator<entry<k, v>> iterator() { return entryset().iterator(); } } this works because implementing iterable allows type used in for-each loop.

opencv - Setting iPhone lens position for focus -

this out there having trouble getting consistent calibration parameters on iphones. old trick focus phone infinity can sure obtained consistent camera matrix without recalibrating. so question how come there isn't method allows manually set focus plebs attempting computer vision applications. /*! @method setfocusmodelockedwithlensposition:completionhandler: @abstract sets focusmode avcapturefocusmodelocked , locks lensposition @ explicit value. @param lensposition lens position, described in documentation lensposition property. value of avcapturelenspositioncurrent can used indicate caller not wish specify value lensposition. @param handler block called when lensposition has been set value specified , focusmode set avcapturefocusmodelocked. if setfocusmodelockedwithlensposition:completionhandler: called multiple times, completion handlers called in fifo order. block receives timestamp matches of first buffer settings have been applied. n