This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' Experimenting with asyncio ''' | |
import asyncio, requests, os, time | |
class Weather(object): | |
api_key = '' | |
places = { | |
'CA' : ['San_Francisco'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
OlderNewer