Skip to content

Instantly share code, notes, and snippets.

View kylegibson's full-sized avatar

Kyle Gibson kylegibson

View GitHub Profile
@kylegibson
kylegibson / dynupdate.sh
Created October 9, 2011 18:26
Simple bash script to update a dyndns host entry
#!/bin/bash
HOST=foo.example.com
USER=
PASS=
IPADDR=$(wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
RESULT=$(wget -q -O- "https://$USER:$PASS@members.dyndns.org/nic/update?hostname=$HOST&myip=$IPADDR&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG")
from decorator import decorator
from line_profiler import LineProfiler
@decorator
def profile_each_line(func, *args, **kwargs):
profiler = LineProfiler()
profiled_func = profiler(func)
try:
profiled_func(*args, **kwargs)
finally:
@kylegibson
kylegibson / queue.py
Created July 5, 2020 22:11
Distributed Memcache Linked List (Queue)
from contextlib import contextmanager
# cache = ...
class DistributedLinkedList(object):
def __init__(self, cache_key_name, cache_timeout=86400):
self.cache_key_name = cache_key_name
self.cache_timeout = cache_timeout
self.head_key_ref = f'distributed-list-{cache_key_name}-head'
self.tail_key_ref = f'distributed-list-{cache_key_name}-tail'
from bs4 import BeautifulSoup
def max_tree_height(html):
'''
Calculate the number of HTML tag levels, iteratively
>>> max_tree_height('')
0
>>> max_tree_height('<div></div>')
@kylegibson
kylegibson / capitalone.user.js
Last active October 13, 2016 04:20
Parse transactions in capitalone and print into console
// ==UserScript==
// @name capitalone
// @namespace kyle
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @include https://servicing.capitalone.com/*
// @grant none
// ==/UserScript==
//
$(function() {
from urllib2 import quote, unquote
import sqlite3
def fix_the_things(name):
name = name[6:]
name = quote(unquote(name), '-_.!()')
name = name.replace('.rar%2F', '.rar/')
bits = name.split('%')
res = [bits[0]]
#!/usr/bin/env python
"""
ignore_moves.py v0.2
Filter relocated lines from a unified diff format stream.
Offered under the terms of the MIT License at github.com
Taken from http://stackoverflow.com/questions/1380333/
"""
import sys
from optparse import OptionParser
@kylegibson
kylegibson / setup_slave.sh
Last active October 11, 2015 12:28 — forked from jlward/setup_slave.sh
Configure Jenkin slave
#!/bin/sh
main() {
configure_ssh_known_hosts
configure_mysql_ram_disk
configure_idle_tracking
}
configure_ssh_known_hosts() {
echo configuring ssh known hosts
@kylegibson
kylegibson / gist:3437984
Created August 23, 2012 16:00
facebook-like selection style
%form.form-horizontal{method:'post'}
%fieldset
%legend Select Users to Assign
.control-group
%label.control-label
These users or groups
.controls
.tokenizer
.tokenarea
%span.label.label-info.removeable.token{title:'Yippie'}
import pyev
class FiveSecondTimer(object):
def __init__(self, data):
self.data = data
def __call__(self, watch, revents):
print 'foo', data
loop = pyev.default_loop()