Skip to content

Instantly share code, notes, and snippets.

View adamrights's full-sized avatar

Adam Bedell adamrights

View GitHub Profile
#!/bin/bash -ex
# Paste this into ssh
# curl -sL https://gist.github.com/gists/2913223/download | tar -xzO | /bin/bash -ex
# When forking, you can get the URL from the download button.
pushd $HOME
aptget='sudo apt-get'
chsh='sudo chsh'
@adamrights
adamrights / snp
Created April 12, 2013 12:18 — forked from erikw/snp
#!/usr/bin/env bash
# Runs a command wrapped with btrfs pre-post snapshots.
log_path="/var/local/log/snp"
date=$(date "+%Y-%m-%d-%H%M%S")
log_file="${log_path}/snp_${date}.log"
# Log stdout and stderr. Reference: http://stackoverflow.com/questions/3173131/redirect-copy-of-stdout-to-log-file-from-within-bash-script-itself
exec > >(tee -a "$log_file")
exec 2> >(tee -a "$log_file" >&2)
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
#!/usr/bin/php
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
/*
* Using of script in command line:
* ./csv-to-json.php csv.file.name.or.url > json.file.name
@adamrights
adamrights / jail.pl
Created September 12, 2013 16:07 — forked from wilbowma/jail.pl
#a/usr/bin/perl
# This script was hastily cobbled together for my own use. It can
# probably break your system. Use at your own risk.
$JAIL = "/srv/http";
$USER = "http";
$GROUP = "http";
$WWW_DIR = "www";
sub run{
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@adamrights
adamrights / .env
Created November 5, 2013 10:35 — forked from everyplace/.env
COOKIE_SECRET="It's a secret to everybody"
FLICKR='{"api_key":"XXXXXX", "api_secret":"XXXXXX", "callback_url":"https://XXXXXX/auth/flickr/callback"}'
TWITTER='{"consumer_key":"XXXXXX", "consumer_secret":"XXXXXX","request_token_url":"https://api.twitter.com/oauth/request_token","authorize_url":"https://api.twitter.com/oauth/authorize","access_token_url":"https://api.twitter.com/oauth/access_token","callback_url":"http://XXXXXX/auth/twitter/callback"}'
GOOGLE='{"web":{"auth_uri":"https://accounts.google.com/o/oauth2/auth","client_secret":"XXXXXX","token_uri":"https://accounts.google.com/o/oauth2/token","client_email":"XXXXXX","redirect_uris":["https://XXXXXX/auth/google/callback"],"client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/XXXXXX","client_id":"XXXXXX","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","javascript_origins":["XXXXXX"]}}'
GOOGLE_SCOPE='["https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/userinfo.email"]'
GOOGLE
var express = require('express'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
connect = require('connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
fs = require 'fs'
express = require 'express.io'
path = require 'path'
#If we didn't get to server.js from bootstrap.js
if !GLOBAL.asset_hash?
GLOBAL.asset_hash = 'main'
#Read dotCloud ENV file if exists
try
// add a new object
var type = 'note';
var attributes = {color: 'red'};
store.add(type, attributes)
.done(function (newObject) {});
.fail(function (error) {});
// update an existing object
var type = 'note';
var id = 'abc4567';