Skip to content

Instantly share code, notes, and snippets.

View chernjie's full-sized avatar

CJ (curl | jq) chernjie

View GitHub Profile
@chernjie
chernjie / UnitTest-e8af5d1.php
Created December 6, 2012 04:52
Bug fix for relative directory removal
<?php
$examples = array(
'../' => ''
, '/../' => ''
, 'abc/../' => 'abc'
, '../def' => 'def'
, '/../def' => 'def'
, 'abc/../../def' => 'abc/def'
, 'abc../' => 'abc..'
@chernjie
chernjie / apache_request_headers.php
Last active December 16, 2015 07:19
apache_request_headers
<?php
print_r(apache_request_headers());
foreach ($_SERVER as $key => $val)
{
if (sscanf($key, 'HTTP_%s', $header) === 1)
{
// take SOME_HEADER and turn it into Some-Header
$header = str_replace('_', ' ', strtolower($header));
@chernjie
chernjie / eclipse
Created May 27, 2013 02:33
Open files in Eclipse via Command Line
#!/bin/bash
case $1 in
-clean|clean)
/Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse -clean
;;
*)
[ $# -gt 0 ] &&
FILES="$@" ||
while read _FILES
@chernjie
chernjie / gist:5765204
Last active December 18, 2015 09:59
SystemProperty_model
<?php
abstract class M3SystemProperty_model extends MY_Model
{
/**
* @var M3SystemProperty_model
*/
protected $system_property_api = null;
protected $system_property_cache = array('enabled'=>FALSE, 'expiry'=>300, 'driver'=>null);
protected static $GET_SYSTEM_PROPERTY = '/system/property/%s';
@chernjie
chernjie / command_installer
Last active December 27, 2015 08:49
find programme, if not found attempts to install
#!/bin/bash
function autoinst()
{
declare -a _list=()
for i
do
command -v "$i" > /dev/null || _list[${#_list[@]}]="$i"
done
test ${#_list[@]} -eq 0 && return
@chernjie
chernjie / sequelpro.sh
Created March 8, 2016 10:37
ssh script to overwrite ignoring of mutex on SequelPro > v1.1.0
#!/usr/bin/env bash
_log () {
echo $(date) $@ >> /var/log/sequelpro.log
}
for i do
case "$i"
in
-L\ *)
#!/usr/bin/env bash
_whack_a_mole_log=~/dotfiles/log/whack-a-mole.log
_whack_a_mole () {
printf $@:
while true
do
i=$(ps aux | grep $@ | grep -ve grep -ve whack-a-mole | awk '{print $2}')
@chernjie
chernjie / .gitignore
Last active June 10, 2016 06:14
hsg-door
success
@chernjie
chernjie / macsay.php
Last active October 25, 2016 13:17
Mac say in PHP
<?php
/**
* Declaring variables
*/
$output = array();
$return_var = null;
/**
* Get environment variables
@chernjie
chernjie / logrotate.d-docker
Created April 17, 2015 17:31
Logrotate docker logs, copy this file to /etc/logrotate.d/docker
/var/lib/docker/containers/*/*-json.log {
dateext
daily
rotate 365
compress
delaycompress
missingok
}