Skip to content

Instantly share code, notes, and snippets.

View halfdan's full-sized avatar
🇩🇪

Fabian Becker halfdan

🇩🇪
View GitHub Profile
class VHost
attr_accessor :hostname
attr_accessor :file
attr_accessor :changed
attr_accessor :config
attr_accessor :id
@changed=false
def initialize(config,hostname,id=0)
#!/bin/bash
# Author: Fabian Becker <[email protected]>
#
# Extracts a database of an sql dump
# usage: ./grep-db.sh dump.sql dbname
line=`grep -n "CREATE DATABASE $2" $1 | cut -d ":" -f 1`
next=`sed 1,${line}d $1|grep -m 1 -n "CREATE DATABASE" |cut -d ":" -f 1`
end=$(($line + $next - 1))
sed -n ${line},${end}p $1
2010-10-01 10:29:12: (mod_fastcgi.c.2568) unexpected end-of-file (perhaps the fastcgi process died): pid: 0 socket: tcp:127.0.0.1:9000
2010-10-01 10:29:12: (mod_fastcgi.c.3356) response not received, request sent: 1010 on socket: tcp:127.0.0.1:9000 for /index.php?module=about&show=&id=&action=&page=&value=&subid=&sortorder=, closing connection
2010-10-01 10:29:14: (mod_fastcgi.c.2568) unexpected end-of-file (perhaps the fastcgi process died): pid: 0 socket: tcp:127.0.0.1:9000
2010-10-01 10:29:14: (mod_fastcgi.c.3356) response not received, request sent: 1010 on socket: tcp:127.0.0.1:9000 for /index.php?module=about&show=&id=&action=&page=&value=&subid=&sortorder=, closing connection
2010-10-01 10:29:33: (mod_fastcgi.c.2568) unexpected end-of-file (perhaps the fastcgi process died): pid: 0 socket: tcp:127.0.0.1:9000
2010-10-01 10:29:33: (mod_fastcgi.c.3356) response not received, request sent: 1010 on socket: tcp:127.0.0.1:9000 for /index.php?module=about&show=&id=&action=&page=&value=&subid=&sortorder=, closi
@halfdan
halfdan / 201102032216_create_users.php
Created February 3, 2011 21:16
ActiveRecord\Migration - CreateTable
<?php
class CreateUsers extends ActiveRecord\Migration {
public function up() {
$this->create_table('users', array(
// <field> => array(<type>, <length>, <nullable>)
'name' => array('varchar', 12, FALSE),
'email' => array('varchar', 255, FALSE)
));
@halfdan
halfdan / bool_test.c
Created May 27, 2011 20:46
Bool in C99
#include <stdbool.h>
#include <stdio.h>
bool test = false;
int main(void) {
if(test) {
printf("Test is true");
}
else {
// Generate random genes
ts.genes = make([]ga.Gene, ts.nGenes)
var proto = make([]int, ts.geneLength)
var i int = 0
for key, _ := range coords {
proto[i] = key
i++
}
// Initialize all len(genes) and shuffle
@halfdan
halfdan / gist:1435768
Created December 5, 2011 22:48
36cities unordered numbers for Travelling Salesman GA
18 2 23 4 25 6 7 21 9 34
36 0 0 0 0 0 0 0 0 16
35 0 0 0 0 0 0 0 0 12
10 0 0 0 0 0 0 0 0 27
33 0 0 0 0 0 0 0 0 14
15 0 0 0 0 0 0 0 0 32
31 0 0 0 0 0 0 0 0 11
30 0 0 0 0 0 0 0 0 17
19 0 0 0 0 0 0 0 0 1
28 13 26 3 24 5 22 8 20 29
@halfdan
halfdan / gist:1514831
Created December 23, 2011 17:21
Ninja Compiler - translation into tree language
// Programm
void f(boolean b) {
local integer a1;
local integer a2;
if (b) {
a1 = 2;
a2 = 22;
} else {
a1 = 3;
/*
* semant.c -- semantic analysis
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
@halfdan
halfdan / gist:1925936
Created February 27, 2012 18:16
Simple Ninja class
public class Main extends Object {
public static void main() {
local Integer x;
local Integer y;
x = 42.add(23);
y = 42.add(23);
System.writeInteger(x);
System.writeInteger(y);
}
}