This file contains hidden or 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
>>> parse_gramar('[HANZI],[PINYIN],[ENGL]#NEWLINE#') | |
{ | |
'text': '[HANZI],[PINYIN],[ENGL]#NEWLINE#', | |
'type': 'Gramar', | |
'children': [ | |
{ | |
'text': 'HANZI', | |
'type': 'Variable', | |
'children': [] | |
}, |
This file contains hidden or 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 | |
$res = mysql_pconnect("localhost","root","root"); | |
mysql_query("DROP Database 'ddpadd'",$res); | |
echo ":\n<br>create:".mysql_query("CREATE DATABASE IF NOT EXISTS ddpadd", $res); | |
echo ":\n<br>select:".mysql_select_db("ddpadd", $res); | |
echo mysql_query("DROP TABLE IF EXISTS decimal"); | |
echo ":\n<br>table:".mysql_query("CREATE TABLE decimal_add ( | |
no1 TINYINT(1), | |
no2 TINYINT(1), |
This file contains hidden or 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
/** | |
* the normally used way to add different types in a function | |
* | |
* @param $nr1 - the first summand | |
* @param $nr2 - the second summand | |
* @param $type - the number type. default='decimal' | |
*/ | |
function add_classical($nr1, $nr2, $type='decimal'){ | |
$sum = NULL; | |
switch($type){ |
This file contains hidden or 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
function add_classical($nr1, $nr2, $type='decimal'){ | |
$sum = NULL; | |
switch($type){ | |
case 'decimal': | |
$sum = (int)$nr1 + (int)$nr2; | |
case 'binary': | |
$sum = bindec($nr1) + bindec($nr2); | |
} | |
return $sum; | |
} |
This file contains hidden or 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/tcsh -f | |
set i=1 | |
while { i <= $#argv } | |
@ i = $i + 1 | |
if ( -d $argv[$i] ) then | |
rm -R $argv[$i] | |
else | |
echo Das $i. Argument ist kein Verzeichnis. | |
endif |
This file contains hidden or 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
import re | |
sep = re.compile(r"[^ |]+") | |
# a possible string that might be delivered by one of my collegues over http | |
test_text = "q1w2e3r4t5z|11°11.111'N 22°22.222'W" | |
def parse_all(text, dispatcher): | |
""" | |
parses over a given text using a dispatch table. the logic itself is in the dispatch table. |
This file contains hidden or 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
public List getRoute(myNode start, myNode end){ | |
//initialise variables | |
myNode actual = end; | |
myNodeList wayBack = new myNodeList(); | |
wayBack.add(end); | |
myNodeList way = new myNodeList(); | |
//find the minimum spanning tree with end | |
myNodeMap map = this.spanner.span(this.g, start); | |
This file contains hidden or 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/sh #################################################################### | |
# | |
# author: Erik Bernoth | |
# | |
# tricks the mac 10.5 terminal tab name into writing the ssh position instead | |
# of just "ssh" | |
# | |
# (c) 2009, do with this program what you want | |
# | |
############################################################################## |
This file contains hidden or 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
unset PROMPT_COMMAND | |
function title { | |
echo -en "\033]2;$1\007" | |
} | |
title `ifconfig -a | perl -ne \ | |
'if (m/^\s*inet (?:addr:)?([\d.]+).*?cast/) {print qq($1); exit 0; }'` |
This file contains hidden or 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
export PS1="\[\033[01;36m\]`ifconfig -a |\ | |
perl -ne 'if (m/^\s*inet (?:Adresse:)?([\d.]+).*?cast/) \ | |
{print qq($1); exit 0; }'`\[\033[00m\]:\[\033[01;36m\]\W \ | |
\[\033[01;36m\]\u\[\033[00m\]\$ " |