Skip to content

Instantly share code, notes, and snippets.

View TimWolla's full-sized avatar

Tim Düsterhus TimWolla

View GitHub Profile
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@lukemorton
lukemorton / README.markdown
Created June 4, 2011 13:32
Set caret position via jQuery

jQuery Caret

This is a very simple lightweight plugin to allow you to move the caret (or cursor) position in an <input /> or <textarea> element.

By exposing three jQuery.fn methods you can easily move a a caret to any position you like:

$.fn.caretTo( index , [ offset ] )

<?php
class FlyingObject extends Exception {
public $object;
public function __construct($object) {
$this->object = $object;
}
}
abstract class Object {
public function outOfWindow() {
@sontek
sontek / snowjob.sh
Last active April 5, 2024 06:51
Make your terminal snow
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
declare -A snowflakes
declare -A lastflakes
clear
@goozbach
goozbach / gist:1507318
Created December 21, 2011 19:26 — forked from sontek/snowjob.sh
Make your terminal snow
#!/bin/bash
LINES=$(tput lines)
COLUMNS=$(tput cols)
declare -A snowflakes
declare -A lastflakes
clear
@zaach
zaach / 0_new.md
Created January 22, 2012 23:15
New Jison 0.3 features

Some improvements have been made for parser and lexer grammars in Jison 0.3 (demonstrated in the FlooP/BlooP example below.)

For lexers:

  • Patterns may use unquoted characters instead of strings
  • Two new options, %options flex case-insensitive
  • flex: the rule with the longest match is used, and no word boundary patterns are added
  • case-insensitive: all patterns are case insensitive
  • User code section is included in the generated module
@TimWolla
TimWolla / gist:1855419
Created February 17, 2012 21:00
Coding with Love
<?php
class ♥ {
}
$♥ = new ♥();
@hank
hank / insane_kernel_macro_solution.c
Created April 12, 2012 07:10
The solution to Linus' question on resolving undefined macros in the preprocessor to 0, as well as resolving defined macros to their values.
#include <stdio.h>
#define CONFIG_FOO 1
#define CONFIG_NOO 0
#define is_set(macro) is_set_(macro)
#define macrotest_1 ,
#define is_set_(value) is_set__(macrotest_##value)
#define is_set__(comma) is_set___(comma 1, 0)
#define is_set___(_, v, ...) v
AW Map Editor file format specifications.
- by João Pedro S. Francese (Roma_emu) [joaofrancese@gmail.com]
- last updated on February 04, 2008
Please inform me before using this file format in your project - but please DO use it,
if it involves AW maps! A standard file format is good for everyone, because it makes sure
the files are compatible between different programs. If you use it, please credit Kamek
(the file format's creator) and me (the map editor's creator) somewhere. :)
Personally I would prefer if you didn't try to make another editor...
But it's not really up to me, is it?
<?php
$input = "root(27,3)";
$number = '(?:-?\d+(?:\.\d+)?)';
while (!preg_match('/^'.$number.'$/', $input)) {
$input = preg_replace_callback('/\(\s*('.$number.')\s*\)/', function ($matches) {
return $matches[1];
}, $input);
$input = preg_replace_callback('/('.$number.')\s*\^\s*('.$number.')/', function ($matches) {
return pow($matches[1], $matches[2]);