Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
chris-ramon / fibonacci.py
Created March 31, 2014 14:08
simple solution
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
@chris-ramon
chris-ramon / d3.js
Last active August 29, 2015 13:58
d3 notes
// 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
@chris-ramon
chris-ramon / dir_ng.js
Last active August 29, 2015 13:59
directive notes
// 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;
@chris-ramon
chris-ramon / ruby_notes.rb
Last active August 29, 2015 13:59
ruby quick notes
# 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$/ }
@chris-ramon
chris-ramon / py.sh
Created May 13, 2014 01:06
python packages
# error when trying to install cryptography package on mac
ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" pip install cryptography
@chris-ramon
chris-ramon / notes.txt
Last active August 29, 2015 14:01
google apis
# 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
@chris-ramon
chris-ramon / mime.txt
Created May 15, 2014 18:26
media types notes
# 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
@chris-ramon
chris-ramon / heroku.txt
Last active August 29, 2015 14:01
heroku notes
# create app
heroku apps:create ng-easyfb
# set env vars
heroku config:set NODE_ENV=production
# push
git push heroku master
# restart app
@chris-ramon
chris-ramon / fb.txt
Last active August 29, 2015 14:01
facebook api notes
# 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
@chris-ramon
chris-ramon / angularjs.txt
Created May 16, 2014 21:58
angularjs generator
# mark view as source root
# mark app as source root