Skip to content

Instantly share code, notes, and snippets.

@mlconnor
mlconnor / duration.php
Created June 20, 2012 16:02
Creates a nice duration given a number of seconds. For example, 1h 28m
function nice_duration($seconds, $maxFragments = 0) {
// Define time periods
$periods = array (
'y' => 31556926,
'mo' => 2629743,
'wks' => 604800,
'd' => 86400,
'h' => 3600,
'm' => 60,
's' => 1
@mlconnor
mlconnor / walk_array.php
Created June 25, 2012 17:19
php function to walk an array/object recursively
/**
* works for json objects. will replace all
* keys and values with the result of the
* closure.
*/
function walk_recursive($obj, $closure) {
if ( is_object($obj) ) {
$newObj = new stdClass();
foreach ($obj as $property => $value) {
$newProperty = $closure($property);
@mlconnor
mlconnor / solr.sh
Created August 1, 2012 19:29
Prepare Solr 3.6.1 for Nutch 1.5
# this site has a good install writeup with custom weighting handler
# https://sites.google.com/site/profileswapnilkulkarni/tech-talk/howtoinstallnutchandsolronubuntu1004
# grab the solr src
curl -o solr-3.6.1.tgz http://apache.ziply.com/lucene/solr/3.6.1/apache-solr-3.6.1-src.tgz
# untar the beast
tar xfvz solr-3.6.1.tgz
cd apache-solr*
@mlconnor
mlconnor / apps.json
Created September 18, 2012 20:19
Wappalyzer JSON compliant file
{
"categories":{
"1":"cms",
"2":"message-boards",
"3":"database-managers",
"4":"documentation-tools",
"5":"widgets",
"6":"web-shops",
"7":"photo-galleries",
"8":"wikis",
@mlconnor
mlconnor / convert_apps_js.php
Created September 19, 2012 12:34
Convert apps.js from Wappaylzer into valid JSON
<?php
/**
* Read apps.js from stdin and write out valid JSON to stdout
*/
$wappalyzerJs = readfile('php://input');
$handle = fopen('php://stdin', 'r');
$wappalyzerJs = '';
while(!feof($handle)) {
@mlconnor
mlconnor / VCLExampleTemplateWordpressNopurge.vcl
Created September 24, 2012 16:34
Example Varnish vcl file for WordPress 3 instance without a purging plug-in
# Found this template here... https://www.varnish-cache.org/trac/wiki/VCLExampleTemplateWordpressNopurge
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
if (req.http.Accept-Encoding) {
#revisit this list
@mlconnor
mlconnor / selenium_links.php
Last active June 18, 2018 13:47
Get all links with Selenium in PHP
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Node.js server, cfn-create-stack NODEJS --capabilities CAPABILITY_IAM --parameters KeyName=KO_Keypair;InstanceType=m1.small;SecurityGroupName=default --disable-rollback --template-file nodeform.js",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access",
"Type" : "String"
},
@mlconnor
mlconnor / nodenotes.txt
Last active December 9, 2015 22:58
Node notes
# my node AMI - IMAGE ami-bcccb2d5
on beanstalk, you can see node logs at /var/log/nodejs/nodejs.log
on beanstalk, if you proxy via nginx, check those logs here /var/log/nginx/error.log
proper way to make a mod to a repo and grab it with npm (http://debuggable.com/posts/how-to-fork-patch-npm-modules:4e2eb9f3-e584-44be-b1a9-3db7cbdd56cb)
Fork the project on GitHub
Clone the fork to your machine
Fix the bug or add the feature you want
@mlconnor
mlconnor / testgeo.html
Created December 31, 2012 18:23
A diagnostic for GPS on the iPhone. Should theoretically work for other devices too.
<html>
<head>
<title>Test Browser Location 2.1</title>
</head>
<style>
body {
font-family:Verdana,Arial,Helvetica;
font-size:12px;
}
#map {