Skip to content

Instantly share code, notes, and snippets.

View bxt's full-sized avatar

Bernhard Häussner bxt

View GitHub Profile
@bxt
bxt / senduit.py
Created February 27, 2011 12:32
Upload to senduit via python/curl/kde script
#!/usr/bin/python
import subprocess, re, sys
#get arguments
if len(sys.argv) < 3:
sys.exit("invalid arguments!")
upload_file = sys.argv[1]
#expire_time = "30 minutes"
@bxt
bxt / infinitemonkeys.sh
Created February 27, 2011 12:34
Fun-Script: Let "infinite monkeys" living in /dev/urandom type "burny"
echo "H4sIADroaE0AA0tOLFHQT0kt0y8tSsxLyc9VqFFISixONTMBMkqKFAwMjYxNTM3MLSwdnZxdXN3c
PTy9vH18/fwDAoOCQ0LDwiMio7RjEpNTUtPSMzKzsnNy8wsKi0vKyiuqFJSSSovyKhVIJZWANqcX
pRYAGTABLgCFrv6kpgAAAA==" | base64 -d | gunzip | sh
@bxt
bxt / twopassenc.sh
Created February 27, 2011 12:38
Encode frames saved in image files to 2-pass-mpeg4-compressed video
#!/bin/sh
# optimal_bitrate = 50 * 25 * width * height / 256
# credits: http://personal.cscs.ch/~mvalle/mencoder/mencoder.html
if [ $1 = "-h" ] ; then
echo "usage: twopassenc \"frames_run1/*.png\" output1.avi 1920 1200"
echo " [filname search string] [output file] [width] [height]"
else
bitrate=`(echo "50 * 25 * $3 * $4 / 256"|bc)`
echo "Using bitrate: $bitrate"
@bxt
bxt / clock.php
Created February 27, 2011 13:23
A PHP-CLI-Script displaying a digital clock
#!/usr/bin/php
<?php
// Do not execute this file through a web server...
// inspired by http://stackoverflow.com/questions/3324301/code-golf-digital-clock
// If you trim this down to match the task in this thread you get about 240 bytes
$parts=str_split(" | _ |_| _||_ | | . 152600134133620143142100122123677666",3);
echo PHP_EOL;
@bxt
bxt / numberconv.php
Created February 27, 2011 13:31
Examining various ways to convert a string to a number in PHP (cast, intval, *1)
<?php
$strs=array('1','10','10a10','a12','a','10E3','4.6','4,6','4%6');
foreach ($strs as $str) {
$int=(int)$str;
$by1=$str*1;
$iv=intval($str);
echo "$str\tint:\t$int\tby1:\t$by1\tintval:\t$iv\n";
}
@bxt
bxt / phpstringconcat.php
Created February 27, 2011 13:36
Examining echo String concat in PHP: echo a,b,c; vs. echo a.b.c;
function foo (){
echo "in \n";
return "bar \n";
}
echo "\nComma:\n";
echo foo (),foo (),foo ();
echo "\nDot:\n";
echo foo ().foo ().foo ();
echo "\n";
@bxt
bxt / .bashrc
Last active July 30, 2024 18:54
some stuff for .bashrc
# .bashrc commands by bxt
# color promt:
PS1="\@ \[\033[0;35m\]\u@\\h\[\033[0m\]:\w> "
# actually I sometimes use this one (shorter, 24h clock)
PS1=" \t \[\033[0;35m\]:\w>\[\033[0m\] "
# And when I use zsh I use:
PROMPT='%F{205}%~> %f'
@bxt
bxt / Profile.php
Created February 27, 2011 20:29 — forked from supernifty/profile.php
Ultra Simple PHP Profiler writing CSV files (OOP verision)
<?php
/**
* A simple class for tracking execution times of PHP scripts and logging them into CVS files
* @author Bernhard Häussner
* @see https://gist.github.com/846504
*/
class Profile {
private $_start = array();
private $_subdata = '';
@bxt
bxt / private_public_test.php
Created March 4, 2011 14:19
Difference between private and public visibility PHP keywords (illustrative example)
<?php
class A {
private $foo="a";
protected $bar="a";
function getAstuff() {
return $this->foo.'/'.$this->bar;
}
}
@bxt
bxt / php_lint_all.sh
Created March 6, 2011 17:09
Syntax check (lint) all php files in certain directory with one shell command line
find . -type f -iname "*.php" | xargs -n 1 php -l