Skip to content

Instantly share code, notes, and snippets.

View csanz's full-sized avatar
🎯
Focusing

Christian Sanz csanz

🎯
Focusing
View GitHub Profile
Christian-Sanzs-MacBook-Air:www csanz$ git push heroku production:master
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 422 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)
-----> Heroku receiving push
-----> Node.js app detected
-----> Vendoring node 0.4.7
@csanz
csanz / gitprotips.md
Created September 8, 2011 02:35
Git Pro Tips

Rebasing

The idea here is that you want to keep your branch super fresh with the latest updates... (some use master, others create a new branch called dev or staging)

  git checkout master && git pull origin master
  git checkout branch-name
  git rebase master
  git push origin :branch-name
  git push origin branch-name
@csanz
csanz / geekli.st.md
Created September 1, 2011 23:53
Commit Stats

Geekli.st repo summary

  project: www
     commits: 449
     files  : 771
     authors: 
       234	Christian Sanz          52.1%
        74	Tim Smart               16.5%
        57	arlolra                 12.7%

30 rekatz 6.7%

@csanz
csanz / encrypt_decrypt.js
Created August 30, 2011 16:06
Simple String Encryption & Decryption with Node.js
function encrypt(text){
var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq')
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
function decrypt(text){
var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq')
var dec = decipher.update(text,'hex','utf8')
@csanz
csanz / movingredistolinode.md
Created August 29, 2011 07:40
Moving your redis instance to linode

Move your redis instance to Linode!

create linode server instance

local:

<shell>$ssh root@(IP ADDRESS)

remote:

telnet filefish.redistogo.com 9576
Trying 75.101.153.205...
telnet: connect to address 75.101.153.205: Connection refused
telnet: Unable to connect to remote host
@csanz
csanz / lalalala.js
Created August 8, 2011 19:37
Geeklist Home Screen Randomizer
db.users.find().forEach(function(user) {
if(user.company){
db.users.update({_id: user._id}, { $set: { random: Math.random(), is_featured: true }});
}else{
db.users.update({_id: user._id}, { $set: { is_featured: false }});
}
});
db.users.find({is_featured: true},{screen_name:1}).limit(10).sort({random: 1})
@csanz
csanz / randomizer.js
Created August 8, 2011 19:33
Mongodb Randomizer Script
db.users.find().forEach(function(user) {
db.users.update({_id: user._id}, { $set: { random: Math.random() }});
});
// Runs in less than 1 sec for 2k records
db.users.ensureIndex({random:1});
/*
Non-authoritative answer:
fastdl.mongodb.org canonical name = d3mw3wlkjdkqc9.cloudfront.net.
Name: d3mw3wlkjdkqc9.cloudfront.net
Address: 216.137.37.45
Name: d3mw3wlkjdkqc9.cloudfront.net
Address: 216.137.37.130
Name: d3mw3wlkjdkqc9.cloudfront.net
Address: 216.137.37.188
Name: d3mw3wlkjdkqc9.cloudfront.net
Address: 216.137.37.66
@csanz
csanz / using_repl.md
Created August 1, 2011 09:07
Debugging your Mongoose Models Using Repl

Debugging your Mongoose Models Using Repl

This is a faster way to test your mongoose models. The example below was based on the expressjs-blog example here

Example

$node
> var mongoose = require('mongoose')
> var db = mongoose.connect('mongodb://localhost/blogsample')

> db.model('BlogPost', require('./app/models/blogpost'))