Skip to content

Instantly share code, notes, and snippets.

View clok's full-sized avatar
👾
I can do this all day.

Derek Smith clok

👾
I can do this all day.
View GitHub Profile
@clok
clok / color-picker.js
Created April 29, 2012 14:38
Hex Color Fade Picker Plugin for ImpactJS
ig.module(
'plugins.color-picker'
)
.requires(
)
.defines(function(){
/*
Initialize object with a default 10 color array fading from
White to Red and with a Tri-Color array from Green to Yellow
@clok
clok / lplm.sh
Last active October 7, 2015 15:57
list installed perl modules
#! /bin/bash
perl -MFile::Find=find -MFile::Spec::Functions -lw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'
@clok
clok / detect_monitor.sh
Created August 20, 2012 18:14
ubuntu switch monitors for laptop
disper -d auto -e
@clok
clok / add_sq
Created December 18, 2012 23:32
add single quote to xargs
grep -i ipad uas_head.log | sed 's/^/"/g' | sed 's/$/"/g' | tr '\n' ' ' | xargs /Users/derek.smith/dev/ds/scripts/parse.pl
@clok
clok / table_size_info.sql
Last active December 13, 2015 19:49
get the row, data, index and total size for all tables
# ALL Tables in ALL DBs
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 100;
@clok
clok / test
Created September 26, 2013 15:38
################# programming questions below #####################
1. convert this string
string = "{key:[[value_1, value_2],[value_3, value4]], 5:10:00AM]}"
to this Ruby hash:
h = {"key" => [["value_1", "value_2"],["value_3", "value4"]], 5=>"10:00AM"}
then convert h to json.
@clok
clok / git_svn_branch_in_cli.sh
Last active August 29, 2015 14:07
Add the working git/hg/svn branch to your CLI
# Add git branch to prompt
parse_git_branch () {
git branch 2> /dev/null | grep '\*' | sed 's#\* \(.*\)# (git::\1)#'
}
parse_svn_branch() {
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | awk '{print " (svn::"$1")" }'
}
parse_svn_url() {
svn info 2>/dev/null | sed -ne 's#^URL: ##p'
}
@clok
clok / slack_sidebar_themes.css
Last active August 29, 2015 14:11
slack_themes
/* Cyphr */
#1F2523,#000000,#08B381,#FFFFFF,#000000,#FFFFFF,#22DEA7,#08B381
/* Monokai */
#222222,#2F2F2F,#F92772,#FFFFFF,#A6E22D,#FFFFFF,#66D9EF,#BE84F2
/* Tron Legacy */
#000000,#000000,#1EB8EB,#000000,#1EB8EB,#FFFFFF,#1EB8EB,#1EB8EB
/* Black Out */
@clok
clok / useful.sql
Last active May 9, 2017 13:13
useful sql queries
# process list info
select id, user, db, host, command, state, time from INFORMATION_SCHEMA.PROCESSLIST;
# ALL Tables in ALL DBs
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
@clok
clok / useful.sh
Last active April 11, 2017 12:49
useful shell oneliners
#!/bin/bash
# List most recently modified files (will take time)
find $1 -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -20
# get file permissions for a file
perl -e 'printf "%o\n", (stat shift)[2]&07777' SOME-FILE
# Convert INT to IPv4
perl -MSocket=inet_ntoa -le "print inet_ntoa(pack(\"N\", shift))"