Posts

Showing posts from June, 2015

Detect the column and row number where whitespace is occuring using Python programmatically -

we coded data based application recently. using python csv module. there whitespace problems in data. using strip() remove whitespaces. fine including calculations. we got requirement have detect whitespaces , report back. possible detect column no , row no of whitespace in data. please help. edit: operating system windows 7 ubuntu " " fedora please suppose sample of data. data in row nos. 1, 2 , 3 fine. row 3 doesnt have data has whitespace. want detect this. if you're using strip , should remove white-spaces. so: if row.strip() == "" would true if row had white spaces: >>> " \t ".strip() == "" true as fetching data csv file, if post code easier help..

highlight search word in webview android 4.0.4 -

i have lot of search in google still didn't solutions questions .the below code working android2.3 , 4.3.but code not work in android 4.0.4 webview.findnext(true); int i=webview.findall(strr); toast.maketext(getapplicationcontext(), "found "+i+" results !", toast.length_short).show(); try{ method m = webview.class.getmethod("setfindisup", boolean.type); m.invoke(webview, true); log.e("click func clicked:","func clicked:"); }catch(exception ignored){} so,anyone give me suggestion problem.. advance in thanks.... this highlighting search text method android 4.0.4 string strr=search_text.gettext().tostring(); webview web=(webview)findviewbyid(r.id.webview); web.findall(strr); try { (method m : webview.class.getdeclaredmethods()) { if (m.getname().equals("setfindisup")) { m.setaccessible(true); m.invoke((web), true); break; }

node.js - Q.js variables passing in parallel flows -

while implementing promises got code: var mongoclient = require('mongodb').mongoclient mongoclient.connect(db_uri, function(err, db) { if(err) throw err; var ccoll = db.collection('cdata'); app.locals.dbstore = db; } var json= {} //auth wrapped mongo collection var auth = app.locals.auth; var coll = app.locals.dbstore.collection('data'); var ucoll = app.locals.dbstore.collection('udata'); var ccoll = app.locals.dbstore.collection('cdata'); var q = require('q'); //testing _id in database var _id = require('mongodb').objectid('530ede30ae797394160a6856'); //auth.getuserbyid = collection.findone() var getuser = q.nbind(auth.getuserbyid, auth); //getuserinfo gives detailed information each user var getuserinfo = q.nbind(ucoll.findone, ucoll); var getuserdata = q.nbind(ccoll.findone, ccoll); //"upr" group of users //getusers gives me list of users, belonging group var getusers = q.nbind(ucoll.find, u

c# - Issue with getJson in asp.net mvc4 -

i have asp.net mvc 4 project in client side need send part data via ajax , display returned result. have in response []. i'm debugging , i'm sure have not null list<> collection. know mistake? <script> $(document).ready(function() { $(function() { $('#navigation a').click(function () { $.getjson('/home/getjoblist', function (data) { $("#headerjobrow").text(""); $.each(data, function (i, job) { $("#headerjobrow").append("<li>" + job.title + "</li>"); }); }); }); }); }); </script> [httpget] public jsonresult getjoblist() { int roll = 0; if (request.cookies["cityid"] != null) { roll = convert.toint32(request.cookies["cityid"].value);

string - XSL substring on two levels -

i want sub string of text 0-500 characters , display image , again display remaining part of above text. getting 0-500 characters till first full stop, using below code : <xsl:value-of select="substring(metadata/item/body, 1, 500 + string-length(substring-before(substring(metadata/item/body, 501),'.')))" disable-output-escaping="yes"/>. then displaying image.after using code display remaining part of text : <xsl:value-of select="substring(metadata/item/body, 500)" disable-output-escaping="yes"/> output getting : partnership private sector, pharmaceutical sector. image***** cal sector. added future vision health....till end. expected output: partnership private sector, pharmaceutical sector. image***** added future vision health....till end. in code section before image doing wonderful job of finding right place break (which might not @ character 500. in second piece of code rather reu

ios - Xcode UITableView Custom Cell xib Image Height -

Image
please see photo , me, important me. thank much need customize height of custom cell , need resize image views inside custom cell according image - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { cgfloat cellheight = image1height + image2height + <button height>; return cellheight; } also need assign imageview rect in custom cell according images dynamically.

c - Copying a linked list and returning a pointer to the new list -

my current struct is: typedef char airportcode[4]; typedef struct node{ airportcode airport; struct node *next; }node; my idea how function should start this: node *copy(node *list) { int count = 0; while (list != null){ count++; list = list->next; } } now know how long original list is, reason why stumped because have no idea how seperatly allocate memory each individual node have copy second list. you allocate new node malloc: node* newnode = malloc(sizeof(node)); then can change stuff inside new node with newnode->airport = <blah blah blah> newnode->next = <other node, etc etc> it might easier clone recursion rather loop, if use loop, unless lot of pointer manipulation , keep track of many nodes @ time (similar reversing linked list in place ), use stack. so this: node* clonelist(node* head){ if (!head) return null;//done node* n = malloc(sizeof(node)); n->airport = head->airport; n->n

python - Disabling Mouse events - Pygame -

i have game made that, when die, message appears reading "game over. press key play again." however, counts mouse input have no if statements in loop. wondering if there key word can use? can't seem find 1 on google. if event.type != mousemove: this hoping maybe there way it. help! do before event loop: pygame.event.set_blocked(pygame.mousemotion) you'll want block other events, too. see more here: https://www.pygame.org/docs/ref/event.html

javascript - Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ ) in java -

i using url matching parent domain , i-frame domain. getting error put below code inside java class. out.print("ref = url.match(/:\/\/(.[^/]+)/)[1];"); getting error line: invalid escape sequence (valid ones \b \t \n \f \r \" \' \\ ) original script: out.print("<script>"); //need put below line inside java class, using out.print(" "); ref = url.match(/:\/\/(.[^/]+)/)[1]; out.print("</script>"); how use correctly? in java string, have backslash have escape backslash. \ should escaped \ in out.print line: out.print("ref = url.match(/:\\/\\/(.[^/]+)/)[1];"); // ^ ^ that outputs this: ref = url.match(/:\/\/(.[^/]+)/)[1];

How to create Thumbnail Image in PHP without loosing its Original Quality using GD Library -

if(isset($_post["insert"])) { foreach($_files $imgfile) { $tmp_name = $imgfile['tmp_name']; $type = $imgfile['type']; $name = $imgfile['name']; //name of original image $size = $imgfile['size']; if (file_exists($tmp_name)) { if(is_uploaded_file($tmp_name)) { $target="realimage/"; $target .= basename($_files['image']['name']); //path of original image $file = fopen($tmp_name,'r'); $data = fread($file,filesize($tmp_name)); fclose($file); $data = chunk_split(base64_encode($data)); move_uploaded_file($tmp_name,$target); } $extension= explode(".", $target); $extension=$extension[count($extension)-1]; //gives image extension $maxwidth=400;

c# - Propertychanged event firing even when property value not changed -

i bind properties controls in wpf. values of properties assigned/changed recursive method in while loop. values assigned @ rate of ~ 1 ms. of time values not changed @ propertychanged event in setter fires when property value not changed. thinking property setter should raise event only when value of field going change. here simplified version of code: public sealed class fx : system.componentmodel.inotifypropertychanged { public event propertychangedeventhandler propertychanged; public void onpropertychanged(string propertyname) { propertychangedeventhandler handler = propertychanged; if (handler != null) { handler(this, new propertychangedeventargs(propertyname)); } } private bool _somebool1 = false; public bool somebool1 { { return _somebool1; } set { _somebool1 = value; onpropertychanged("somebool1"); //messagebox.show("somebool1 : propertychanged even

Trying to get a javascript function in a php foreach loop to work -

i had question answered regarding creating 2 pop boxes using simple javascript. have attached demo of answer below. novice php developer has started learn js. question this.. the code below forum. 'ask question' creates pop question can asked - part of code fine. questions pulled database using simple php foreach loop , each question, need 'edit' button each question creates pop 'edit question'. demo below works editing 1 question (the first) doesn't subsequent questions. know simple thing, relating how function called etc despite finding 'solutions' online can't work. accustomed being able call function in php anytime want , many times want. isn't case js written here. give me advice? html <button id="askquestion">ask question</button> <button id="editquestion">edit question</button> <div id="overlay"></div> <div id="popup"> <h2>question?</

c# - Why cant bind data from cs to html style attribute? -

i created listview , pass info cs file item template. when pass information cs file item template checkbox gets it's value ( rel='<%# eval("info") %> ) label doesn't ( backcolor='<%#eval("color")%>' ). how make work? <itemtemplate> <tr> <td> <asp:checkbox id="checkbox1" rel='<%# eval("info") %>' runat="server" /> </td> <td> <asp:label id="colorlbl" runat="server" backcolor='<%#eval("color")%>'>&nbsp</asp:label> </td> </tr> </itemtemplate>

Ruby on Rails Model creation string not converted to integer -

here code: base_release_id column in release db integer type form.html.haml = form_for @release |f| = f.label :name %br = f.text_field :name .... = f.label :base_release_id %br = f.select :base_release_id, options_from_collection_for_select(conditionsplusblankorderby(release),"id","name",@release.base_release_id) = f.submit releases_controller.rb def create ap params @release = release.new(params[:release]) ap @release ... end i going create new release including name , base release id etc. using 2 "ap" trace release object. strange thing happen. see log below: { "utf8" => "â", "authenticity_token" => "8hddlc3jjxyvq+8tuh/cut5ibhxjif6l2czaforlnbg=", "release" => { "name" => "e", "code" => "e", "base_release_id"

angularjs - Angular-ui-router: ui-sref-active and nested states -

i using angular-ui-router , nested states in application, , have navigation bar. nav bar hand written, , uses ui-sref-active highlight current state. two-level navigation bar. now, when in, products / categories both products (in level 1) , categories (in level 2) highlighted. however, using ui-sref-active , if in state products.categories state highlighted, not products . is there way make products highlight in state? instead of this- <li ui-sref-active="active"> <a ui-sref="posts.details">posts</a> </li> you can this- <li ng-class="{active: $state.includes('posts')}"> <a ui-sref="posts.details">posts</a> </li> currently doesn't work. there discussion going on here ( https://github.com/angular-ui/ui-router/pull/927 ) and, added soon. update: for work, $state should available in view. angular.module('xyz').controller('abccontro

version control - What to commit into VCS from a Gradle project in Android Studio -

i using android studio 0.4.6 , gradle 1.10. want commit git necessary files , folders, cloning repository can start working project , not have issues of missing files/settings because of not commited file. point needed vcs , optional. from question: " gradle directory in android studio project " see gradle/ folder have it, .idea/, .gradle/, gradlew.bat etc... see inside local.properties should not commited, else? here .gitignore works perfect me now: /app/build .idea/workspace.xml .idea/tasks.xml .gradle local.properties you can take @ what should in .gitignore android studio project? if use .gitignore file questions shouldn't have problems. i think if create new project inside git directory android studio automatically create necessary .gitignore files project. edit: seems android studio generates .gitignore files when create project.

Selenium Java Webdriver: Adding a string to an Xpath -

i have folllowing piece of java in want add string inside statement: @and ("^i want change fieldnumber \"([^\"]*)\" , remove whats inside , add following text: \"([^\"]*)\"$") public void testscenario12345(string number, string text) throws throwable { driver.findelement(by.xpath("//*[contains(@name,'template:view:<insert number string here>:item:view:1:item:')]")).clear(); driver.findelement(by.xpath("//*[contains(@name,'template:view:<insert number string here>:item:view:1:item:')]")).sendkeys(text); how can add number string in above piece of code? clarify, if insert "4" in cucumber, want driver find element xpath, @name contains template:view:4:item:view:1:item: what driver.findelement(by.xpath("//*[contains(@name,\"template:view:" + number+ ":item:view:1:item:\")]")).clear(); and need number const, means: public

linux - What Desktop is setup in my Debian Machine -

i have desktop environment in debian machine. what shell command can use know desktop environment have in debian machine ? know if kde, gnome, xfce... sudo apt-get install wmctrl wmctrl -m | grep "name:" | awk '{print $2}' source: https://askubuntu.com/questions/125062/how-can-i-find-which-desktop-enviroment-i-am-using

clojurescript - In clojure, how to map a sequence and create a hash-map -

in clojure , apply function elements of sequence , return map results keys elements of sequence , values elements of mapped sequence. i have written following function function. wondering why such function not part of clojure . maybe it's not idiomatic ? (defn map-to-object[f lst] (zipmap lst (map f lst))) (map-to-object #(+ 2 %) [1 2 3]) => {1 3, 2 4, 3 5} your function idiomatic. for fn part of core, think has useful people. part of core language , not quite debatable. think amount of stringutils classes can find in java.

html - jquery get can't find any good examples -

i have line of code in example.html there other code want bit <section> should counted </section> i have html page test.html want jquery gets piece of code , prints out onto test.html. cannot find decent website explains well. if knows of website or can give me explanation, more appreciated giving me answer you can see example here: http://jsbin.com/kayey/1/edit?html,output first of you'll need make request file contents , then, set content of file "container" on test.html file: $.get('example.html', function(response){ $('#content').html(response); }); all inside test.html file have div#content element or 1 want. regards, hope works.

sql server 2008 - how to get stored procedure parameters count using C# -

i have 2 stored procedure "same name" different functionality in different database. suppose have 2 database named db1 & db2. in db1 stored procedure contains 7 parameteres , db2 contains 11 parameters. so how can stored procedure parameteres count using c#. using count can add condition both different databases. following links you, http://www.4guysfromrolla.com/articles/092408-1.aspx http://adamprescott.net/2012/09/21/sqlcommandbuilder-deriveparameters/ http://blogs.lessthandot.com/index.php/datamgmt/datadesign/getting-the-list-of-parameters/ any let me know...............

xml - Android: Using self-defined metadata -

i want make android application shows questions on go on basis of user selection. won't use server, , questions have bundled app. adding whole questions not great design, either sqlite database can used, or xml metadata can used. sqlite bundling heard makes app large in size. so? , explain how refer xml file self-defined metadata, create questions on fly. best way this? the sqlite db on phone already, i've used few times no big jump in .apk size. if looking easy-to-use stored hashmap, try sharedpreferences! though wouldn't use heavy solution, implementation guarantees acid , straightforward. can make several different hashmaps , name them different things sharedpreferences http://developer.android.com/reference/android/content/sharedpreferences.html i declare: private sharedpreferences anchorhash; in oncreate: anchorhash = getsharedpreferences(getstring(r.string.anchor_hash), mode_private); inonpause: sharedpreferences.editor editor = anchorhash.

objective c - Disable background and change tint color for custom popup -

in project created custom popups. example uiactionsheet create overlay, disable other interactions , gray out tintcolor of uitabbar buttons, uinavigationbar buttons , on. as i've managed fix manually creating background overlay, disable interaction adding overlay on other views , change tintcolor manually. i've searched api method automatically solve problem, without success. hoping find suggestions here @ so. edit the answer looking called tintadjustmentmode: https://developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/#//apple_ref/occ/instp/uiview/tintadjustmentmode add new view in xib set background color black color , set opacity 50% create popup on view. put view in main view. finally hide & unhide view according requirement. in don't need disable other control.

asp.net - PYTHON: Submitting queries in APSX, and scraping results from aspx pages -

i want scrap info people in " http://www.ratsit.se/bc/searchperson.aspx ", doing following code written: import urllib bs4 import beautifulsoup headers = { 'accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'origin': 'http://www.ratsit.se', 'user-agent': 'mozilla/5.0 (windows nt 6.1) applewebkit/537.17 (khtml, gecko) chrome/24.0.1312.57 safari/537.17', 'content-type': 'application/x-www-form-urlencoded', 'referer': 'http://www.ratsit.se/', 'accept-encoding': 'gzip,deflate,sdch', 'accept-language': 'en-us,en;q=0.8', 'accept-charset': 'iso-8859-1,utf-8;q=0.7,*;q=0.3' } class myopener(urllib.fancyurlopener): version = 'mozilla/5.0 (windows nt 6.1) applewebkit/537.17 (khtml, gecko) chrome/24.0.1312.57 safari/537.17' myopener = myopener() url = 'http://www.ratsit.se/bc/searchperson.aspx' # first http

python - Cartesian product of different size -

i can have cartesian product of lists itertools.product() function : lists = [['a', 'b'], ['1', '2'], ['x', 'y']] combinations = itertools.product(*lists) # [('a', '1', 'x'), ('a', '2', 'y'), ..., ('b', '2', 'y')] what want same thing different sizes : all_comb = magicfunction(lists) # [('a', '1', 'x'), ..., ('b', '2', 'y'), ('a', '1'), ('a', '2'), ... ('2', 'y'), ... ('y')] i can't see 1 obvious way it. i need method let me set minimum , maximum size of tuples (i deal long lists , need combinations of sizes 7 3, number of lists , size vary). my lists more : lists = [['a', 'b', 'c'], ['1', '2'], ['x', 'y', 'z', 'u'], ...] # size may go few dozens >>> itert

sockets - Writing client to server Java -

i need help. i'm making sample queue system. when try write data , store server, server returns exception. i'm newbie on sockets appreciate reply on question. here's code student: import java.lang.*; import java.io.*; import java.net.*; import java.util.*; public class student { public static void main(string args[]) { scanner sc = new scanner (system.in); try { socket skt = new socket("localhost", 1234); printwriter out = new printwriter(skt.getoutputstream(), true); system.out.println("hello!"); system.out.print("please enter name: "); string name = sc.next(); system.out.print("please enter id number: "); string id = sc.next(); string student = name +" - "+ id; out.print(student); } catch(exception e) { system.out.println("whoops! didn't work."); } } } and server: import java.lang.*; import java.io.*; import java.

list index out of range: python -

i have list has these elements(list consists str(elements)): ['-0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15'] and want process have output this ['-0', '1#', '15#'] if element -x want leave there take last 2 elements , if gap 1 remove element before last element. here code: k in range(len(l1)): if "-" in (l1[-k] or l1[-k-1]): print("debuggggg") pass elif(int(l1[-k]) - int(l1[-k-1])== 1 , int(l1[-k]) - int(l1[-k-2])== 2) : a= l1[-2] print(a) l1.remove(a) #print("debug 2") elif(int(l1[-k]) - int(l1[-k-1])== 1): a= l1[-2] l1.remove(a)

cocoa touch - Recreate sliding out keyboard in iOS7 -

Image
there's great effect in ios 7 native messages app when use ios7 's new interactivepopgesturerecognizer pop view in uinavigationcontroller when keyboard open. looks this: note keyboard belongs previous viewcontroller, sticks , feels right. however, no matter how hard try keyboard in app behaves this: i don't modify code @ all, if put [self.view endediting:yes]; somewhere in code (e.g. viewwilldissapear or viewdiddissappear ) - hides keyboard doesn't make stay in example above. i don't think approach of making screenshot of keyboard , placing image right one, slow down process , won't feel fluid @ all. any suggestions on how mimc kind of behavior welcome. the answer question proved simple. there's great working awesome library on github built right this. works flawlessly , requires no code @ all. check out - https://github.com/cotap/tapkeyboardpop

postgresql - Lazarus + Postgres: incomplete startup packet -

i've been building lazarus pascal program using postgresql on back-end. used work fine following lines opening db. dbconn:= tpqconnection.create(nil); dbconn.hostname := 'localhost'; dbconn.databasename:= 'dbhrs'; dbconn.username:='mizk'; dbconn.password:='123'; dbconn.open; if dbconn.connected openhrsdb := true else openhrsdb := false; but moment change localhost server's ip (on lan), program stops. no errors or warnings. have no clue happening. here related details may narrow down problem. the program i'm running workstation on same lan server. both machines run ubuntu 12.04 desktop i can access postgres db on server using pgadmin iii, guess it's not firewall issue. i have allowed postgresql ufw , ufw disabled. strangely, when firewall disabled, can ssh server terminal using workstation. when it's enabled, can't my biggest concern right why pascal program not working when i

objective c - iCloud Demo Sourcecode for iOS and OSX -

i want build ios , mac app stay in sync using icloud. i found apple demo project mac: packageddocument now looking simple demo app includes both ios app , mac app. have seen on wwdc demo demo not seem part of demos ship xcode. try tutorial @ location http://www.appcoda.com/icloud-programming-ios-intro-tutorial/ as starting point

regex - Regular expression to parse values from somewhat complex HTML table -

i have web page contains lot of tables. cannot change page need way work data on page in different application, need able parse , extract data. terrible regular expressions appreciate on this. use regular expression in php (laravel) application if that's relevant syntax. the web page need parse contains lot of these (among other things): <!-- post number: 10000 --> <!-- 127.0.0.1 127.0.0.1 --> <table class="message" cellspacing="0" cellpadding="0" border="0"> <tr> <td> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td class="tableheader2" nowrap> <b>name: </b> firstname lastname </td> <td class="tableheader2" nowrap> <a href="url.html?param=10000"

Find the Same day of Previous Year Given by Current Year Date in SQL Server -

Image
i working sql server, scenario find out same day's date of previous year of today's day. suppose 2014-03-06 today date , day thursday want find same day in previous lies in same week .which 2013-03-07 can body help? here have written: declare @datefrom datetime declare @dateto datetime set @datefrom = '2014-01-01' set @dateto = '2014-02-10' declare @count int set @count = datediff(day, @datefrom, @dateto) create table #current_year /*this year*/ ( [date] datetime , weeknum int, [day] varchar(20), data int ) create table #last_year /*this year -1*/ ( [date] datetime , weeknum int, [day] varchar(20), data int ) while ( @count > 0 ) begin insert #current_year values ( convert(varchar(10), @datefrom, 101), datepart(week,@datefrom), datename(weekday, @datefrom),@count) insert #last_year valu

angularjs - ng-html-bind omitting style tag -

i have ng-bind this <p ng-bind-html="decodetext(item.description)"></p> with decodetext $scope.decodetext = function (data) { return data } however, following json loses style attribute style="color:#ff0000;" when rendered [{"title":"i here","date_received":"feb 28, 2014","description":"<p>ee)\u00a0 <span style=\"color:#ff0000;\"> accepted<\/span><\/p>\n<p>hh)\u00a0 <span style=\"color:#ff0000;\">i am\nhere; <\/span><strong>\u00a0<\/strong><\/p>"} what's causing this? ng-bind-html , $sce.trustashtml used displaying flat html. it seems missing $sce part in code. try instead: $scope.decodetext = function (data) { return $sce.trustashtml(data); }

Android studio and eclipse + ADT -

i'am looking @ android studio tutorials on youtube , find interesting. i'd know if android studio can used in complement of eclipse +adt. is possible use android studio , it's wysiwyg features create layout of app , go in eclipse edit java code of ? thank you. you can it, it's going inconvenient i'm not sure why you'd want to. the biggest problem you'll run eclipse , android studio can't share same project. can share same source tree on disk, you'll need maintain separate project + build files each environment. see using gradle project in both eclipse , idea inspiration on that.

performance - How do I efficiently concatenate ImageMagick and convert commands to produce a no of images -

i have big big size image of dimensions 4000*4000. want carry out various operations on image : convert a.jpg -crop 6x6@ +repage +adjoin tile_6_%d.jpg convert a.jpg -crop 9x9@ +repage +adjoin tile_9_%d.jpg convert a.jpg -crop 3x3@ +repage +adjoin tile_3_%d.jpg convert a.jpg -resize 120x120 thumbnail.jpg thus creating batch of 36+81+9+1 = 127 i trying convert a.jpg \ \( +clone -resize 66% -crop 6x6@ +repage +adjoin -write tile_6x6_%d.jpg +delete \) \ \( +clone -resize 33% -crop 3x3@ +repage +adjoin -write tile_3x3_%d.jpg +delete \) \ \( +clone -crop 9x9@ +repage +adjoin -write tile_9x9_%d.jpg +delete \) \ -density 150 -quality 50 -resize 120x120 thumbnail.jpg but doesn't work desired way , produces 250 files. wrong here ? best way concatenate these commands ? +delete deletes last image in image sequence. want -delete 0--1 , means delete images 0 through -1, negatively indexed -1 refers last image in seque

javascript - How can I extract the values entered in the input boxes generated dynamically and pass it to controller using jquery? -

i have form wherein user can enter input boxes , remove them @ click. want extract values entered in these input boxes , pass them controller using jquery. how do that?right using ids extract values not think better method because suppose add 4 options , remove of them , again add inputs, not able track these ids , extract values. here html code: <button type="button" class="addoption" id="addoption_btn">add more option</button> <div id="options"> <input type="text" name="mytext[]" id="option_1" placeholder="option 1"/> </div> here javascript: var maxoptions = 4; //maximum input boxes allowed var optionsform = $("#options"); //input boxes wrapper id var addbutton = $("#addoption_btn"); //add button id var x = optionsform.length; //initial text box count var optioncount=1; //to keep track of text box added $(add

css - SASS without Ruby for .NET application -

i've been reading on sass(simply awesome stylesheets) on codeschool when tried installing it, turns out need install rvm(ruby) sass written in ruby. so have 2 questions here: i understand there other css frameworks less don't seem powerful/popular. how true this? wouldn't mind switching less if not need ruby @ all. is there compiler sass in .net or java family of languages , if there is, how production ready it? not want keep checking generated css file when debugging or making changes. this comes down want preprocessor , fits project requirements best. people argue either or day long. me see main difference in less can't many programatical things, loops, each statements. kind of thing. sass ruby based, therefore need have ruby installed. there extensions can use in visual studio make sass compiling easier. web workbench , sassy studio . support coming web essentials time soon. so think comes down think fits best. prefer use less in visua

multithreading - Explicit vs intrinsic locking degradation in java -

i have 2 identical classes find next fibonacci number. difference 1 of them uses intrinsic locking , other uses explicit locking. instrinsic locking implementation more faster 1 explicit locking , faster stm or lock free implementations. impl/threads | 1 | 2 | 4 | 8 | 16 | --- | --- | --- | --- | --- | --- | intrinsiclocking | 4959 | 3132 | 3458 | 3059 | 3402 | explicitlocking | 4112 | 5348 | 6478 | 12895 | 13492 | stm | 5193 | 5210 | 4899 | 5259 | 6733 | lockfree | 4362 | 3601 | 3660 | 4732 | 4923 | the table shows average time of single computation of next fibonacci number. tested on java 8 , 7. code placed on github https://github.com/f0y/fibench/tree/master/src/main/java/fibonacci/mdl can explain why intrinsic locking implementation wins? that benchmark wrong on many levels, not make sense discuss results yet. here's simple cut jmh benc

objective c - VideoStabilizationSupport in iOS using AVFoundation -

i using avfoundation record video in ios app. working correctly. trying enable video stabilization while recording video. here code i have avcaptureconnetion as @property(nonatomic, retain) avcaptureconnection *videoconnection; code enable video stabilization when available self.videoconnection = [self.videooutput connectionwithmediatype:avmediatypevideo]; if([self.videoconnection isvideomirroringsupported] && self.videodevicetype == videodevicetypefrontcamera) { [self.videoconnection setvideomirrored:yes]; nslog(@"video mirroring supported"); } else nslog(@"video mirroring not supported"); if ([self.videoconnection isvideostabilizationsupported]) { [self.videoconnection enablesvideostabilizationwhenavailable]; nslog(@"video stabilization supported"); } else nslog(@"!!! video stabilization not supported"); everytime run code , getting below output in xcode console video mirroring supported !!! vid

parsing - Remove line pattern script in Python not fully functional -

for logs parsing, need remove pattern in log file: pattern: acces : lecture donnees (ou liste de repertoire) privileges : - nombre de sid restreint : 0 masque d acces : 0x1 " log sample: # line has kept 2014-03-03 09:50:20,2014-03-03 09:50:20,560,success audit event,accès aux objets,security,la\user1,la-server1,"objet ouvert : serveur de l’objet : security type d’objet : file objet : \vol\vol01\prod\prod.conf identificateur du handle : 554 identificateur de l’opération : - id du processus : 2050 nom du fichier image : server soft utilisateur principal : user1 domaine principal : la id d’ouv. de session principale : (0x0, 0x9596) utilisateur client : 1.2.3.4 domaine client : - id d’ouv. de session client : - acces : lecture données (ou liste de répertoire) Écriture données (ou ajout fichier) ajout données (ou ajout sous-répertoire ou créer instance de canal) write_dac privilèges : - nombre de sid restreint : 0 masque d’accès : 0x40007 " # line has removed 2014

ios - i can't get all the URL from my json. this code show only first URL of json -

- (void)viewdidload { [super viewdidload]; nsurl *url = [nsurl urlwithstring:@"http://www.xovak.com/json_logo.php"]; nsdata *data = [nsdata datawithcontentsofurl:url]; nserror *error; nsmutabledictionary *json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; nsdictionary *logos = [[[json valueforkey:@"logos"]objectatindex:0]mutablecopy]; nsmutablearray *img = [[nsmutablearray alloc]init]; (id item in logos) { [img addobject:[logos objectforkey:@"image_file"]]; nslog(@"%@",img); } } another way of getting imagfile json response. please check it. nsurl *url = [nsurl urlwithstring:@"http://www.xovak.com/json_logo.php"]; nsdata *data = [nsdata datawithcontentsofurl:url]; nserror *error; nsmutabledictionary *json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; nsmutablearray *img = [[nsmutablea

why are '(single quote) or "(double quote) not allowed in subprocess.check_output() in python? -

i using subprocess.check_output() method execute commands within python script. there commands need "(double quotes) present in syntax. here's 1 example: >drozer console connect -c "run app.package.info -a com.package.name" it throws error if remove "(double quotes) above command. i did following : string = '\"run app.package.info -a com.package.name\"' command = ['/usr/bin/drozer','console','connect','-c',string] output = subprocess.check_output(command) this yields me error: *** unknown syntax: "run app.package.info -a com.package.name" please note : commands without quotes running through subprocess.check_output, code works properly. how can solve issue of quotes? highly appreciated. thanks you don’t need double quotes. the reason need them shell command shell parsing command line string, , uses them indication text run app.package.info -a com.package.name sho

android - Calling random value from an array list -

i new android programming on eclipse , have problem trying figure out on how call random values list in array. codes follows: final float column_positions[][] = new float[][] { { 600, 0.5f }, { 900, 0.3f }, { 1200, 0.2f } }; final random rnd = new random(); // random column final float[] randomcolumn = column_positions[rnd.nextint(column_positions.length)]; //get random row random column float random = randomcolumn[rnd.nextint(randomcolumn.length)];

r - plot the results glm with multiple explanatories with 95% CIs -

Image
data: df <- structure(list(x = c(9.5638945103927, 13.7767187698566, 6.0019477258207, 10.1897072092089, 15.4019854273531, 10.9746646056535, 12.9429073949468, 20.7513493525379, 18.5764146937149, 2.91302077116471, 13.6523222711501, 10.0920467755108), y = c(83.949498880077, 18.066881289085, 71.3052196358606, 39.8975644317452, 57.2933166677927, 87.8484256883889, 92.6818329896141, 49.8297961197214, 56.3650103496898, 14.7950650020996, 37.9271392096266, 50.4357237591891), z = c("a", "c", "e", "f", "b", "a", "b", "a", "b", "a", "c", "d")), .names = c("x", "y", "z"), row.names = c(na, -12l), class = "data.frame") my model: mod <- glm(y ~ x + i(x^2) + z, family=quasipoisson, data = df) summary(mod) i want plot this: ggplot(df, aes(x=x,y=y)) + geom_point() + stat_smooth(method="lm",se=false,

node.js - How can I use factor-bundle with browserify programmatically? -

i want use factor-bundle find common dependencies browserify entry points , save them out single common bundle: https://www.npmjs.org/package/factor-bundle the factor-bundle documentation makes seem easy on command line, want programmatically , i'm struggling head around it. my current script (i'm using reactify transform react's jsx files too): var browserify = require('browserify'); var factor = require('factor-bundle') var glob = require('glob'); glob('static/js/'/**/*.{js,jsx}', function (err, files) { var bundle = browserify({ debug: true }); files.foreach(function(f) { bundle.add('./' + f); }); bundle.transform(require('reactify')); // factor-bundle code goes here? var dest = fs.createwritestream('./static/js/build/common.js'); var stream = bundle.bundle().pipe(dest); }); i'm trying figure out how use factor-bundle plugin, , specify desired output file each o

How to print input file next to graph in gnuplot? -

Image
is possible gnuplot print data plotted next graph? if have text file input.txt : #x y 1 2 2 5 3 6 4 7 and plot 'input.txt' i'd have plotted usual , next plot i'd have table printed. possible? note: i'm on windows , i'd format output. sure can. simplest way in gnuplot read in file calling external command ( cat on *nix, not sure on windows) , storing output variable, setting label on graph. here how it: set rmargin 8 datas = system('cat data.dat') print datas set label datas @ graph 1.1,0.7 plot 'data.dat' notitle this puts data file off side, in place of key.

How to pass parameters in cfhttp for put requests in coldfusion? -

i need make put request api using cfhttp . api expects parameters in form scope. put request coldfusion not send parameters in form scope adobe bug how can execute call? i have gone through stackoverflow question , not able make successful call api. showing the request has exceeded allowable time limit tag: cfhttp . have tried increasing time limit still not working. i using coldfusion 10. any suggestions?

C programming help - adding values together/for loop -

i'm trying add values using loop i'm stumped how it. code have far: float counter; float harmonic; float sum; (counter = 2; counter <= n; counter ++) { harmonic = 1/counter; // current value sum = harmonic; // stores current value } return 0; } so each value "harmonic" variable need add next until loop ends. should looking @ arrays? help. change code read float sum = 0; then inside loop write sum += harmonic; you don’t need array unless want remember of values you’ve summed. also, don’t use float loop counter. want int instead.

ios - i used inAppPurchase in my appwhere didReceiveResponse method never called but every time didFailedWithError Called -

i trying add in app purchase in app. have done code. object of skproductsrequest global. -(void)requestproductswithcompletionhandler:(requestproductscompletionhandler)completionhandler { _completionhandler = [completionhandler copy]; _productsrequest = [[skproductsrequest alloc] initwithproductidentifiers:_productidentifiers]; _productsrequest.delegate = self; [_productsrequest start]; } in above method _productidentifiers display correct value when debug it. skproductsrequest delegate method here. -(void)productsrequest:(skproductsrequest *)request didreceiveresponse:(skproductsresponse *)response { nslog(@"loaded list of products..."); _productsrequest = nil; nsarray * skproducts = response.products; (skproduct * skproduct in skproducts) { nslog(@"found product: %@ %@ %0.2f", skproduct.productidentifier, skproduct.localizedtitle, skproduct.price.floatvalue); } _completionhandler(yes, skproducts); _completionhandle

Rewrite Url with urlManager in Yii -

what must in order shorten user's page url like: http://mydomain.com/xegbmcry i set string id each user. you routes in main file should have rule :- '<name:[\w\_]+>' => 'user/view' and acionview in usercontroller should like public function actionview($name)

Python Qt: Interactive Re-Sizable QGraphicsItem, mouse hover area not resizing -

Image
i trying build python class around qgraphicsrectitem (pyside or pyqt4) provides mouse interaction through hover-overs, movable, , re-sizable. have pretty working except: for reason, seems if mouse hover area not changing when item re-sized or moved. need solving issue. maybe problem caused inverting y axis on qgraphicsview : qgraphicsview.scale(1,-1) qgraphicsrectitem class: class boxresizable(qtgui.qgraphicsrectitem): def __init__(self, rect, parent = none, scene = none): qtgui.qgraphicsrectitem.__init__(self, rect, parent, scene) self.setzvalue(1000) self._rect = rect self._scene = scene self.mouseover = false self.resizehandlesize = 4.0 self.mousepresspos = none self.mousemovepos = none self.mouseispressed = false self.setflags(qtgui.qgraphicsitem.itemisselectable|qtgui.qgraphicsitem.itemisfocusable) self.setacceptshoverevents(true) self.updateresizehandles()