Splitting a string in Google Spreadsheet

Here is how to split a string into tokens, then grab each token for each column in Google Spreadsheet. So we start with the string. Then we do =index(split(A2, " “), 1, 1). Basically, split will give us an array (or range). Then we select the first row (there is just one resulting row), and we select the first column (there are 3 resulting columns in our example). ...

August 21, 2014 · 1 min · birdchan

Get url parameters with javascript

There are times you will need to grab url parameters, then update some of your form components accordingly. In my case, it was a search form that passes search terms using GET. I largely got the javascript function from here, but I added a few lines to decode/unescape values. Here it is. function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == sParam) { var val = sParameterName[1]; //console.log("before: " + val) val = decodeURIComponent(val); val = val.replace(/+/g, " "); //console.log("after: " + val) return val; } } }; $(function() { // pre-set our search control components based on the URL params $("#search_text").val(getUrlParameter("search_text")); // more fields... });

August 14, 2014 · 1 min · birdchan

Install MySQLdb on osx

Here is the error message I got. ImportError: No module named MySQLdb Below is how you install such module for your python script. brew install mysql brew install python sudo easy_install pip sudo pip install MySQL-python Depending on your file permissions at various directories, you can determine the use of sudo.

August 8, 2014 · 1 min · birdchan

PHP functions in Python?

Coming from the PHP background, very often I wonder if there are equivalent function calls in Python. Say for example, how do you do file_get_contents in Python? I find myself doing a lot of these searches lately. Here is this website php2python that tells you just that, with code examples.

July 20, 2014 · 1 min · birdchan

deobfuscate js

Just found this nice tool online to deobfuscate js code. It works kinda like PrettyPrint. Give it a try! =) http://jsnice.org/ And here is a command line version of it: https://github.com/brettlangdon/jsnice

June 3, 2014 · 1 min · birdchan

Commit all deleted files in git

I had like 100+ files deleted from upgrading to a newer version of wordpress. Below is how to batch commit those deleted files in git. git add -u That will stage all those deleted files (that have been tracked before). Ref: http://stackoverflow.com/questions/1402776/how-do-i-commit-all-deleted-files-in-git

May 4, 2014 · 1 min · birdchan

vis.js

Here is a fun graphing library to play with! =) Vis.js is a dynamic, browser based visualization library. The library is designed to be easy to use, to handle large amounts of dynamic data, and to enable manipulation of and interaction with the data. The library consists of the components DataSet, Timeline, and Graph. #mygraph { width: 400px; height: 400px; border: 1px solid lightgray; } /js/vis.js // create an array with nodes var nodes = [ {id: 1, label: ‘Node 1’}, {id: 2, label: ‘Node 2’}, {id: 3, label: ‘Node 3’}, {id: 4, label: ‘Node 4’}, {id: 5, label: ‘Node 5’} ]; // create an array with edges var edges = [ {from: 1, to: 2}, {from: 1, to: 3}, {from: 2, to: 4}, {from: 2, to: 5} ]; // create a graph var container = document.getElementById(‘mygraph’); var data = { nodes: nodes, edges: edges }; var options = {}; var graph = new vis.Graph(container, data, options); ...

May 4, 2014 · 2 min · birdchan

Gradle: A problem occurred configuring project

Weird error message: Gradle: A problem occurred configuring project ':App'. > Failed to notify project evaluation listener. > Could not resolve all dependencies for configuration ':App:_DefaultFlavorDebugCompile'. > Could not find any version that matches com.android.support:appcompat-v7:+. Required by: MyApplication:App:unspecified If this happens, just go to Tools -> Android -> Android SDK Manager, then check “Android Support Repository” and “Android Support Library” under “Extra” and install them. That should take care of the error. ...

November 17, 2013 · 1 min · birdchan

A list of programming screencast series

Here is a list I copied from http://devblog.avdi.org/2013/06/21/a-list-of-programming-screencast-series/. Railscasts, Udemy (text) - Ruby on Rails Destroy all Software - Ruby, Python, Unix, software design. Code School - Ruby, Rails, iOS, JavaScript, HTML/CSS, etc. Clean Coders - software design and discipline PeepCode - Long-form videos on many different languages and technologies NSScreencast - weekly bite-sized screencasts on iOS development. Minimalist Programming - Haskell Neckbeard Republic - Python Backbone Rails - Rails and Backbone.js Build Podcast - a different tool/tech every episode. Vimcasts Emacs Rocks Hack Emacs MetaCasts - EmberJS, Ruby, RubyMotion, JavaScript, etc. Ember 101 - EmberJS WatchMeCode - JavaScript Must Hack - Ruby, UNIX Programming Tutorials from William Byrd - Scheme, functional programming concepts Egghead - AngularJS Tekpub - .NET, Ruby, JavaScript, and more Frontend Masters - HTML5, CSS3, JavaScript Treehouse - Web, Adnroid, iOS, Ruby on Rails, PHP EventedMind - NodeJS, Meteor dot enter - d3 Let’s Code - Test-Driven JavaScript Pluralsight - “Hardcore developer training” Motioncasts - RubyMotion Learning iOS Development with Azam Sharp RubyTapas – Ruby, TDD, and OOP EmberCasts – EmberJS

July 21, 2013 · 1 min · birdchan

Reachability.m ARC errors?

If you got some weird errors from Reachability.m (my xcode is in version 4.6.3), something like the following: Then just update your reachability files with the new ones. Also, Select your project -> target -> Build Phases -> Compile Sources -> Double click the Reachability.m -> add the flag -fno-objc-arc. Ref: http://stackoverflow.com/questions/7877867/use-reachability-m-in-xcode-4-2

June 22, 2013 · 1 min · birdchan