Skip to content

Instantly share code, notes, and snippets.

View wgaylord's full-sized avatar

William Gaylord wgaylord

View GitHub Profile
import socket
import struct
import json
def unpack_varint(s):
d = 0
for i in range(5):
b = ord(s.recv(1))
d |= (b & 0x7F) << 7*i
if not b & 0x80:
@ebuckley
ebuckley / gist:1842461
Created February 16, 2012 05:55
python code to encode/decode morse code
morseAlphabet ={
"A" : ".-",
"B" : "-...",
"C" : "-.-.",
"D" : "-..",
"E" : ".",
"F" : "..-.",
"G" : "--.",
"H" : "....",
"I" : "..",
@silarsis
silarsis / Image Effects.py
Created November 8, 2012 02:28
Pythonista Scripts
# Image Effects
# Demonstrates some effects using different modules
# from the Python Imaging Library (PIL).
#
# Tip: You can touch and hold an image in the output
# to copy it to the clipboard or save it to your
# camera roll.
import Image, ImageOps, ImageFilter
from Image import BILINEAR
@omz
omz / ImageMail.py
Created November 14, 2012 17:43
ImageMail
# Example for sending an email with an attached image using smtplib
#
# IMPORTANT: You need to enter your email login in the main() function.
# The example is prepared for GMail, but other providers
# should be possible by changing the mail server.
import smtplib
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email import encoders
@schrockwell
schrockwell / freedv.sh
Created December 7, 2012 16:59
Compiling Codec 2 and FreeDV on Windows
# Compiling Codec 2 and FreeDV on Windows
# Rockwell Schrock, WW1X
# December 7, 2012
#
# Based off the README.Win32 file in the FreeDV SVN repository.
# Tested on Windows 7 32-bit.
#
# More info: http://freedv.org/
#
# Install MinGW with options: C Compiler, C++ Compiler, MSYS
@omz
omz / turtle.py
Created December 30, 2012 17:04
turtle
# turtle.py
# Basic Turtle graphics module for Pythonista
#
# When run as a script, the classic Koch snowflake is drawn as a demo.
# The module can also be used interactively or from other scripts:
# >>> from turtle import *
# >>> right(30)
# >>> forward(100)
# ...
@omz
omz / SlimIt-Installer.py
Created October 21, 2013 17:11
SlimIt-Installer
ply_url = 'https://pypi.python.org/packages/source/p/ply/ply-3.4.tar.gz'
slimit_url = 'https://pypi.python.org/packages/source/s/slimit/slimit-0.8.1.zip'
print 'Downloading SlimIt...'
from urllib import urlretrieve
import tarfile
import zipfile
import shutil
import os
try:
@pudquick
pudquick / transtor.py
Created November 24, 2013 01:30
A Pythonista (python on iOS, check the App Store!) script for downloading torrents, modifying them, then uploading them to a Transmission server - directly from your iPhone / iPad
# Usage of this file:
# This code is intended for use in the iOS python interpreter named 'Pythonista'.
# When looking at a page on the torrentz.eu search engine for a torrent result from Mobile Safari
# you can click on a bookmarklet (mentioned below) and it will cause the following:
# - Search results for the page are scraped
# - Torrent sites are visited for direct download links for the .torrent file
# - A .torrent file is downloaded
# - The .torrent file trackers are updated to include the scraped trackers listed on torrentz.eu
# - The .torrent file is re-uploaded to your Dropbox account (for an on-demand HTTP source)
# - The direct download link for the modified .torrent file is passed via RPC to a Transmission torrent server
@cclauss
cclauss / getColor.py
Last active August 8, 2023 14:43
Creates a dict of 752 Pythonista scene.Colors from the tkinter color palette. This allow you to get colors like: 'light goldenrod yellow', 'light steel blue', 'SlateGray4', 'etc. I would recommend using this code to find the colors that work for your app and then hardcoding them into you app. Loading all 752 colors every time your app runs will …
import bs4, collections, console, requests, scene
tkColorDict = collections.OrderedDict() # key = tkinter color name
def loadTkColorDict(): # will automaticly be called by getColor() if needed
tkColorURL = 'http://www.tcl.tk/man/tcl8.6/TkCmd/colors.htm'
print('Loading tkinter colors from: ' + tkColorURL)
tkColorSoup = bs4.BeautifulSoup(requests.get(tkColorURL).text).tbody
print('Soup is ready. Creating color table...')
for tableRow in tkColorSoup.find_all('tr'):
@fiorix
fiorix / gist:9664255
Created March 20, 2014 13:55
Go multicast example
package main
import (
"encoding/hex"
"log"
"net"
"time"
)
const (