Skip to content

Instantly share code, notes, and snippets.

View lordkebab's full-sized avatar

Lord Kebab lordkebab

  • USA
View GitHub Profile
@lordkebab
lordkebab / afinn.py
Last active August 29, 2015 14:08 — forked from fnielsen/afinn.py
#!/usr/bin/python
#
# (originally entered at https://gist.github.com/1035399)
#
# License: GPLv3
#
# To download the AFINN word list do:
# wget http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/6010/zip/imm6010.zip
# unzip imm6010.zip
#
@lordkebab
lordkebab / wvdial.conf
Created November 4, 2014 20:19
wvdial configuration
[Dialer Defaults]
Init1 = ATZ
Init2 = AT Q0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = USB Modem
Stupid Mode = 1
New PPPD = yes
Dial Command = ATDT
Carrier Check = 0
ISDN = 0
@lordkebab
lordkebab / decorators.py
Last active August 29, 2015 14:19
Learning about python decorators
''' Learning about python decorators '''
def is_logged_in(func):
def wrapper(logged_in):
print "Checking logged in status..."
if logged_in:
print "Ok!"
func(logged_in)
else:
print "Not logged in"
@lordkebab
lordkebab / asyncio.py
Created June 26, 2015 14:41
Playing with asyncio
''' Experimenting with asyncio '''
import asyncio, requests, os, time
class Weather(object):
api_key = ''
places = {
'CA' : ['San_Francisco'],
@lordkebab
lordkebab / pipeline.py
Created June 30, 2015 18:39
Python processing pipeline
''' Basic processing pipeline. Watch for new files and add the numbers inside '''
import os, time
class Pipeline(object):
# list of files we've processed
processed = []
# running total
@lordkebab
lordkebab / coroutines.py
Created July 1, 2015 16:18
Python interpreter session playing around with coroutines
>>> def gen():
... while True:
... x = (yield)
... print(x)
...
>>> a = gen()
>>> a.send('hi')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't send non-None value to a just-started generator
# sum the sizes of your EBS volumes
# requires jq (sudo yum install jq)
aws ec2 describe-volumes | jq .Volumes[].Size | awk '{sum+=$1} END {print sum}'
@lordkebab
lordkebab / fib.py
Created March 17, 2015 12:36
Ultra fast python Fibonacci generator
from math import sqrt, pow
def binet(x):
return int(1/sqrt(5)*(pow(((1+sqrt(5))/2),x)-pow(((1-sqrt(5))/2),x)))
def fib(x):
return [binet(x) for x in range(1,x)]
print fib(500)
@lordkebab
lordkebab / unbox.sh
Last active October 17, 2015 01:20
Install software that I need on a new Linux box
#!/bin/bash
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# unbox.sh
#
# Bootstrap a new Linux machine, fresh out of the box.
#
# Usage:
# Run as your user. You will be prompted for your password so it can sudo,
# and then the script will continue as normal.
#!/bin/bash
#
# Date: July 18, 2016
# Auth: Matt Selph <matt.selph@ngc.com>
#
# Log the result of a tnsping operation on all Oracle DB's
# so Splunk can ingest it. Uses entries from the tnsnames.ora file.
# You can put either the hostname or IP of a database in tnsnames.ora,
# just make sure to also add an entry to /etc/hosts.