This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def average(*numbers) | |
((numbers.inject {|sum, element| sum + element}) / numbers.length).to_f | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once("bootstrap.php"); | |
/* | |
* | |
* The template class to handle the output to a template file. It's good | |
* because it seperates all the PHP code from the actual HTML, except for | |
* the PHP markup used to output the data. | |
* | |
* It's used by making a file in the root directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* Simple template engine | |
* | |
*/ | |
class Template { | |
private $data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TodoList < Array | |
def self.load(file) | |
# read the file, create a list, create items, add them to the list, return the list | |
list = TodoList.new | |
File.read(file).each_line do |line| | |
list << line.chomp | |
end | |
list | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
main() { | |
// String to contain program | |
char *program = "#include <stdio.h>%cmain() {%c char *program = %c%s%c;%c printf(program, 10, 10, 34, program, 34, 10, 10, 10);%c}%c"; | |
/* Insert ascii characters for colon and newline | |
Write out the program, two new lines, at 34 we start colons | |
at the program pointer, in the colons write out the program | |
_again_ stop colons, and paste out some new lines, done! */ | |
printf(program, 10, 10, 34, program, 34, 10, 10, 10); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
static char *ptr; | |
int do_command(const char command, FILE *pFile) | |
{ | |
char c; | |
int pos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
WINTITLE="sakura" # Name of the window (or part of it) | |
PROGRAMNAME="sakura" # Name of the program, so it can be opened if there's no window currently | |
# Lists all windows, if there's one containing $WINTITLE it'll return 1, and bring the current instance of the program to the front. | |
if [ `wmctrl -l | grep -c "$WINTITLE"` != 0 ] | |
then | |
wmctrl -a "$WINTITLE" | |
# Else, it'll launch a new instance | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# By Sirupsen @ http://sirupsen.dk | |
# | |
# Description: Very simple script to make you | |
# select a region of your screen, which will be captured, and | |
# then uploaded. The URL will then be inserted into your clipboard. | |
# | |
# Dependencies: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class TodoList | |
def self.load(file) | |
# read the file, create a list, create items, add them | |
end | |
def initialize | |
end | |
def add(item) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implementation of TheLinx's BrainDamage in Ruby | |
# => http://gist.github.com/402454 | |
# | |
class BrainDamage < Array | |
SPACE = 32 | |
NEWLINE = 10 | |
def run(file) | |
file = get_file_content(file) |
OlderNewer