Skip to content

Instantly share code, notes, and snippets.

View kballenegger's full-sized avatar

Kenneth Ballenegger kballenegger

View GitHub Profile
<?php
//
// attemplate.inc.php
//
// Created by Kenneth Ballenegger on 2009-06-30.
// Copyright (c) 2009 Arure Talon. All rights reserved.
//
/*
<?php
class User {
// static
private static $_current_user = null;
// non-static
private $_data = array();
@kballenegger
kballenegger / xor.php
Created January 31, 2011 02:49
A toy cypher written in PHP. (I have no idea why I wrote this...)
<?php
function xor_cipher($data, $key) {
$data = bitify($data);
$key = bitify($key);
$cipher = array();
$k_i = 0;
for($d_i=0; $d_i<count($data); $d_i++) {
$d = $data[$d_i];
$k = $key[$k_i];
<?php
// Adapted by Kenneth Ballenegger
// From php.net
function arguments ($args) {
array_shift($args);
$endofoptions = false;
$ret = array(
@kballenegger
kballenegger / MainFile.m
Created August 2, 2011 21:54
Forcing category linking in static libraries.
// [...]
#import "NSInvocation+ForwardedConstruction.h"
void linkToMyCategoryProperly(void);
void linkToMyCategoryProperly() {
emptyCFunctionToForceLinkerToIncludeNSInvocationForwardedConstruction(); // make sure it's linked to properly
}
// [...]
require 'chartboost'
connection = Chartboost::ApiConnection.new
connection.app_id = my_app_id
connection.app_signature = my_app_secret
request = Chartboost::ApiRequest.new
request.controller = :api
request.action = :install
@kballenegger
kballenegger / desopafy.js
Created January 18, 2012 05:45 — forked from timraymond/desopafy.js
Bookmarklet: Remove SOPA overlay from Wikipedia pages
javascript:%24(%22%23mw-page-base%2C%20%23mw-head-base%2C%20%23content%2C%20%23mw-head%2C%20%23mw-panel%2C%20%23footer%22).css(%22display%22%2C%22inherit%22)%3B%24(%22%23mw-sopaOverlay%22).css(%22display%22%2C%22none%22)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/kenneth/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
checking for zmq.h... yes
checking for zmq_init() in -lzmq... yes
Cool, I found your zmq install...
creating Makefile
make
compiling rbzmq.c
[eye ~/Desktop•dotfiles]$ cat HelloWorldClient.java
//
// Hello World client in Java
// Connects REQ socket to tcp://localhost:5555
// Sends "Hello" to server, expects "World" back
//
// Naveen Chawla <naveen.chwl@gmail.com>
//
import org.zeromq.ZMQ;
@kballenegger
kballenegger / hn.css
Created February 24, 2013 03:50
Custom Hacker News stylesheet. Edited from something I found on the web.
.comment p, .comment + p {
line-height: 16px;
}
.comment u, .comment u a, .comment u a:visited, .comment + p u, .comment + p u a, .comment + p u a:visited {
color: #777;
text-decoration: none ;
}
.pagetop {