Skip to content

Instantly share code, notes, and snippets.

@bycoffe
bycoffe / csvtosqlite.py
Created October 23, 2009 16:52
Creates a sqlite database and table from a CSV file for easier querying
"""
Copyright (c) 2009, Aaron Bycoffe
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
@aliang
aliang / Mac SSH Autocomplete
Created June 14, 2011 07:14
Add auto complete to your ssh, put into your .bash_profile
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
@gruber
gruber / gist:1063605
Created July 4, 2011 16:48
Simple Inbox Archiving Script for Apple Mail
-- See article here: http://daringfireball.net/2007/07/simple_inbox_sweeper
-- The following should be one long line:
set _description to "All unflagged, read messages in each IMAP account
inbox will be moved to the “Archive” mailbox corresponding to that
account. This action is not undoable."
tell application "Mail"
display alert "Archive read messages from IMAP inboxes?" buttons ¬
{"Cancel", "Archive"} cancel button 1 message _description
@javan
javan / gist:1168475
Created August 24, 2011 16:32
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen
@aculich
aculich / forwarder.py
Created November 28, 2011 07:52
SSHForwarder class for use with the python ssh module: http://pypi.python.org/pypi/ssh
#!/usr/bin/env python
# This code is licensed according to the main package that it depends on:
# http://pypi.python.org/pypi/ssh
# License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
# http://www.gnu.org/licenses/lgpl.html
import sys, os, os.path
import select
import SocketServer
@empireshades
empireshades / smokemtr.py
Created May 10, 2012 21:01
Script that runs an MTR (MattsTraceRoute) report against a given host, saves the output to log and also emails. This is meant to be called by smokeping (via pipe '|') after an alert is triggered. Tested on python2.6
#!/bin/env python
'''This is a script which runs an MTR (matt's traceroute)
against a target hosts - meant to be triggered by a
smokeping alert. Output is emailed and saved to log.'''
import argparse, datetime, subprocess, smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active July 20, 2024 05:10
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@dlo
dlo / allpinboard.py
Last active September 5, 2019 15:26 — forked from ttscoff/allpinboard.rb
Python version of https://gist.github.com/3773519 that pulls all bookmarks on the first sync, and does incremental updates afterwards. Also uses the Mac OS X keychain to retrieve your password so it doesn't need to live in a file on your computer in plain text.
#!/usr/bin/env python
"""
This script is designed to generate a simple html file with _all_ of your
Pinboard.in bookmarks The HTML file can be added to Launchbar's index as a
custom bookmark file and you can search your entire Pinboard.in collection
instantly from Launchbar (by title only). It includes any applied tags as part
of the title to aid in searching.
You should edit the `username`, `bookmark_filename`, and `local_timezone`
@macolyte
macolyte / today_i_learned.py
Last active December 11, 2015 21:39
Learn something new every day with Pythonista
from datetime import date
import webbrowser
import console
def main():
result = console.alert("Today I Learned", "Choose your path", "reddit", "today", "random")
today = date.today().strftime("%B_%d")
urls = ["http://www.reddit.com/r/todayilearned", ("http://en.wikipedia.org/wiki/%s" % today), "http://en.wikipedia.org/wiki/Special:Random"]
@valpackett
valpackett / Alfred-Pinboard-INSTANT.md
Last active September 7, 2023 21:01
INSTANT Pinboard search from Alfred 2

INSTANT Pinboard search from Alfred 2

I've had a Python script that makes an HTML Bookmarks file for LaunchBar.
Now that I use Alfred 2, I modified it to make XML for Alfred.
This allows me to search my bookmarks with GREP SPEED!

Installation

First, add your token (from pinboard.in/settings/password) to ~/.netrc