Skip to content

Instantly share code, notes, and snippets.

@mrasmus
mrasmus / gist:b133ca537eff7c3ae175
Last active June 16, 2016 07:35
WavTap Uninstaller
#!/bin/bash
# Because WavTap (https://github.com/pje/wavtap) doesn't come with a straightforward way to do it. :\
# Must be run elevated. Mirrors what "make uninstall" does exactly as of June 24, 2014.
osascript -e 'tell application "WavTap"' -e 'quit' -e 'end tell'
rm -rf /Applications/WavTap.app
if [[ "$(kextstat | grep WavTap | grep -v grep)" ]]; then sudo kextunload /System/Library/Extensions/WavTap.kext; fi
rm -rf /System/Library/Extensions/WavTap.kext
rm -rf /Library/Receipts/WavTap*
rm -rf /var/db/receipts/*WavTap.*
@drdrang
drdrang / WeatherUnderground.py
Created February 23, 2014 06:07
Pythonista script for generating and displaying the local weather.
#!/usr/bin/python
import json
import requests
import time
from datetime import datetime
import location
import webbrowser
import BaseHTTPServer
@ept
ept / gist:4475995
Last active November 4, 2022 08:38
Syntax highlighting code for PowerPoint (Mac OS)

How to add syntax-highlighted code to PowerPoint slides (Mac OS)

  1. pygmentize -f rtf FILE | pbcopy
  2. Paste into TextEdit (in rich text mode: Format → Make Rich Text before pasting), and copy to clipboard again.
  3. In PowerPoint, Edit → Paste Special… → Styled Text.

(Pasting RTF directly into PowerPoint doesn't work correctly, at least with PowerPoint 2008 — it extends colour spans longer than it should, and sometimes removes line breaks. Going via TextEdit seems to solve the problem.)

@typehorror
typehorror / name_generator.py
Created November 26, 2012 15:08
I give you a random name generator using the most common american first names (male and female) and last name.
import random
FIRST_NAMES = 'James', 'John', 'Robert', 'Michael', 'William', 'David',
'Richard', 'Charles', 'Joseph', 'Thomas', 'Christopher', 'Daniel', 'Paul',
'Mark', 'Donald', 'George', 'Kenneth', 'Steven', 'Edward', 'Brian',
'Ronald', 'Anthony', 'Kevin', 'Jason', 'Matthew', 'Gary', 'Timothy',
'Jose', 'Larry', 'Jeffrey', 'Frank', 'Scott', 'Eric', 'Stephen', 'Andrew',
'Raymond', 'Gregory', 'Joshua', 'Jerry', 'Dennis', 'Walter', 'Patrick',
'Peter', 'Harold', 'Douglas', 'Henry', 'Carl', 'Arthur', 'Ryan', 'Roger',
'Joe', 'Juan', 'Jack', 'Albert', 'Jonathan', 'Justin', 'Terry', 'Gerald',
@pudquick
pudquick / pipista.py
Created November 20, 2012 07:23
pipista - pip module (for installing other modules) for Pythonista
import os, os.path, sys, urllib2, requests
class PyPiError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def _chunk_report(bytes_so_far, chunk_size, total_size):
if (total_size != None):
@lost-theory
lost-theory / gist:3925738
Created October 21, 2012 04:29
different delimiters in jinja2 + flask
from flask import Flask, render_template_string, request
class CustomFlask(Flask):
jinja_options = Flask.jinja_options.copy()
jinja_options.update(dict(
block_start_string='<%',
block_end_string='%>',
variable_start_string='%%',
variable_end_string='%%',
comment_start_string='<#',
@jtratner
jtratner / dynamic_blueprints.py
Last active November 26, 2019 14:24
Dynamic blueprints flask pseudocode
import os
PATH = path/to/my/blueprints/directory
BLUEPRINT = 'the_blueprint'
def import_file(path, name=None):
""" imports a file with given name and path """
# use the imp module to do actual imports
import imp
name = name or os.path.split(path)[-1].replace(".", "_")
@jkp
jkp / websocketserver.py
Created July 18, 2012 13:28
A simple WebSockets server with no dependencies
import struct
import SocketServer
from base64 import b64encode
from hashlib import sha1
from mimetools import Message
from StringIO import StringIO
class WebSocketsHandler(SocketServer.StreamRequestHandler):
magic = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
@ljos
ljos / cocoa_keypress_monitor.py
Last active January 6, 2024 07:36
Showing how to listen to all keypresses in OS X through the Cocoa API using Python and PyObjC
#!/usr/bin/env python
#
# cocoa_keypress_monitor.py
# Copyright © 2016 Bjarte Johansen <Bjarte.Johansen@gmail.com>
#
# The MIT License (MIT)
#
# 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
@liamcurry
liamcurry / gist:2597326
Created May 4, 2012 19:56
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})