Skip to content

Instantly share code, notes, and snippets.

View aspyct's full-sized avatar

Antoine d'Otreppe aspyct

View GitHub Profile
@aspyct
aspyct / workaround.php
Created August 22, 2012 16:10
The most undebuggable PHP snippet ever
<?php
define("true ", false);
function doIt() {
define(" false", true);
define("maybe", rand() & 1);
}
function  ($stupid="clever") {
if (assert_value($stupid)) {
@aspyct
aspyct / display-double.cpp
Created July 28, 2012 21:31
A small program to display binary representation of double numbers
/*
* File: display-double.cpp
* Author: aspyct
*
* Can be compiled to a binaly that displays the binary value of double numbers.
* Usage : ./a.out <number1> ... <number n>
* Example: ./a.out 1.0 2.5
*
* Created on July 28, 2012, 11:03 PM
*/
@aspyct
aspyct / RBTree.java
Created July 17, 2012 13:22
Left Leaning Red/Black Tree implemented in Java
package org.aspyct.going;
import java.util.Iterator;
import java.util.Stack;
/**
* This is an implementation of the Left Leaning Red/Black Tree as
* described in the course from the University of Princeton.
*
* This code contains a lot of assertions (assert ;).
@aspyct
aspyct / common.h
Created July 15, 2012 22:00
Unix semaphore with the C programming language, tested under Debian
#ifndef _COMMON_H_
#define _COMMON_H_
#define SEM_KEY_FILE ("sem.key")
#endif /* _COMMON_H_ */
@aspyct
aspyct / NodeJs example .js
Created June 26, 2012 12:45
A short dependency container for javascript / node applications
> var sb = new ServiceBox();
> sb.msg = "Hello World";
> var handler = sb.wrap(function (prefix) {
... console.log(prefix);
... console.log(this.msg);
... });
> handler("this is the prefix");
this is the prefix
Hello World
@aspyct
aspyct / check_server.sh
Created June 25, 2012 14:31
Perl & Bash scripts to warn you if your website is failing
#!/bin/bash
# Actual recipient and sender are defined in another file
script_dir=`dirname $0`;
script_name=`basename $0`;
config_file="$script_dir/config-$script_name";
if [ -f $config_file ]; then
source $config_file;
else