Skip to content

Instantly share code, notes, and snippets.

View chernjie's full-sized avatar

CJ (curl | jq) chernjie

View GitHub Profile
@chernjie
chernjie / varDebugPdoMysqlLog.php
Last active August 29, 2015 14:01
Magento var/debug/pdo_mysql.log SQL Statement Parser
<?php
class varDebugPdoMysqlLog
{
private $_fileName = 'var/debug/pdo_mysql.log.newdesign';
private $_filterKeys = array('datetime', 'pid', 'type', 'SQL', 'BIND', 'AFF', 'TIME');
// private $_filterKeys = array('type', 'SQL', 'BIND');
private $_skipTables = array(
'admin_user'
, 'eav_entity_store'
@chernjie
chernjie / splitLogFileByDate.sh
Last active August 29, 2015 14:03
Split log file by date
#!/bin/bash
function breakup()
{
LAST=$(wc -l "$1" | xargs | cut -d' ' -f1)
LAST=$(($LAST + 1))
grep -no ^201.-..-.. "$1" | sort -u -t: -k2 | sort -t: -rnk1 | while read j
do
DATE=$(echo $j | cut -d: -f2)
LINE=$(echo $j | cut -d: -f1)
<?php
$handle = fopen($argv[1], 'r');
$handle || exit('no readable file');
$handles = array();
while (($line = fgets($handle)) !== false)
{
if (preg_match('/^201.-..-../', $line, $match))
#!/usr/bin/env bash
use() {
for i do
if ! command -v $i > /dev/null
then
echo command $i not found
exit 1
fi
done
#!/usr/bin/env bash
_usage () {
echo Cherry pick merge commits >&2
exit 1
}
_error () {
echo "$@" >&2
exit 1
@chernjie
chernjie / paypal-payout.sh
Last active August 29, 2015 14:22
HackerspaceSG membership payment via PayPal Rest API
#!/usr/bin/env bash
##
# Update your configuration here
# You may get your `client_id` and `client_secret` from developer.paypal.com
# For membership level, please refer to http://hackerspace.sg/membership
##
endpoint=api.paypal.com
client_id=$client_id

git-gh-setup


This scripts will find all github remotes in the current repository and add a new configuration that allows you to fetch pull request heads and merge-heads

+refs/pull/*/head
+refs/pull/*/merge

Example:

#!/usr/bin/env bash
# Set the following SSH configurations to no:
# ChallengeResponseAuthentication
# PasswordAuthentication
# UsePAM
test -f /etc/ssh/sshd_config || exit 1
sed -i -r -e \
#!/usr/bin/env bash
function _usage()
{
echo "$0 [php53|php54|php55|php56]"
}
function phpversion()
{
local _VERSION=$1
#!/usr/bin/env bash
variable_name="$1"
shift
while read "$variable_name"
do
eval "$(echo "$@" | sed s/"$variable_name"/'"'\$"$variable_name"'"'/g)"
done