Skip to content

Instantly share code, notes, and snippets.

@halferty
halferty / zend.ini
Created March 17, 2016 23:13
set default timezone for ZF1
phpSettings.date.timezone = "America/Los_Angeles"
@halferty
halferty / wpautop.rb
Last active February 28, 2017 06:36
wpautop ported to Ruby (including an incidental "fix" for an obscure bug in the PHP version - which will be lost to the world because no one will ever look at this gist lol)
def autop(px, br = true)
pre_tags = []
return '' if px.strip == ""
px = px + "\n"
if px =~ /<pre/
px_parts = px.split "</pre>"
last_px = px_parts.pop
px = ""
i = 0
px_parts.each do |px_part|
@halferty
halferty / heading.rb
Created December 22, 2015 01:48
Code-golfed source code comment banner generator
#!/usr/bin/env ruby
t=$*[0]
e='#'*79
r='#'+' '*77+'#'
puts [e,r,t.scan(/.{1,40}/).map{|a|m=r.clone;l=(79-a.size)/2;m[l..(l+a.size-1)]=a;m},r,e].join "\n"
@halferty
halferty / ledripple_no_ir.ino
Last active December 13, 2015 03:38
ledripple_no_ir.ino
#include <avr/pgmspace.h>
#define DATA_1 (PORTC |= 0X01)
#define DATA_0 (PORTC &= 0XFE)
#define STRIP_PINOUT (DDRC=0xFF)
#define NOP __asm__("nop\n\t");
#define NOP28 NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP
#define NOP9 NOP NOP NOP NOP NOP NOP NOP NOP NOP
#define NOP3 NOP NOP NOP
@halferty
halferty / gist:18e79c46ce3e68ac4f14
Created October 4, 2015 06:04
codewarrior versions
login or create an account.
recent changes, games uploaded so far Macintosh Garden
GAMES A - Z APPS
SEARCH...
GUIDES FORUM IRC ABOUT
This page is a wiki. Please login or create an account to begin editing.Home › General discussion
11 posts / 0 new Login or register to post comments
Last post
@halferty
halferty / 001
Last active August 29, 2015 14:23
c code wrapped in bash script for quickly testing stuff.
#!/bin/bash
rm -f tempfifo1
rm -f a.out
mkfifo tempfifo1 2>/dev/null
cat << EOF > tempfifo1 &
#include <stdio.h>
int main(int argc, char ** argv) {
printf("Hello, world!\n");
return 0;
~ »wc -l test.txt
23759 test.txt
~ »function truncate() { echo "`tail -n100 $1`" > $1; }; truncate test.txt
~ »wc -l test.txt
100 test.txt
~ »
@halferty
halferty / killify.sh
Created May 27, 2015 21:29
The development world is full of badly-behaved processes that stop responding to ctrl-c (WEBrick & jetty, I'm lookin' at you!). Make them stop with a good old fashioned kill -9.
function killify() {
if [ $# -ne 0 ]; then
kill -9 `ps auxww | grep "$@" | grep -v grep | tr -s ' ' | cut -d' ' -f 2`
fi
}
@halferty
halferty / ledripple.ino
Created May 4, 2015 22:01
Radioshack RGB LED strip Ripple color change test with IR remote control
#include <avr/pgmspace.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#define DATA_1 (PORTC |= 0X01)
#define DATA_0 (PORTC &= 0XFE)
#define STRIP_PINOUT (DDRC=0xFF)
#define NOP __asm__("nop\n\t");
#define NOP28 NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP
#define NOP9 NOP NOP NOP NOP NOP NOP NOP NOP NOP
@halferty
halferty / main.c
Created March 29, 2015 08:03
OpenGL win32 multi-window example
#include "stdafx.h"
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#define MAX_LOADSTRING 100
HINSTANCE hInstance;
HWND hWnd, hWnd2;
struct WindowData {
HWND window;