Skip to content

Instantly share code, notes, and snippets.

@kylef
kylef / dict.c
Created March 27, 2009 17:11
A key/value dictionary system in C
/* A key/value dict system in C */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TEST TRUE /* Comment this line out to compile without a main function (used when including into another application). */
typedef struct dict_t_struct {
char *key;
void *value;
@kylef
kylef / craftbukkit
Created February 9, 2011 21:36
init.d script for craftbukkit (minecraft server)
#!/bin/sh
# /etc/init.d/craftbukkit
USERGROUP="sam:sam"
CBPATH="/home/sam/.craftbukkit"
PIDFILE=$CBPATH/pidfile
case "$1" in
start)
@kylef
kylef / sabnzbd.py
Created January 11, 2010 15:04
SABnzbd python api
import urllib, json
class SABnzbd(object):
"""
Usage:
>>> from sabnzbd import SABnzbd
>>> s = SABnzbd('sakar.local', 8080, '4488f2881b90d7753bef8fb9e1bc56b3')
>>> s.pause() # Pauses the downloads
>>> s.shutdown() # Shut's down SABnzbd+
"""
#!/usr/bin/env bash
# Automatically installs swiftenv and run's swiftenv install.
# This script was designed for usage in CI systems.
git clone --depth 1 https://github.com/kylef/swiftenv.git ~/.swiftenv
export SWIFTENV_ROOT="$HOME/.swiftenv"
export PATH="$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH"
if [ -f ".swift-version" ] || [ -n "$SWIFT_VERSION" ]; then
swiftenv install -s
@kylef
kylef / post-checkout.sh
Last active December 11, 2019 21:09
Git post-checkout hook to install CocoaPods
#!/bin/bash
#
### CocoaPods git-checkout hook
#
# This is a hook which you can install, it will automatically
# run `pod install` when you do a git pull/clone/checkout.
#
# The hook can be used to make CocoaPods usable with Xcode CI.
#
## Installation

Keybase proof

I hereby claim:

  • I am kylef on github.
  • I am kylef (https://keybase.io/kylef) on keybase.
  • I have a public key whose fingerprint is BB7D D311 C34B 09C9 0FD1 1258 93AB E8C2 33AC D3D5

To claim this, I am signing this object:

@kylef
kylef / Toggle Mute (Skype)
Created May 31, 2009 13:11
Applescript to toggle mute on Skype
tell application "Skype"
if (send command "GET MUTE" script name "MuteToggler") is equal to "MUTE ON" then
send command "SET MUTE OFF" script name "MuteToggler"
else
send command "SET MUTE ON" script name "MuteToggler"
end if
end tell
@kylef
kylef / instance-swizzle.m
Last active January 2, 2016 02:19
Replace a method on an instance at runtime
+ (void)load {
/* We want to add our method after the application has finished launching
because that's when the key window should be setup.
We will add a method to that instance. */
/*
WARNING
This would fail if another object was to key value observe the object
we are going change the class of before we change it. That means before
@kylef
kylef / reporting.md
Last active December 22, 2015 06:59
Problem reporting guide

When reporting any problems, please provide all the information outlined below so we can properly diagnose the problem.

  • Classification: Security, Crash/Hang/Data Loss, Performance, UI/Usability, Serious Bug, Other Bug, Feature, Enhancement
  • Reproducability: Always, Sometimes, Rarely, Unable, Not Applicable
  • Device For example: iPad 3 or iPhone 5 GSM
  • Operating System Version: For example: iOS 6.1.3
  • Application Version: For example: 1.0-3-gefebej (553)
  • Steps to reproduce: Describe exactly every step you had to do to produce the problem.
  • Expected Results: Describe what you expected to experiance after completing the above steps.
  • Actual Behaviour: Describe what actually happened after completing the steps above.
@kylef
kylef / images.py
Last active December 21, 2015 13:59
Search the current directory for unused images. Useful for finding leftover assets from files which exist in Xcode project or in your repository.
# This simple python utility crawls the current directory and finds all images.
# It will then search the directory for files using these images and also mark
# any xcode projects which include these images.
#
# Allowing you to easily find images which are no longer used (or even images
# included in xcode and not used).
#
# Usage, cd into your repository and then run:
#
# curl https://gist.github.com/kylef/6316920/raw/images.py -# | python -