Posts

javascript - Strange behavior with "this" in Backbone.js when binding to "add"/"remove" in a collection -

i have following 2 views based on backbone.js pg.views.itemlist = backbone.view.extend({ tagname: "div", classname: "items", initialize: function() { _.bindall(this, 'addone', 'addselected') items.bind('add', this.addone); items.fetch(); }, // removed addone: function(item) { console.log($(this.el)); var view = new pg.views.item({model: item}); $(this.el).append(view.render().el); }, addselected: function(itemlist) { _.each(itemlist, this.addone); return this.el; }, // removed }); pg.views.section = backbone.view.extend({ tagname: "section", sectiontemplate: _.template($('#section-template').html()), events: { // removed }, initialize: function() { _.bindall(this, 'render', 'close', 'additemtosection', 'removeitemfromsection'); this.model.bind('change', this.render); this.model.view ...

app store - iPhone app: tap this button to update to the latest version -

i need url open end @ updates tab of appstore app. preferably @ update screen app. such thing possible? i know can open app itself, or reviews page app. when prompting users upgrade, "buy/free" button grayed out , says "installed". pretty unintuitive. have text instructs user do, far better go directly update page our app. can remotely update content in our old app, easy have button or link takes them update tab, assuming knew magic url was. there's no such url. can tell user check app store update , block them progressing further app until they've installed new version.

css - In a fixed width <select multiple> html box, is there a way to see text options that are to long? -

i have following code: <div id='div2' style='height: 430px; width: 350px; overflow:auto;'> <select multiple id="id" size="28" style="font-size: 12px; font-family: arial; width: 100%"> i cannot (due requirements) increase width of box, fixed @ 350px. of text strings in box larger 350px; right being truncated wondering if there way either make these options wrap onto second line, or add horizontal scrollbar box in order see full options. i'm developing ie7 , 8. you can use css word-wrap: break-word; click here cross browser functionality if it's text inside select list want wrapped it's not possible far know what use custom made selectbox example jquery selectmenu can customize fully

sqlite - Returning column indicating row existence in another table -

sqlite3 i have 2 tables, table1 , table2. both of these tables have column called name. i query table2 , return name column. in addition, return column containing values 1 or 0 depending on whether rows in table1 contain same value name. what efficient way this? i'm looking like: select name, if exists (select * table1 table1.name = table2.name) 1 else 0 table2 sorry, i'm not familiar sqlite, should work you. trick left outer join , comparison on joined table. select table2.name, case when table1.name not null 1 else 0 end table2 left outer join table1 on table1.name = table2.name i'm not sure case syntax best if more familiar conditionals in sqlite can clean part up.

java - How can one detect airplane mode on Android? -

i have code in application detects if wi-fi actively connected. code triggers runtimeexception if airplane mode enabled. display separate error message when in mode anyway. how can reliably detect if android device in airplane mode? /** * gets state of airplane mode. * * @param context * @return true if enabled. */ private static boolean isairplanemodeon(context context) { return settings.system.getint(context.getcontentresolver(), settings.system.airplane_mode_on, 0) != 0; }

regex - converting markdown lists to html lists in PHP -

i have been working on markdown converter today project of mine. got lost in , ran through code , noticed had huge amount converting lists. code below , have supplied code deals lists, suggestions on shortening code, cant see past have written , need fresh pair of eyes. <?php class markdown { private static $html = ''; private static $list_types = array( array( '>>', '<ul>', '</ul>' ), array( '>>>', '<ol>', '</ol>' ) ); private static $list_patterns = array( '/-[ ]+(.+)/' => ' >>\1', '/[0-9]{1}\. (.+)/' => ' >>>\1' ); public static function converttext($markdown = array()) { $markdown = explode("\n", strip_tags($markdown)); foreach ($markdown &$line) { $line = htmlentities($line, ent_quotes, 'utf-8'); foreach (self...

unit testing - Python unittest - opposite of assertRaises? -

i want write test establish exception not raised in given circumstance. it's straightforward test if exception is raised ... sinvalidpath=alwayssuppliesaninvalidpath() self.assertraises(pathisnotavalidone, myobject, sinvalidpath) ... how can opposite . something i'm after ... svalidpath=alwayssuppliesavalidpath() self.assertnotraises(pathisnotavalidone, myobject, svalidpath) try: myfunc() except exceptiontype: self.fail("myfunc() raised exceptiontype unexpectedly!")