Skip to content

Instantly share code, notes, and snippets.

View thegoleffect's full-sized avatar

Van Nguyen thegoleffect

View GitHub Profile
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'
#!/usr/bin/env node
var sys = require("sys"),
fs = require("fs");
var indented = "";
(function (json) {
indented = /(^[\t ]*)/.exec(json)[0] || "";
try {
#!/usr/bin/python
import sys
code = """#!/usr/bin/python
import sys
code = {0}{1}{0}
def initial_solution():
@thegoleffect
thegoleffect / rvm-version.rb
Created April 20, 2011 19:40 — forked from thbar/rvm-version.rb
install rvm specific version
curl -s https://rvm.beginrescueend.com/install/rvm -o rvm-installer
chmod +x rvm-installer
./rvm-installer 1.6.3
@thegoleffect
thegoleffect / index.html
Created August 31, 2011 20:39
dnode auth working example
<html>
<head>
<script src="/dnode.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
DNode({
session : function (session) {
$('#auth :visible').slideUp();
$('#user').text(session.user);
@thegoleffect
thegoleffect / redis.markdown
Created September 3, 2011 00:33 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

@thegoleffect
thegoleffect / mongoosejs.on.connect.js
Created December 29, 2011 23:15
[Reference][Snippet][MongooseJS]: Listen and bind on "open" event aka "on connect"
// This snippet is useful for debugging connection parameters in the connect_string, for checking if your remote mongodb server is up, etc.
var mongoose = require("mongoose");
mongoose.connect(connect_string);
mongoose.connection.on("open", function(){
console.log("connection established");
})
@thegoleffect
thegoleffect / mongoosejs.cursors.tailable.js
Created December 29, 2011 23:18
[Reference][Snippet][MongooseJS]: Tailable cursor example
// This example shows how to use tailable cursors in MongoDB using mongoosejs
// IMPORTANT: The collection must be created as "capped" or this will raise err.
// At time of writing, there is no built-in way to create capped collection using MongooseJS.
var mongoose = require("mongoose");
mongoose.connect(connect_string);
Model = mongoose.model(model_name);
Model.connection.find(query, {tailable:true}, function(err, cursor){
if (err){
@thegoleffect
thegoleffect / nodejs.repl.js
Created December 29, 2011 23:32
[Reference][Snippet][NodeJS]: Remote-accessible REPL server example
var net = require("net");
var repl = require("repl");
net.createServer(function(socket){
var replserver = repl.start("prompt > ", socket);
// You must explicitly give the repl client access to variables via replserver.context variable.
// The following line is intended for educational purposes only. DO NOT USE in practice.
replserver.context = exports; // DANGER: This gives repl client access to ALL global variables of this program.
replserver.context.myvar = "stuff";