Skip to content

Instantly share code, notes, and snippets.

@jimbojsb
jimbojsb / gist:5df104147704c1d96302
Last active August 29, 2015 14:09
Mysql has gone away
public function processJob($job)
{
try {
// stuff
} catch(Exception $e) {
if(Offers\Model::getDb()->errno() == 2006) {
Offers\Model::connectDb();
$this->processJob($job);
} else {
throw $e;
@ikwattro
ikwattro / bash.sh
Last active August 29, 2015 14:21
Simple sed script to deactivate neo4j auth
#!bin/bash
sed -i.bak 's/^\(dbms\.security\.auth_enabled=\).*/\1false/' ./conf/neo4j-server.properties
@ikwattro
ikwattro / transform.php
Created May 16, 2015 22:14
From NeoClient to Vis.js
$q = 'MATCH (n) OPTIONAL MATCH (n)-[r]-() RETURN r,n';
$result = $neoclient->sendCypherQuery($q)->getResult();
$graph = [];
foreach ($result->getNodes() as $node) {
$graph['nodes'][] = [
'id' => $node->getId(),
'label' => $node->getLabels()[0],
'group' => $node->getLabels()[0],
'properties' => $node->getProperties()
@elazar
elazar / phpunit-log-junit.php
Created May 25, 2012 23:43
PHPUnit --log-junit processor
<?php
/**
* This script is used to process the output of a PHPUnit test run
* that uses --log-junit for the purposes of timing each executed
* test method. It outputs test methods with their respective
* runtimes in order from largest to smallest. Times are in
* seconds. The script accepts paths to any number of files in the
* JUnit log format.
*
* Ex: php phpunit-log-junit.php /path/to/junit-log1.xml /path/to/junit-log2.xml ...
@jbrooksuk
jbrooksuk / head.html
Created January 5, 2013 19:03
Open graph tags used in my Octopress blog.
<!-- Rich Object stuff -->
<meta property="og:url" value="{{ site.url }}{{ page.url }}">
<meta property="og:type" content="website" />
{% if page.title %}<meta property="og:title" value="{% if page.title %}{{ page.title }}{% endif %}">
<meta property="og:description" value="{% if page.description %}{{ page.description }}{% else %}{{site.description}}{% endif %}">
{% else %}<meta property="og:title" value="{{ site.title }}">
<meta property="og:description" value="{{ description }}">
{% endif %}{% if page.cover %}<meta property="og:image" value="{{ site.url }}{{ page.cover }}">{% endif %}
@briandailey
briandailey / .bashrc
Created June 25, 2013 13:57
phpargs function - add to bashrc
function phpargs() {
curl -s http://us3.php.net/$1 | \
sed -n '/<div class="methodsynopsis dc-description">/,/<\/div>/p' | \
sed 's/<[^>]*>//g' | tr -d "\n"
echo
}
@ewingd
ewingd / facepalm_for_loop.php
Last active December 21, 2015 21:08
facepalm for loop
<?php
// Before (this was repeated 3 times in one script, copy and pasted exactly...)
for($i=0,$btotal=0,$total=0,$page=1;$lclass=$row['class'],$lwhse=$row['whse'],$row=mysql_fetch_array($res);$i++,$total+=$row['cost'],$btotal+=$row['cost'],$gtotal+=$row['cost']) {
// ...snip.. 35 lines of echo statements dumping HTML
}
// Removing all the unused variables reduced it down to:
for ($i = 0; $row = mysql_fetch_array($res); $i++) {
// Same 35 lines of echo statements dumping HTML
@feulf
feulf / gist:8408501
Created January 13, 2014 21:27
tmux configuration
# Mouse support
setw -g mode-mouse on
set-option -g mouse-select-pane on
set-option -g mouse-select-window on
set -g mouse-resize-pane on
set -g mouse-select-window on
# tmux vi mode
setw -g mode-keys vi
@dragonmantank
dragonmantank / gist:6723460
Last active January 21, 2016 17:39
Reset Apache httpd to run as the vagrant user
exec { "change_httpd_user":
command => "sed -i 's/www-data/vagrant/g' /etc/apache2/envvars",
onlyif => "/bin/grep -q 'www-data' '/etc/apache2/envvars'",
notify => Service['apache2'],
require => Package['apache2'],
}
file { "/var/lock/apache2":
ensure => "directory",
owner => "vagrant",
@bradmontgomery
bradmontgomery / shell.sh
Created February 9, 2014 05:22
Playing with `jq`, using the Albums api for a Facebook page. This is loosely based on the tutorial at: http://stedolan.github.io/jq/tutorial/
# pretty-print a JSON result
curl 'https://graph.facebook.com/memphispython/albums/' | jq '.'
# grab the data list
curl 'https://graph.facebook.com/memphispython/albums/' | jq '.data'
# Get *just* the first album
curl 'https://graph.facebook.com/memphispython/albums/' | jq '.data[0]'
# Narrow that first entry to some specific data