Skip to content

Instantly share code, notes, and snippets.

@pudquick
pudquick / lockscreen.py
Created December 23, 2015 19:12
Programmatically immediately lock the screen of a Mac running OS X, regardless of security settings, screensaver settings, or Fast User Switch settings
from ctypes import CDLL
loginPF = CDLL('/System/Library/PrivateFrameworks/login.framework/Versions/Current/login')
result = loginPF.SACLockScreenImmediate()
@tomviner
tomviner / snake1d.py
Last active May 6, 2016 08:49
One dimensional snake
import os
import random
import string
import sys
import time
from utils import getch
def snake1d():
export NONE='\[\033[0m\]'
export WHITE_1='\[\033[0;1m\]'
export BLACK='\[\033[0;30m\]'
export GRAY='\[\033[1;30m\]'
export RED='\[\033[0;31m\]'
export LIGHT_RED='\[\033[1;31m\]'
export GREEN='\[\033[0;32m\]'
export LIGHT_GREEN='\[\033[1;32m\]'
export BROWN='\[\033[0;33m\]'
export YELLOW='\[\033[1;33m\]'
@cdennington
cdennington / gist:5098790
Last active December 14, 2015 14:08
Redmine issue update
//Set an Interval on the function to run every 10 secs
setInterval(function() {
//Get actual date
var date = new Date();
//console.log(date);
var reDate = /(\d+)\/(\d+)\/(\d+)/;
//Make comment date into actual date format
jQuery('a[title]').filter(function(){
var a = jQuery(this);
return a.attr('title').match(reDate);
@jaymzcd
jaymzcd / mailbomb.py
Created February 14, 2012 17:38
Quick'n'dirty mailbomb of user X when annoying
import smtplib
import os
import sys
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
from random import randint
@jaymzcd
jaymzcd / nicereadme.sh
Created February 13, 2012 16:39
Use documentup.com to prettify your markdown files from the commandline
function nicereadme {
TARGET_DOC=${1:-/tmp/doc.html}
INFILE=${2:-README.md}
curl -s -X POST --data-urlencode content@$INFILE http://documentup.com/compiled > $TARGET_DOC;
echo "$INFILE is pretty at file://$TARGET_DOC";
}
@jaymzcd
jaymzcd / resolve_301.sh
Created February 3, 2012 13:59
resolve a list of 301'ing links to a file
while read line;
do curl -Is $line | egrep "Location" | awk -F": " '{print $2}' >> urls-resolved.txt;
done < urls-2.txt
@stephenpaulger
stephenpaulger / sigquit.py
Created January 18, 2012 17:14
SIGQUIT handler
import signal
import sys
import time
def handle(sig, frame):
print all_signals[sig]
all_signals = dict((getattr(signal, attr), attr) for attr in dir(signal) if attr.startswith("SIG"))
@dnouri
dnouri / gist:1600408
Created January 12, 2012 13:06
Use pyquery to search zope.testbrowser contents
from zope.testbrowser.browser import Browser
def _zope_testbrowser_pyquery(self):
from pyquery import PyQuery
return PyQuery(self.contents)
Browser.pyquery = property(_zope_testbrowser_pyquery)
# This will allow you to do in your tests:
# >>> "Home" in browser.pyquery('#navigation').text()
@jaymzcd
jaymzcd / git_tips.md
Created September 22, 2011 09:42
Few git things for pushing remotes/setting up on centos/rhel

Git things internally

Installation of Git on RHEL/CentOS

first, and you probably wont really ever need this unless you're doing a bare bones install of a cent/rhel box, the webtactic repo maintains a decently up to date git install that will cleaning go onto such a box:

sudo rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
sudo yum install --enablerepo=webtatic git-all

Now you have working git!