Skip to content

Instantly share code, notes, and snippets.

'''
Easy Mac
Copyright (2015) Sean Beck
Licensed under Creative Commons Attribution-ShareAlike 4.0 International
See: https://creativecommons.org/licenses/by-sa/4.0/
Easily change your MAC address on Linux using `ifconfig`
'''
#!/usr/bin/python2.7
@touilleMan
touilleMan / SimpleHTTPServerWithUpload.py
Last active April 10, 2024 12:41 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload - Python3 version
#!/usr/bin/env python3
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
see: https://gist.github.com/UniIsland/3346170
"""
@Lucretiel
Lucretiel / switch.py
Last active April 15, 2022 15:40
A switch statement in python
from contextlib import contextmanager
class SwitchError(RuntimeError):
pass
@contextmanager
def switch(switch_value, *, ignore_nomatch=True):
blocks = {}
blocks.default = None
@vlasovskikh
vlasovskikh / tweetread.py
Created June 1, 2014 23:26
Actor-based CLI Twitter client example for using asyncio
# Copyright (c) 2014 Andrey Vlasovskikh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@hellosteadman
hellosteadman / twopy.py
Created March 4, 2014 09:59
Add your Twitter friends' RSS feeds to a single OPML file
"""
This script requires the following Packages
1: Twitter: https://pypi.python.org/pypi/twitter
2: PyQuery: https://pypi.python.org/pypi/pyquery
3: Jinja2: https://pypi.python.org/pypi/Jinja2
It's fairly primitive but works. It uses a Jinja2 template to create an OPML
file from the RSS feeds of the websites run by the people you follow on
Twitter.
@jiko
jiko / rapgenius_scraper.py
Created November 4, 2013 17:06
Scrapes Rap Genius for song lyrics. Leaves some mess to clean up in the output.
import requests # for grabbing pages
from bs4 import BeautifulSoup # for parsing pages
import codecs
# grab page
root = "http://rapgenius.com"
path = "/artists/2-chainz"
page = requests.get(root+path)
# load downloaded page into BS
@tempox
tempox / Game.py
Created June 25, 2013 02:58
Just run the program either in python or the command line. Then answer the questions. Hopefully the code works this is my first time uploading code to github.
import random
import time
import pickle
## Initial constants
initial_human = 100
human = initial_human
human_dead = 0
initial_beast = 25
beast = initial_beast
beast_dead = 0
@phillipkent
phillipkent / nplustransform.py
Last active December 15, 2015 22:19
N-plus-transform: An implementation in Python of the Oulipo 'S+7' ('noun + 7') text transformation. [http://www.oulipo.net/contraintes/docs/s-7 , http://www.spoonbill.org/n+7/ ] Requires the NLTK toolkit http://nltk.org, and uses a nouns list sourced from http://www.ashley-bovan.co.uk/words/partsofspeech.html
'''
Created on 14 Mar 2013
@author: phillip
INCOMPLETE CODE UNDER DEVELOPMENT
'''
# Oulipo's 'N plus' transformation for text
#
# Words list 'nouns91k.txt' contains 91000 nouns, found at
# http://www.ashley-bovan.co.uk/words/partsofspeech.html
@UniIsland
UniIsland / SimpleHTTPServerWithUpload.py
Created August 14, 2012 04:01
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@stefanv
stefanv / sparks.py
Created November 17, 2011 00:25
Command line sparks in Python
#!/usr/bin/python
# coding=utf-8
# Python version of Zach Holman's "spark"
# https://github.com/holman/spark
# by Stefan van der Walt <stefan@sun.ac.za>
"""
USAGE: