Skip to content

Instantly share code, notes, and snippets.

View davidreuss's full-sized avatar

David Reuss davidreuss

View GitHub Profile
@davidreuss
davidreuss / useful bashisms
Created July 10, 2009 11:46
useful bashisms
#!/bin/bash
# Default variable if not set
[ -z "${var:-}" ] && var="Default..."
echo "$var"
# array declaration
<?php
$contents = file_get_contents('http://nod123.cn/');
preg_match_all('/username:\s?([A-Za-z0-9-]+)/i', $contents, $usernames);
preg_match_all('/password:\s?([A-Za-z0-9-]+)/i', $contents, $passwords);
foreach ($usernames[1] as $key => $username) {
if (isset($passwords[1][$key])) {
printf("%s:%s\n", $username, $passwords[1][$key]);
}
}
?>
<?php
class Collection extends SplObjectStorage {
public function __construct($mixed = array()) {
if ($mixed) {
$this->add($mixed);
}
}
public function add($mixed) {
sandbox.git
test-project.git
@davidreuss
davidreuss / zend_layout_nested_layouts_patch.diff
Created October 4, 2009 16:34
Patch to get nested layouts with Zend_Layout
diff --git a/Layout.php b/Layout.php
index 46de129..bfd5ded 100644
--- a/Layout.php
+++ b/Layout.php
@@ -29,6 +29,25 @@
*/
class Zend_Layout
{
+
+ /**
<?php
class Zend_View_Helper_AddLayout {
protected $_plugin;
public function __construct() {
$this->_getPlugin();
}
protected function _getPlugin() {
@davidreuss
davidreuss / git-stats-simple.sh
Created October 24, 2009 00:31
creates line-based stats by author for a git project
git ls-files | while read f; do git blame -M -- "$f"; done | perl -pe 's/^\^?[a-f0-9]*(?:[^(]* )?\((.*?) +200.*/$1/' | sort | uniq -c | sort -n | tee stats; perl -ne '$s += $1 if /(\d+)/; END{print "$s\n"}' < stats
@admins = one two three
@users = five six @admins
@admin = project1 project2
repo @admin
RW = @users
#!/bin/bash
username=""
password=""
firstbytes=5000
lastbytes=5000
cookie="rapidshare.cookie"
curl -s -k -c "$cookie" -d "login="$username"&password="$password"" https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi &> /dev/null
@davidreuss
davidreuss / tv_dir_cleanup.sh
Created February 6, 2010 18:07
script for cleaning up files in download directory
#!/bin/zsh
[ -z "$1" ] && {
echo "What directory do you want me to look in?"
exit 1
}
[ -d "$1" ] || {
echo "'$1' doesn't look like a directory"
exit 1