Skip to content

Instantly share code, notes, and snippets.

View lca.php
<?php
error_reporting(E_ALL ^ E_NOTICE);
function findLCA( $root, $a, $b)
{
// no root no LCA.
if (!$root) {
return null;
}
@heskyji
heskyji / hmac_sha1.py
Created Sep 17, 2015
Generate HMAC-SHA1 Signature using Python 3
View hmac_sha1.py
import hashlib
import hmac
import base64
def make_digest(message, key):
key = bytes(key, 'UTF-8')
message = bytes(message, 'UTF-8')
@heskyji
heskyji / ttfb.sh
Last active Mar 29, 2017 — forked from chrisiona/ttfb.sh
TTFB – Bash script that returns interesting information about a HTTP/S call
View ttfb.sh
#!/bin/bash
# Returns interesting information about a HTTP/S call
# http://chrisiona.com/post/125309997618/ttfb-a-bash-script-that-returns-interesting
curl -so /dev/null \
-w "%{http_code}\tPre-Transfer: %{time_pretransfer}\tStart Transfer: %{time_starttransfer}\tTotal: %{time_total}\tSize: %{size_download}\n" \
$1
echo ""
@heskyji
heskyji / pecl-memcached.sh
Last active Sep 24, 2015 — forked from paul91/pecl-memcached.sh
How to install php memcached on CentOS 6.5
View pecl-memcached.sh
#!/bin/bash
# How to install PHP memcached on CentOS 6.5
# Install dependencies
yum install cyrus-sasl-devel zlib-devel gcc-c++
# Get the latest libmemcached
wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
tar -xvf libmemcached-1.0.16.tar.gz
View duplicate_dynamodb_table.py
from boto.dynamodb2.exceptions import ValidationException
from boto.dynamodb2.fields import HashKey, RangeKey
from boto.dynamodb2.layer1 import DynamoDBConnection
from boto.dynamodb2.table import Table
from boto.exception import JSONResponseError
from time import sleep
import sys
if len(sys.argv) != 3:
print 'Usage: %s <source_table_name> <destination_table_name>' % sys.argv[0]
View duplicate_dynamodb_table.py
from boto.dynamodb2.exceptions import ValidationException
from boto.dynamodb2.fields import HashKey, RangeKey
from boto.dynamodb2.layer1 import DynamoDBConnection
from boto.dynamodb2.table import Table
from boto.exception import JSONResponseError
from time import sleep
import sys
if len(sys.argv) != 3:
print 'Usage: %s <source_table_name> <destination_table_name>' % sys.argv[0]
View find_iam_user.py
#!/usr/bin/env python
# Find the IAM username belonging to the TARGET_ACCESS_KEY
# Requirements:
#
# Environmental variables:
# AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
# python:
# boto
@heskyji
heskyji / gist:c44d19739a2bd554fcee
Last active Aug 29, 2015
install gem using puppet package
View gist:c44d19739a2bd554fcee
package {
'jekyll':
ensure => installed,
provider => gem,
require => [
Anyenv::Env::Install["anyenv_deploy_rbenv_${ruby_version}"],
Anyenv::Env::Default["anyenv_deploy_rbenv_default_${ruby_version}"],
];
'rouge':
ensure => installed,