Skip to content

Instantly share code, notes, and snippets.

View trivektor's full-sized avatar
🏠
Working from home

Tri Vuong trivektor

🏠
Working from home
View GitHub Profile
@trivektor
trivektor / gist:1325451
Created October 30, 2011 03:56
Create app using Cedar stack on Heroku
Precompile assets for Heroku
RAILS_ENV=production bundle exec rake assets:precompile
//Copied from http://jeremyjbarth.blogspot.com/2011/10/rails-31-asset-pipeline-on-heroku.html
heroku create app_name --addons custom_domains -r git_remote -s cedar
heroku run rake db:migrate --app app_name
heroku domains:add www.your_domain.com --app app_name
change dns entry to point to app_name.heroku.com
@trivektor
trivektor / gist:1355915
Created November 10, 2011 19:37
Exercise for JS Master Class
function isCreditCard( CC ) {
if (CC.length > 19)
return (false);
var sum = 0, mul = 1, l = CC.length, digit;
for (var i = l; i > 0; i--) {
digit = CC.substring(i-1, i);
tproduct = parseInt(digit)*mul;
sum += tproduct >= 10 ? (tproduct % 10) + 1 : tproduct;
@trivektor
trivektor / gist:1356092
Created November 10, 2011 20:24
Exercise for JS Master Class (Closure)
function countdown(){
var index = 10;
function log() {
console.log(index);
}
return function iterate(){
log();
if(index>1) setTimeout(iterate, 1000);
@trivektor
trivektor / gist:1358735
Created November 11, 2011 18:13
Exercise for JS Master Class (OOP)
function Person(name) {
this.name = name;
}
Person.prototype.getName = function() {
return this.name;
}
var thomas = new Person('Thomas');
var amy = new Person('Amy');
@trivektor
trivektor / gist:1358737
Created November 11, 2011 18:13
Javascript prototype notes
Prototype is intimately tied to constructors so calls to prototype only works on a constructor function (for example Fruit)
Prototype is more memory efficient (50 copies of the eat function for 50 fruit instances) but could be harder to read and maintain
Prototype works in a delegation fashion
@trivektor
trivektor / gist:1358954
Created November 11, 2011 19:26
Exercise for JS Master Class (DOM Events)
<div id="the_div">
<ul id="the_list">
<li id="the_item">Click me!</li>
</ul>
</div>
<p id="log"></p>
<script type="text/javascript" charset="utf-8">
function log(string){
@trivektor
trivektor / gist:1362285
Created November 13, 2011 16:20
Mongo DB post-install instructions
If this is your first install, automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mongodb/1.8.2-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
cp /usr/local/Cellar/mongodb/1.8.2-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
@trivektor
trivektor / deploy.rb
Created November 23, 2011 19:20 — forked from netzpirat/deploy.rb
Capistrano recipe to sync rails database and files within a multi stage environment
set :sync_directories, ["public/assets", "public/galleries"]
set :sync_backups, 3
@trivektor
trivektor / gist:1397074
Created November 27, 2011 06:13
Convert avi to mp4 for iWhatever
ffmpeg -i Roman_Holiday.avi -f mp4 -vcodec libxvid -maxrate 1000 -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac -strict experimental -mbd 2 -s 320x240 -ab 128 -b 400 Roman_Holiday.mp4
@trivektor
trivektor / gist:1429298
Created December 4, 2011 05:33
Compile asset pipeline Rails 3.1
RAILS_ENV=production bundle exec rake assets:precompile