Skip to content

Instantly share code, notes, and snippets.

@SteelPangolin
SteelPangolin / mkdtemp.php
Created Nov 29, 2011
fake mkdtemp() for PHP
View mkdtemp.php
<?php
/**
* Create a directory in the system temp directory with a hard-to-predict name.
* Does not have the guarantees of the actual BSD libc function or Python tempfile function.
* @param string $suffix Append to the new directory's name
* @param string $prefix Prepend to the new directory's name
* @return string The path of the new directory.
*/
function mkdtemp($suffix = '', $prefix = 'tmp')
@SteelPangolin
SteelPangolin / rmtree.php
Created Nov 30, 2011
shutil.rmtree for PHP
View rmtree.php
<?php
/**
* Delete a file or directory recursively.
* @param string $path
*/
function rmtree($path)
{
if (is_dir($path))
{
@SteelPangolin
SteelPangolin / lsflags.c
Created Oct 2, 2012
lsflags: complementary utility to chflags. List flags for Mac OS X files and folders.
View lsflags.c
// compile with gcc -std=c99 -Wall lsflags.c -o lsflags
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/stat.h>
View site_init.py
"""
Decorate SCons Environment constructor so that Homebrew paths are always included.
"""
from functools import wraps
import SCons.Environment
# Homebrew install directory
homebrew = '/opt/homebrew'
View gist:9009942
<?php
function master()
{
$num_partitions = 10;
// not every system has this :(
//setproctitle("Parallel master: {$num_partitions} partitions");
$workers = [];
@SteelPangolin
SteelPangolin / package_mod_auth_openid.sh
Created Jun 14, 2014
How to package your own mod_auth_openid 0.9 for Ubuntu
View package_mod_auth_openid.sh
#!/bin/bash
# Ubuntu version of package: http://packages.ubuntu.com/trusty/libapache2-mod-auth-openid
# FPM man page: https://github.com/jordansissel/fpm/wiki
# FPM instructions for autotools: https://github.com/jordansissel/fpm/wiki/PackageMakeInstall
# install build-time dependencies
# yes, apache2 is a build-time dependency, otherwise APXS breaks:
# "checking Apache version... configure: error: /usr/bin/apxs2 says that your apache binary lives at /usr/sbin/apache2 but that file isn't executable."
sudo aptitude -y install \
@SteelPangolin
SteelPangolin / Main.hs
Created Jan 20, 2015
Install Mac version of UT2004 from PC discs and Mac demo
View Main.hs
module Main where
{-
Utility to automatically install and patch the Mac OS X version
of Unreal Tournament 2004 from the Mac demo and patcher
and PC installation disc images and CD key.
Can automatically download the demo and patcher.
see: http://lowetechlabs.com/UT2004-WIN2OSX/
see: http://forums.macnn.com/showthread.php?t=292620
@SteelPangolin
SteelPangolin / sitecopy.sh
Created Jan 23, 2015
wget optimized for creating locally browseable archives
View sitecopy.sh
#!/bin/bash
wget \
--execute robots=off \
--no-check-certificate \
--mirror \
--html-extension \
--convert-links \
--backup-converted \
--page-requisites \
@SteelPangolin
SteelPangolin / EC2-Describe-IAM-policy.json
Created Jan 30, 2015
Get an Amazon Elastic Beanstalk environment's name from inside one of its instances
View EC2-Describe-IAM-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:Describe*"
],
"Effect": "Allow",
"Resource": "*"
}
@SteelPangolin
SteelPangolin / detect_wordexp.py
Last active Aug 29, 2015
Look for wordexp() imports on your $PATH
View detect_wordexp.py
#!/usr/bin/python
"""
Look for binaries on $PATH that use the wordexp() POSIX libc function.
Only looks at dynamically linked binaries.
Works on Mac OS X and Linux systems, Python versions 2.4 to 3.4.
"""
import subprocess
import os
import sys
You can’t perform that action at this time.