Skip to content

Instantly share code, notes, and snippets.

View Darkflib's full-sized avatar
🏠
The real problem is not whether machines think, but whether men do.

Mike Preston Darkflib

🏠
The real problem is not whether machines think, but whether men do.
View GitHub Profile
@Darkflib
Darkflib / keybase.md
Created June 15, 2014 15:18
keybase.md

Keybase proof

I hereby claim:

  • I am darkflib on github.
  • I am darkflib (https://keybase.io/darkflib) on keybase.
  • I have a public key whose fingerprint is CC8C 22D1 B95D 957A 59EE 7665 D5E5 F691 45F5 BBA2

To claim this, I am signing this object:

$id='1227feacf41c472e5ee34e20b510a240ad81ea6e';
echo 'id '.$id."\n";
$url = 'http://example.com/activity/pub?id='.$id;
echo 'url '.$url."\n";
$data = array( 'foo' => 'bar' );
$data_json = json_encode($data);
echo $data_json."\n";
@Darkflib
Darkflib / slack signup
Created July 12, 2015 10:36
Slack signup
<?php
//requires guzzle
require_once '../vendor/autoload.php';
$token='xoxp-3180528888-111111-98229-b4e1b7';
$email='darkflib@example.com';
$teamname='example';
$url="https://${teamname}.slack.com/api/users.admin.invite";
@Darkflib
Darkflib / subscribe.php
Created December 16, 2011 09:07
redis subscribe in php
<?php
//just making a note of this here for later use...
//subscribe.php
function f($redis, $chan, $msg) {
switch($chan) {
case 'chan-1':
print "get $msg from $chan\n";
break;
case 'chan-2':
@Darkflib
Darkflib / gist:1487788
Created December 16, 2011 20:20
plugins in php
<?php
print_r($_SERVER);
define('PLUGINDIR','./plugin.d/');
foreach (glob(PLUGINDIR."*.php") as $filename) {
require_once($filename);
$basename=substr($filename,strlen(PLUGINDIR),-4);
$funcname='plugin_'.$basename;
$result[$basename]=$funcname();
}
@Darkflib
Darkflib / gist:1490701
Created December 17, 2011 16:53
Task Queues in redis
Rough concept is as follows.
Setup 4 lists for each queue.
for a queue 'foobar'
'queue:foobar:low'
'queue:foobar:medium'
'queue:foobar:high'
'queue:foobar:run_at'
and optionally 'queue:foobar:failed'
@Darkflib
Darkflib / gist:1884523
Created February 22, 2012 12:03
Setting up ssh keys
<h3>Generating the keys</h3>
<p>Generating the key isn't difficult.</p>
<code>
[root@server1 ~]# <b>ssh-keygen</b>
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): <b>test_key</b>
Enter passphrase (empty for no passphrase): <b>my passphrase</b>
Enter same passphrase again:<b>my passphrase</b>
@Darkflib
Darkflib / example output
Created October 2, 2012 07:15
GeoIP example.
teamplayr.com:
This host is located in: NA
This host is located in: US
Array
(
[continent_code] => NA
[country_code] => US
[country_code3] => USA
[country_name] => United States
[region] => TX
@Darkflib
Darkflib / twitstream.php
Created October 2, 2012 07:20
Twitter to syslog streamer
<?php
/*
This has been used for testing a logstash install and searching infrastructure. It is a quick and dirty implementation of the twitter streaming api. A better way would be to do it with curl with callback handlers. Normal curl wont work as the stream doesn't have a proper end.
*/
set_time_limit(0);
$query_data = array('track' => '#devops', 'stall_warnings' => 'true');
$user = 'twitteraccount'; // replace with your account
@Darkflib
Darkflib / geoip-package.sh
Created October 7, 2012 20:32
Packaging GeoIP
#!/bin/bash
#### Edit the paths to suit your environment.
mkdir /tmp/geoip
cd /tmp/geoip/
rm -f *.dat
wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gzip -d - < GeoIP.dat.gz > GeoIP.dat