Skip to content

Instantly share code, notes, and snippets.

View greyaperez's full-sized avatar

Grey Perez greyaperez

View GitHub Profile
@greyaperez
greyaperez / Get_Concrete_Type_of_Generic.java
Created February 27, 2014 03:49
Grab generic interfaces of a class by Class#getGenericInterfaces() which you then in turn check if it's a ParameterizedType and then grab the actual type arguments accordingly. .
// Interface
public interface FooBar<T> {
// ...
}
// Impl Class
public class BarFoo implements FooBar<Person> {
// ...
}
@greyaperez
greyaperez / ngrok-tunnel.sh
Created February 19, 2014 15:43
NGROK Tunnel, useful commands to run
// Initial Setup - Get AUTH TOKEN from ngrok.com (Run this once)
ngrok -authtoken {AUTH TOKEN} 80
// Run Ngrok on a specific Subdomain (Ex: local.ngrok.com)
ngrok -subdomain=local 8080
@greyaperez
greyaperez / tail_match_execute.sh
Created February 6, 2014 16:12
When Tailed Log matches a string, execute task.
tail -f logfile.log | while read LOGLINE
do
[[ "${LOGLINE}" == *"Server Started"* ]] && pkill -P $$ tail && {DO SOMETHING HERE}
done
@greyaperez
greyaperez / PDO-Simple_Example.php
Created January 20, 2014 16:45
Quick & Dirty PDO Usage to MySQL DB
$pdo = new PDO( 'mysql:dbname={DBNAME};host=localhost', $user, $pass );
@greyaperez
greyaperez / git_show_commit_hash.sh
Created January 17, 2014 15:10
Git - Show Current Commit Hash
git rev-parse HEAD
@greyaperez
greyaperez / composer_global_require.sh
Created January 13, 2014 02:44
Globally Install a Package
# Exec
composer global require '{APP PACKAGE}'
# Example
composer global require 'phpunit/phpunit=3.7.*'
@greyaperez
greyaperez / log.sh
Created December 16, 2013 17:04
Logging - with filtering
# Tail Files in Directory
# USAGE: $ log {arg1:file filter(opt)} {arg2:string filter(opt)}
function log (){
if [ $# -lt 1 ];
then
tail -f *
fi
if [ $# -gt 1 ];
then
@greyaperez
greyaperez / PostgreSQL_Commands.sql
Created December 10, 2013 19:25
Common/Important PostgreSQL Commands
# Common/Important Commands
# See Cheatsheet - http://www.postgresonline.com/downloads/special_feature/postgresql83_cheatsheet.pdf
# Admin
psql
\list lists all databases
\dt lists all tables in the current database
\q quit
@greyaperez
greyaperez / service_status_all.sh
Created December 10, 2013 18:52
Get status of all services.
service --status-all
@greyaperez
greyaperez / Most_Useful_Shell.sh
Created December 10, 2013 15:42
Some of the most useful bash/shell functions and aliases.
alias editbash='vim ~/.bashrc'
alias updatebash='source ~/.bashrc'
alias ls='ls -alC --color=auto'
function search (){
egrep -roiI $1 . | sort | uniq
}
function whereis (){
find . -name "$1*";