Skip to content

Instantly share code, notes, and snippets.

@kristm
kristm / hexcat
Created August 3, 2021 06:23
show hex color on terminal (or at least how the terminal wants to show it ^_^)
#!/bin/bash
usage="hexcat\nUsage $0 <hexcolor>"
#https://gist.github.com/mhulse/b11e568260fb8c3aa2a8
function fromhex() {
hex=$1
if [[ $hex == "#"* ]]; then
hex=$(echo $1 | awk '{print substr($0,2)}')
fi
#!/usr/bin/env ruby
require 'rubyXL'
require 'rubyXL/convenience_methods'
require 'csv'
def usage
puts "Contribution Summary\nUsage: #{$0} <username>"
end
#!/usr/bin/env ruby
require 'csv'
def usage
puts "s3_migrate.rb \nUsage: $0 <bucket_name> <input_csv>"
end
IMAGE = 0
ORG_ID = 2
@kristm
kristm / annoying.js
Created November 22, 2018 02:52
annoying site js
/* global Element */
/**
* The Annoying Site
* https://theannoyingsite.com
*
* Author:
* Feross Aboukhadijeh
* https://feross.org
*
@kristm
kristm / deps
Last active May 5, 2016 10:32
get deploy status in shell
function deps(){
curl $(cat ~/.staging-url) | awk -F '<td>|</td>' '{ if ($2 && $2 !~ /^[0-9]/) print $2 }' |
awk -F '<|>' '{if ($3) { print $3 } else { print $0 }}' |
awk '/^http/ { url=$0 } /^[a-z0-9\/_-]+$/ { branch=$0 }
/ago$/ { gsub(/about /, "");
match($0, /[0-9]+/); time=substr($0, RSTART, RLENGTH);
if($0 ~ /hour/) { mins=time * 60 }
else if ($0 ~ /day/) { mins=time * 60 * 24 }
else if ($0 ~ /month/ || $0 ~ /year/) { mins="48000" }
else if ($0 ~ /less than a minute/) { mins=0 }
@kristm
kristm / tailf
Last active December 23, 2022 00:00
tailf
#!/bin/bash
tail -f $1 | awk '/INFO/ {print "\033[32m" $0 "\033[39m"}
/SEVERE/ {print "\033[5m\033[31m\033[40m" $0 "\033[39m"}
/kernel|lsd/ {print "\033[36m" $0 "\033[39m"}
/login|(a|A)uth|accountsd|secd/ {print "\033[46m\033[34m" $0 "\033[39m"}
/networkd|sharingd|blued|watchdogd|cdpd|locationd/ {print "\033[92m" $0 "\033[39m"}
/imagent/ {print "\033[7m\033[92m" $0 "\033[39m"}
/Google/ {print "\033[43m\033[90m" $0 "\033[39m"}
/Error|spindump/ {print "\033[101m\033[30m" $0 "\033[39m"}
#!/bin/bash
if [ $# -lt 1 ]; then
echo -e "Usage: $0 <target process>"
exit
fi
target=`ps aux|grep pow|awk -v app="$1" '{ if($11 == app) { pid = $2 } } END { print pid }'`
if [ ! -z "$target" -a "$target" != " " ]; then
kill -9 $target
fi
@kristm
kristm / gist:3d26ba1a31860119e92b
Last active August 29, 2015 14:24
group in pairs
#get array of cities by
#Schools.where('XX').map(&:city).uniq.sort { |a,b| a.downcase <=> b.downcase }
def group_in_pairs (arr)
ra = []
skip = -1
arr.each_with_index do |a,i|
return ra if arr[i+1].nil?
next if skip > i
if (a.downcase == arr[i+1].downcase)
#!/bin/bash
if [ $# -lt 1 ]; then
echo -e "Usage:"
echo -e "$0 <csvfile>"
exit
fi
total=$(wc -l $1|awk '{ print $1 }')
inc=4999
@kristm
kristm / vimrc
Last active May 23, 2019 08:25
pure heroine
execute pathogen#infect()
filetype plugin indent on
filetype plugin on
syntax on
set clipboard=unnamed
"colorscheme desert "badwolf
"colorscheme gummybears
"colorscheme tokyo-metro
colorscheme pablo