Skip to content

Instantly share code, notes, and snippets.

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

Randall Hunt ranman

🏠
Working from home
View GitHub Profile
db.eval("
db.logs.find().forEach(function (d) {db.newlogs.insert(d)});
db.logs.renameCollection('bak', true);
db.newlogs.renameCollection('logs', true);
");
@ranman
ranman / .slate
Created November 28, 2012 06:43
test slate
# Configs
config windowHintsShowIcons true
config windowHintsIgnoreHiddenWindows false
config windowHintsSpread true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config secondsBetweenRepeat 0.1
config checkDefaultsOnLoad true
config focusCheckWidthMax 3000
@ranman
ranman / gist:4505580
Last active December 10, 2015 22:58
nonsense go commandline parsing
func main() {
var operand_p *float64 = new(float64)
flag.Float64Var(operand_p, "operand", math.NaN(), "sqrt operand")
flag.Parse()
if math.IsNaN(*operand_p) {
var err error
*operand_p, err = strconv.ParseFloat(flag.Arg(0), 64)
if err != nil {
log.Fatal(err)
}
@ranman
ranman / stupid_hack.py
Created April 9, 2013 17:34
le sigh python...
@app.route('/img/<ObjectId:gitshot_id>')
def render_image(gitshot_id):
img = mongo.db.gitshots.find_one_or_404(gitshot_id, {'img': True})['img']
def wsgi_app(environ, start_response):
start_response('200 OK', [('Content-type', 'image/jpeg')])
return img
return make_response(wsgi_app)
ranman ⮀ Downloads ⮀ cat test.cpp ⮂ 00:20:11 ⮂ 2013-04-18
#include <iostream>
#include <fstream>
#include <streambuf>
#include <string>
#include <cerrno>
using namespace std;
std::string get_file_contents(const char *filename)
{
{
"_id": ObjectId("5168940332e9bc755385e947"),
"author": "ranman",
"ts": ISODate("20130412T15:08:48-0400"),
"project": "corp",
"msg": "almost working version of employees",
"dstats": [
{
"+": "15",
"-": "3",
@ranman
ranman / post-commit.py
Created May 20, 2013 04:30
git post-commit hook
#!/usr/bin/env python2.7
# this is an awesome githook by randall at 4am.
# now to get back to real work
import os
import getpass
import subprocess
import time
import json
import requests
from datetime import datetime
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
@ranman
ranman / test.c
Created June 4, 2013 05:20
random bored gist
#include <stdio.h>
int main() {
#pragma pack(push, 1)
struct X {
char a;
double b;
char c;
int d;
double e;
float f;
@ranman
ranman / gist:5703810
Created June 4, 2013 05:36
hahahahahaha
perl -E '@P=split//,".URRUU\c8R";@d=split//,"\nbeewd nohtyP a si lladnaR";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print'