Posts

knockout.js - Remove the value Binding based on the model -

knockout.js - Remove the value Binding based on the model - i have model property @ times should bind input element , select element, based on configuration. utilize value binding on both elements , hide either 1 using visible binding. as both bindings on page, when input visible , when come in text not exists in hidden select , unable alter value. in case input element visible ( isdropdown false) not want select bound (or there other improve way handle this?). sample javascript model var player = function (name, age, country, isdropdown) { this.name = ko.observable(name); this.age = ko.observable(age); this.country = ko.observable(country); this.isdropdown = ko.observable(isdropdown); }; var playermodel = function () { var self = this; self.myplayer = new player('murray', 28, 'uk', false); //self.myplayer = new player('murray', 28, 'uk', true); self.countrylist = ['us', 'uk', 'sw...

parsing - Best way to parse comma delimeted CSV that include commas that arnt delimeters? [Java] -

parsing - Best way to parse comma delimeted CSV that include commas that arnt delimeters? [Java] - this question has reply here: java: splitting comma-separated string ignoring commas in quotes 9 answers i'm trying parse info sets through database. csv files i'm working have info separated commas. there info encompassed quotation marks include commas part of string. how step through each line of info , parse out each info entry given obstacle? edit: csv parsers not alternative because programme used non csv files. , i'm trying minimize external libraries. i found issue because of code here parse through quotes: while(bufferinput.hasnext()){ nextline = bufferinput.nextline(); dataarray = nextline.split(","); for(i = 0; i<colnum;i++){ //try-catch search through dataarray , f...

ruby - Getting a string from a file -

ruby - Getting a string from a file - this question exact duplicate of: what each part of code mean? ruby [closed] i have been using: open("some.txt") { |f| f.each_line.find_all{ |line| /re/.match(line) } } what each component of piece of code mean? one way map results operation want them. if wanted first 3 words do: open("some.txt") { |f| f.each_line.find_all{ |line| /re/.match(line)}.map{|line| line.split[0...3].join(' ')} update: above assumes recipe first word on line. instead of doing that, can modify regex takes next word characters until space \w*\s , repeats e.g. 2 or 3 times {2, 3} : open("some.txt") { |f| f.each_line.find_all{ |line| puts /re(\w*\s){2,3}/.match(line) } } (play around regex needed on http://rubular.com/) ruby file screen-scraping

python - Programmatically generate requirements.txt file -

python - Programmatically generate requirements.txt file - i'm trying generate requirements.txt file programatically. way can diff against sec .txt file. far i've tried following, output requirements console (no .txt file generated). so far i've tried import pip pip.main(["freeze",">","requirements.txt"]) and subprocess import phone call call(["pip","freeze", ">","requirements.txt"]) if effort run same command manually in terminal though, file generated without issue. suggestions? ask pip straight provide list of distributions script myfreeze.py import pip open("requirements.txt", "w") f: dist in pip.get_installed_distributions(): req = dist.as_requirement() f.write(str(req) + "\n") then expected content in requirements.txt file. python subprocess pip requirements.txt

java - BitmapFont special characters not displayed in Android, in desktop version works though -

java - BitmapFont special characters not displayed in Android, in desktop version works though - i have libgdx project supports android , desktop version. fonts used freetypefontgenerator generate fonts. fonts worked fine, decided create bitmapfonts .fnt & .png file, have alternative back upwards html project (freetypefontgenerator not compatible html) the problem: if launch android project there no special chars (ü, ñ, etc.) displayed: --> in android text displayed this: ber --> in desktop text correctly displayed this: über the odd thing if run desktop version special characters work fine, although desktop version uses same code (since create font in core project): font = new bitmapfont(gdx.files.internal("fonts/gooddog40.fnt"), new textureregion(new texture("fonts/gooddog40.png"))); the .fnt & .png files looks me (and works fine in desktop!), since can see special chars contained there. create next using hiero font ge...

apache pig - how to set multiline string in my pig script? -

apache pig - how to set multiline string in my pig script? - how can set multiline string in pig latin? i'm trying set string containing json within it. this: myjson = ' { "name":"someone", "age":"20" } '; apache-pig

node.js - Use a node module from casperjs -

node.js - Use a node module from casperjs - is possible install node module, installed via npm, , require casperjs script? (i see lots of posts , tools running casper or phantom within node.js, not i'm trying do.) the casperjs docs seem possible, show hand-written toy modules don't anything. real-world module i'm trying install imap , @ point cannot module work, built-in ones net . simple example: class="lang-none prettyprint-override"> npm install imap echo "var test = require('imap');" > test.js casperjs test.js gives me: class="lang-none prettyprint-override"> caspererror: can't find module imap /usr/local/src/casperjs/bin/bootstrap.js:263 in patchedrequire test.js:1 (i can see imap module npm ls , , can utilize fine node.js script.) or alternatively built-in module: echo "var test = require('net');" > test.js casperjs test.js complains "can't find module n...