Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
chris-ramon / enumerators.rb
Created February 4, 2014 21:40
each, map, select - ruby
# each
h = [10, 20, 30]
hh = h.each {|e| e*2 } # does not create new object
# print h
# print h.object_id == hh.object_id # true
# map
x = [1, 2, 3]
z = x.map { |e| e*2 } # does create new object - non-destructive manner
# print x
@chris-ramon
chris-ramon / dart_notes.dart
Last active August 29, 2015 13:56
dart notes
/*
Dartium => Build of Chromium that has Dart VMtree-shaking process where unused code is not included in the final output of the program, that said u can import all kind libraries and not caring about unuse code.eg dart2js supports tree-shaking for Dart and Js outputs
final variables can not change
static class level fields
string interpolation: '$_firstName $_secondName'
=> expr; shorthand for {return expr;}
*/
PirateName.readyThePirates()
@chris-ramon
chris-ramon / heroku_dart.sh
Last active August 29, 2015 13:56
heroku + dart
Procfile
web: ./dart-sdk/bin/dart bin/basic_http_server.dart
heroku create myfirstdartappforheroku -s cedar
heroku labs:enable user-env-compile
heroku config:set DART_SDK_URL=https://github.com/selkhateeb/heroku-vagrant-dart-build/releases/download/latest/dart-sdk.tar
heroku config:add BUILDPACK_URL=https://github.com/igrigorik/heroku-buildpack-dart.git
git push heroku master
heroku ps:scale web=1
@chris-ramon
chris-ramon / postgresql
Last active August 29, 2015 13:57
postgresql notes
# describe table
SELECT attname, attnotnull FROM pg_attribute,pg_class WHERE attrelid=pg_class.oid AND relname='uploads' AND attstattarget <>0;
# start process
postgres -D /usr/local/var/postgres
# list roles
\du
# list tables
@chris-ramon
chris-ramon / closures.rb
Created March 4, 2014 23:21
ruby procedures closures
# blocks
# most basic closure
# can not be saved
# wrong_proc = { puts 'hi' }
correct_proc = Proc.new { puts 'procedure' }
3.times { puts 'block' } # works
# 3.times proc # wont work
3.times(&correct_proc)
@chris-ramon
chris-ramon / protractor_config.txt
Last active August 29, 2015 13:57
protractor config
# sleep
protractor.getInstance().sleep(2 * 1000);
browser.pause();
// java -Dwebdriver.chrome.driver=/Users/chris/projects/xims-platform/xims-app/node_modules/protractor/selenium/chromedriver -jar /Users/chris/projects/xims-platform/xims-app/node_modules/protractor/selenium/selenium-server-standalone-2.39.0.jar
//
//
//
@chris-ramon
chris-ramon / angularjs_testing.js
Created March 8, 2014 16:55
angularjs testing
// mock service, override methods
EmployeeService = $injector.get('EmployeeService');
spyOn(EmployeeService, 'getAllUrl')
.andReturn('http://0.0.0.0:3000/1/employees');
// mock service, replace
mockEmployeeService = {
getAll: function() {
return employees;
}
@chris-ramon
chris-ramon / drone.rb
Last active August 29, 2015 13:57
:D dsl drone
def drone
puts 'start controlling drone'
yield
end
def fly
puts 'flying'
yield if block_given?
end
def move direction
puts "moving #{direction.to_s}"
https://github.com/mhoofman/wordpress-heroku
https://api.wordpress.org/secret-key/1.1/salt/
# htdocs on mac
# defined within
/etc/apache2/httpd.conf
<IfDefine WEBSHARING_ON>
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.