Skip to content

Instantly share code, notes, and snippets.

View jhargis's full-sized avatar

Jay Hargis jhargis

  • Heroku
  • Portland, OR
View GitHub Profile
@jhargis
jhargis / install.sh
Created June 22, 2012 01:40 — forked from crofty/install.sh
Redis install for ubuntu 8.04 without upstart
# Redis install instructions for systems without upstart
mkdir ~/redis
cd ~/redis
wget --no-check-certificate http://github.com/antirez/redis/tarball/v2.0.0-rc4 -O redis_v2.0.0-rc4.tar.gz && tar --strip-components 1 -xzvf redis_v2.0.0-rc4.tar.gz
make
sudo mv redis-server /usr/local/bin/
sudo mv redis-cli /usr/local/bin/
sudo mv redis-benchmark /usr/local/bin/
sudo mv redis-check-dump /usr/local/bin/
sudo mkdir /var/lib/redis
@jhargis
jhargis / node-and-npm-in-30-seconds.sh
Created July 18, 2012 18:45 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@jhargis
jhargis / encryptpw.pl
Created August 29, 2013 04:33
generate an htpasswd with perl script
#!/usr/bin/env perl
if ($#ARGV < 1) {
die("Usage:\tUsername Password\n")
}
my $username = shift;
my $newpass = shift;
my $new_entry;
my @entry = split(':', $_);
@jhargis
jhargis / pull-toggl-timesheet.py
Last active March 2, 2020 20:43
Python based timesheet report generation utility for toggl.com api This generates CSV and HTML files from an api call filtered on client and date range.
#!/usr/bin/env python
import os
import csv
import sys
import datetime
import string
import requests
# replace these: API_KEY, CLIENTNAME1, CLIENTNAME2 , CLIENT_ID1, CLIENT_ID2 , WORKSPACE_ID
@jhargis
jhargis / mclarens.js
Created February 22, 2014 17:43 — forked from nikhilm/mclarens.js
/*
* Mclarens Bar: Redis based Instant Messaging
* Nikhil Marathe - 22/04/2010
* A simple example of an IM client implemented using
* Redis PUB/SUB commands so that all the communication
* is offloaded to Redis, and the node.js code only
* handles command interpretation,presentation and subscribing.
*
* Requires redis-node-client and a recent version of Redis
@jhargis
jhargis / guncorn-example
Created May 1, 2014 17:56
Debian init script for virtualenv'd gunicorn_django
#! /bin/sh
### BEGIN INIT INFO
# Provides: gunicorn-initscript
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $nginx
# Default-Start: 30 2 3 4 5
# Default-Stop: 70 0 1 6
# Short-Description: virtualenv + gunicorn + nginx debian init script
# Description: virtualenv + gunicorn + nginx debian init script
@jhargis
jhargis / __init__.py
Last active November 18, 2018 22:00
using jinja2 with cherrypy - example
# -*- coding: utf-8 -*-
# http://docs.cherrypy.org/en/latest/advanced.html?highlight=jinja2#html-templating-support
import os.path
import cherrypy
class Root(object):
@cherrypy.expose
def index(self):
@jhargis
jhargis / bottle_flash2.py
Last active June 20, 2021 21:09
bottle-flash2 - Fixed up abandoned bottle-flash[https://pypi.python.org/pypi/bottle-flash/]. Made api ver 2 ready. Plugin enables flash messages in bottle similar to django and flask.
from bottle import request, response, PluginError
class FlashMsgPlugin(object):
"""Usage:
from bottle import Bottle
from bottle_flash2 import FlashMsgPlugin
app = Bottle()
COOKIE_SECRET = 'your_secret_key'
app.install(FlashPlugin(secret=COOKIE_SECRET))
@jhargis
jhargis / keybase.md
Created November 13, 2014 19:43
keybase.md

Keybase proof

I hereby claim:

  • I am jhargis on github.
  • I am jhargis (https://keybase.io/jhargis) on keybase.
  • I have a public key whose fingerprint is 0FCF 328B 353D 9282 C929 80EA 8620 C622 7D44 B2EA

To claim this, I am signing this object:

@jhargis
jhargis / UPnP-client.py
Created November 20, 2014 03:57
UPnp or NAT-PMP client
# NAT Traversal via UPnP Port Mapping
# Written by Nikos Fotoulis <nikofot at gmx.com>
# This code is public domain.
#
# Tested on Thomsom TG858v7 modem router.
# UPnP is hairy. May not work with other routers
# Feedback is welcome.
import re, thread, socket, traceback as tb, random
from time import sleep