This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib(n): | |
if n == 0: | |
return [0] | |
elif (n == 1): | |
return [0, 1] | |
else: | |
result = [0, 1] | |
for i in range(2, n + 1): | |
result.append(result[i-1] + result[i-2]) | |
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// formats | |
// https://github.com/mbostock/d3/wiki/Formatting#d3_format | |
// in order to get random cool colors | |
d3.scale.category20().range() | |
// forze axis range | |
.forceY([0,100]) | |
// make labels accomodate if there is no space for all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// communicate legacy code with angular | |
var scope = $(self.selector).find('option').scope().$$childHead; | |
scope.$apply(function() { scope.selected = null; }); | |
// manually compilation | |
var html = $templateCache.get('templateId.tpl'); | |
var template = angular.element(html); | |
var linkFn = $compile(template); | |
var htmlCompiled = linkFn(scope); | |
return htmlCompiled; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find all files that has 'type' within its name | |
Dir.entries('.').each {|f| puts f if f =~ /type/ } | |
require 'find' | |
iml_files = [] | |
Find.find('.') {|path| iml_files << path if path =~ /.*\.iml$/ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# error when trying to install cryptography package on mac | |
ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" pip install cryptography |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# auth scenarios | |
https://developers.google.com/accounts/docs/OAuth2?csw=1#scenarios | |
# cloud storage | |
# gsutil | |
gsutil config | |
gsutil mb gs://mybucket | |
gsutil cp sf.jpg gs://mybucket | |
gsutil cp gs://mybucket/sf.jpg /Users/chris/Desktop/mybucket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list of media types | |
http://www.iana.org/assignments/media-types/media-types.xhtml | |
# detect media type via javascript | |
http://stackoverflow.com/questions/4581308/jquery-or-javascript-get-mime-type-from-url | |
# via bash / replace i for I dependening on os | |
file -i FILE_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create app | |
heroku apps:create ng-easyfb | |
# set env vars | |
heroku config:set NODE_ENV=production | |
# push | |
git push heroku master | |
# restart app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list of apps | |
https://developers.facebook.com/apps | |
# explorer | |
https://developers.facebook.com/tools/explorer/?method=GET&path=me&version=v2.0 | |
# api reference user | |
https://developers.facebook.com/docs/graph-api/reference/v2.0/user | |
# find places near lon/lat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mark view as source root | |
# mark app as source root |