Skip to content

Instantly share code, notes, and snippets.

View danielpunkass's full-sized avatar

Daniel Jalkut danielpunkass

View GitHub Profile
@danielpunkass
danielpunkass / spamhaus-check.py
Created December 14, 2012 18:18
Spamhaus periodically places some IP addresses back on their "PBL" which leads certain mail exchanges to treat mail originating from the IP address as suspicious. If you run a mail server that ends up on this PBL you'll probably just notice that certain mail stops making it all the way to recipients. This python script checks the block status fo…
#!/usr/bin/python
import os
import sys
import urllib
# Change this to match your mail server's REVERSE static IP address
staticIPAddress = "1.0.0.127"
# Change this to an email address you don't mind sending to and from for the notice alert delivery
@danielpunkass
danielpunkass / gist:3702206
Created September 11, 2012 21:27
Importing from a newer prefs file
@implementation NSUserDefaults (RSFoundation)
+ (BOOL) rsImportPreferencesFromBundleID:(NSString*)otherBundleID ifNewerThanBundleID:(NSString*)ourBundleID
{
BOOL didMigrate = NO;
NSArray* libraryFolders = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
if ([libraryFolders count] > 0)
{
NSString* prefsFolder = [[libraryFolders objectAtIndex:0] stringByAppendingPathComponent:@"Preferences"];
tell application "Audio Hijack Pro"
set myAudio to (first session whose name is "Core Intuition MOTU 828")
set skypeAudio to (first session whose name is "Skype")
-- Start recording my mic input
start hijacking myAudio
start recording myAudio
-- Start recording Skype audio
start hijacking skypeAudio
@danielpunkass
danielpunkass / gist:2854083
Created June 1, 2012 18:06
Zsh functions for easily "fixing" iOS-optimized PNG files
function fixpng ()
{
if [[ ! -f $1 ]] ; then
echo "Usage: fixpng <inputFiles> [outputFile]"
return -1
else
local inputFile=$1
local outputFile=$1
if [[ -e $2 ]] ; then
outputFile=$2
tell application "System Events"
set frontProcess to first process whose frontmost is true
-- When it's down to just Finder and the front process, we have to switch
-- to the Finder first to get the front process to hide itself. Furthermore,
-- the Finder will not be listed as among the visible processes unless it
-- has open windows, so treat a condition of 2 *or fewer* visible apps as
-- meaning the Finder should be activated before hiding the front process.
@danielpunkass
danielpunkass / gist:2018752
Created March 11, 2012 23:57 — forked from rcw3/gist:2018059
Self-contained WWDC Status Checker Hack
#!/bin/bash
# run from terminal and you can watch it log as well... or nohup it
cd ~
testSiteForChanges ()
{
ls "old_page.html" 1>/dev/null 2>/dev/null
if [ $? -eq "1" ] ; then
/usr/local/bin/wget -q -O old_page.html $1
# Copies the selected tweet's URL from Twitter.app, and
# opens corresponding page for Aaron Swartz's Twitter Viewer.
#
# Original by John Gruber: https://gist.github.com/1440914
# This version by Daniel Jalkut
#
# I'm hooking this up to a keyboard shortcut specifically in Twitter.app,
# using my scripting utility FastScripts.
#
# Requires "Access for Assistive Devices" to be enabled.
//
// TextView.m
// TextDidChange
//
// Created by Timothy J. Wood on 10/27/09.
// Copyright 2009 The Omni Group. All rights reserved.
//
/*
- (id)copyWithZone:(NSZone *)zone
{
RSRadialProgressCell* newbie = [super copyWithZone:zone];
// When you use -[super copyWithZone], you have to assume that the superclass may have copied your instance variables over verbatim. So
// let's clear them out manually (using accessors would cause the stale pointer reference to be released).
newbie->mProgressView = nil;
newbie->mProgressView = [mProgressView retain];
newbie->mProgressCompletedOverlayImage = nil;
newbie->mProgressCompletedOverlayImage = [mProgressCompletedOverlayImage retain];
@implementation JimPopUpButtonCell
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSRect rect = [self drawingRectForBounds: cellFrame];
rect.size.width -= 17; // chop off the popup indicator
NSSize imageSize = NSMakeSize(12, 12);
rect.origin.x += (rect.size.width - imageSize.width) / 2.0;