Skip to content

Instantly share code, notes, and snippets.

@chx
chx / x.php
Created July 7, 2012 09:05
Dummy filter
<?php
class DummyFilter extends PHP_User_Filter
{
private $_data;
/* Called when the filter is initialized */
function onCreate( )
{
@chx
chx / gist:3067643
Created July 7, 2012 18:50
APC stat=0 and I mean it.
Index: apc.c
===================================================================
--- apc.c (revision 326528)
+++ apc.c (working copy)
@@ -34,6 +34,7 @@
#include "apc.h"
#include "apc_zend.h"
#include "apc_cache.h"
+#include "apc_globals.h"
#include "php.h"
@chx
chx / gist:3172060
Created July 24, 2012 19:23
nput FALSE, NULL
if (!isset($input)) {
if (!empty($element['#default_value'])) {
$element['#needs_validation'] = TRUE;
}
$element['#has_garbage_value'] = TRUE;
}
if ($input === FALSE && !isset($element['#default_value']))) {
$element['#has_garbage_value'] = TRUE;
}
@chx
chx / gist:3930812
Created October 22, 2012 10:27
Batch proof of concept
<?php
use Symfony\Component\HttpFoundation\JsonResponse;
function btest_menu() {
$items['btest'] = array(
'type' => MENU_CALLBACK,
'access callback' => TRUE,
'page callback' => 'btest_page',
);
@chx
chx / packer.php
Created October 26, 2012 21:53
Bin packing on the master
<?php
$dir = getcwd();
foreach (file('/usr/local/etc/baseline.csv') as $row) {
list($k, $v) = explode(',', trim($row));
$a[$k] = (int)$v;
}
$a = array_reverse($a);
$bins[] = array('sum' => 0, 'data' => array());
foreach ($a as $name => $time) {
@chx
chx / .rtorrent.rc
Created October 29, 2012 23:35
rtorrent setup on slave
system.method.set_key = event.download.finished,done,"execute=/usr/local/bin/run.sh,$d.get_name=;d.set_directory=/var/www"
schedule = watch_directory,1,1,load_start=/root/torrent/watch/*.torrent
@chx
chx / create.php
Created October 29, 2012 23:45
php script to create the server
<?php
require('rackspace.inc');
$conn = new OpenCloud\Rackspace(
'https://identity.api.rackspacecloud.com/v2.0/',
array(
'username' => '',
'apiKey' => '',
'tenantName' => 'this is your account number'
));
$compute = $conn->Compute('cloudServersOpenStack', 'DFW', 'publicURL');
@chx
chx / blast
Created November 2, 2012 02:09
Initiate test
cd /tmp/serverlist
for i in * ; do scp /var/www/$1.torrent $i:torrent/watch/ ; done
@chx
chx / ConfigMetadata.php
Created December 19, 2012 10:08
Start of ConfigMetadata
<?php
namespace Drupal\Core\Config;
class ConfigMetadata {
/**
* @var \Drupal\Core\Config\Config
*/
protected $config;
while read -r project
do
output=`drush dl --dev -y -q --destination=allmodules --package-handler=git_drupalorg $project`
if [ -z "$output"]
then
output=`drush dl --dev -y -q --destination=allmodules --default-major=6 --package-handler=git_drupalorg $project`
if [ -z "$output"] ; then echo 'module sucks; fi
fi
done < allmodules.txt