Skip to content

Instantly share code, notes, and snippets.

View romac's full-sized avatar
🔮
λ

Romain Ruetschi romac

🔮
λ
View GitHub Profile
@tj
tj / error
Created September 21, 2010 05:11
if foo
if bar
something
else
something_else
else
baz
@macmade
macmade / ASM Universe
Created November 26, 2010 20:05
The whole universe, coded with 236 characters of assembly code...
BITS 16
before_big_bang:
cli
mov ax, 0x07C0
mov ds, ax
mov es, ax
@creationix
creationix / _README.markdown
Created November 29, 2010 19:50
Rectify Challenge

Rectify

Takes a grid and returns an optimal set of rectangles that fills that grid

For example, the following grid:

[[1,1,0,1,1],
 [1,1,1,1,1],
 [0,1,1,1,0]]
@brantfaircloth
brantfaircloth / sphinx_to_github.sh
Created January 23, 2011 02:40
Sphinx documentation to github gh-pages without submodules
# assume the following directory structure where contents of doc/
# and source/ are already checked into repo., with the exception
# of the _build directory (i,e. you can check in _themes or _sources
# or whatever else).
#
# proj/
# source/
# doc/
# remove doc/_build/html if present

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";
@nolanw
nolanw / NSBundle+StopAutoloadingNibs.m
Created February 5, 2011 23:04
Prevent NSApp from autoloading a nib at launch.
#import <Foundation/Foundation.h>
// NSApplication has this weird habit of trying very hard to load a nib at
// launch. If there are none in the app bundle, it'll wander off into the
// frameworks until it finds one, then try to use it.
//
// You know this is what's happening if you get four log messages at launch
// saying "Could not connect the action buttonPressed: to target of class
// NSApplication". You've deleted MainMenu.nib and removed the "Main nib file
@greut
greut / run.php
Created April 30, 2011 18:18
A web server in pure PHP (non-concurrent and concurrent)
#!/usr/bin/env php
<?php
$app = function($request) {
$body = <<<EOS
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<title>Hello World!</title>
@dzuelke
dzuelke / bcrypt.php
Last active March 28, 2023 13:15
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22);
// 2y is the bcrypt algorithm selector, see http://php.net/crypt
// 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt
@nathansmith
nathansmith / detect_full_screen.html
Created May 18, 2011 15:42
Detect full-screen mode for desktop browsers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Detect Full-Screen</title>
<style>
* {
font-family: sans-serif;
line-height: 1.5;
@mads-hartmann
mads-hartmann / ast_transformation.scala
Created August 11, 2011 13:00
Attempt to do AST Transformation
#!/bin/sh
exec scala "$0" "$@"
!#
/*
Subset of our Simple Java AST
*/
sealed abstract class SJStatement
case class SJAssert (assertion : SJExpression) extends SJStatement