Skip to content

Instantly share code, notes, and snippets.

View tobiassjosten's full-sized avatar

Tobias Sjösten tobiassjosten

View GitHub Profile
#!/usr/bin/env bash
#
# drupal-cron - a shell script for running cron.php on Drupal installations.
SITES=$(grep -r 'ServerName' /etc/apache2/sites-enabled/)
for site in $SITES ; do
if [[ "$site" == ServerName || "$site" =~ /etc/apache2/sites-enabled/* ]]; then
continue
fi
site=$(expr match "$site" '\([^:]*\)');
# Count the number of lines in the files of a directory
find * -type f -print0 | xargs -0 wc -l | grep total | awk '{print $1}'
#!/bin/bash
# Expand globs to null when there are no matches
shopt -s nullglob
# Look for either a '<subdir>/console' or a 'symfony' file
until
file=(*/console symfony); [[ -f "$file" ]] && php "$file" "$@" && exit;
do
[[ "$PWD" == "/" ]] && break;
<?php
// $ php -f tostring_helper_benchmark.php
// 0.877526044846 <- Arrays are slooow
// First: 0.352955102921
// Second: 0.354468107224 <- substr() way takes a .0015s penalty
$time = microtime(true);
$html=array();
for ($i=1; $i<1000000; $i++)
#!/bin/bash
###############################################################################
## INITIALIZATION
if [ $(whoami) != "root" ]; then
echo "[*] You must be root to run this setup script!"
exit
fi
<?php
function a(array $a) {}
for ($i = 1; $i < 1000000; $i++) @a('');
var mongodb = require('mongodb');
var Db = mongodb.Db;
var Server = mongodb.Server;
module.exports = Database;
function Database(database_name, host, port) {
this.client = new Db(database_name, new Server(host, port, {}));
this.find = function(collection_name, params, callback) {
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin name="TargetingExample" author="Tobias Sjösten" id="a808c24b99bfdb45e4560e48" language="Lua" purpose="A targeting example plugin" save_state="y" date_written="2007-08-21 16:54:48" version="1.0">
<description trim="y">This example plugin shows how targeting can be done, using MUSHclient aliases and Lua variables.</description>
</plugin>
<?php
require('pathing.php');
$gmap = array(
array(6, 5, 6, 4, 6, 1, 2, 6, 9, 6, 6, 5, 6, 4, 6, 1, 2, 6, 9, 6),
array(8, 5, 3, 2, 9, 9, 3, 2, 4, 7, 8, 5, 3, 2, 9, 9, 3, 2, 4, 7),
array(4, 8, 7, 7, 3, 5, 2, 8, 3, 5, 4, 8, 7, 7, 3, 5, 2, 8, 3, 5),
array(7, 5, 5, 8, 7, 7, 8, 4, 8, 5, 7, 5, 5, 8, 7, 7, 8, 4, 8, 5),
array(4, 5, 1, 6, 4, 6, 9, 3, 8, 1, 4, 5, 1, 6, 4, 6, 9, 3, 8, 1),
<?php
/*
* This file is part of the sfImageTransform package.
* (c) 2007 Stuart Lowes <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**