Skip to content

Instantly share code, notes, and snippets.

View fijimunkii's full-sized avatar
🦁
𐂃͠

Harrison Powers fijimunkii

🦁
𐂃͠
View GitHub Profile
@fijimunkii
fijimunkii / ubuntu_ruby_install.sh
Created March 6, 2014 02:12
sh: ubuntu ruby install
#!/bin/bash
# Install rbenv
# https://github.com/sstephenson/rbenv
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bash_profile
echo 'eval "$(rbenv init -)"' >> .bash_profile
@fijimunkii
fijimunkii / .zshrc | .bashrc | .bash_profile
Last active August 29, 2015 13:57
sh: pianobar config
function lyrics
{
sh ~/.config/pianobar/lyrics.sh
}
@fijimunkii
fijimunkii / number-format.js
Last active August 29, 2015 13:57
js: convert big numbers to abbreviations
function format_number(n) {
if (n < 1000) {
// Anything less than a thousand
return parseInt(n);
} else if (n < 1000000) {
// Anything less than a million
return (parseInt(n / 1000) + 'K');
} else if (n < 1000000000) {
@fijimunkii
fijimunkii / osx_dashboard_disable.sh
Created March 23, 2014 20:39
sh: disable the osx dashboard
defaults write com.apple.dashboard mcx-disabled -boolean NO
@fijimunkii
fijimunkii / diff_alternatives.sh
Created March 23, 2014 22:34
sh: diff alternatives
comm -13 <(sort file1) <(sort file2) > file3
grep -Fxvf file1 file2 > file3
diff file1 file2 | grep "<" | sed 's/^<//g' > file3
join -v 2 <(sort file1) <(sort file2) > file3
@fijimunkii
fijimunkii / ruby_logger_format.rb
Created March 24, 2014 23:05
ruby: custom logger
class CustomFormater < Logger::Formatter
def call(severity, time, progname, msg)
# msg2str is the internal helper that handles different msgs correctly
"#{time} - #{msg2str(msg)}"
end
end
@fijimunkii
fijimunkii / ruby_error_reporting.rb
Last active August 29, 2015 13:57
ruby: error logging
$logfile = File.join(__dir__, '../.log')
$logger = Logger.new($stdout).tap { |log| log.progname = 'MISBEHAVING APP' }
begin
# SSL Stuff
rescue => e
$logger.error e
$logger.error "Check the log file => #{$logfile}"
open($logfile, 'a') do |it|
@fijimunkii
fijimunkii / berks_chef-rbenv_installer.sh
Last active August 29, 2015 13:57
vagrant: adds latest rbenv to berksfile
repo="fnichol/chef-rbenv"
latest_release=$(curl -s https://api.github.com/repos/$repo/git/refs/tags \
| ruby -rjson -e '
j = JSON.parse(STDIN.read);
puts j.map { |t| t["ref"].split("/").last }.sort.last
')
cat >> Berksfile <<END_OF_BERKSFILE
cookbook 'rbenv',
:git => 'git://github.com/$repo.git', :branch => '$latest_release'
@fijimunkii
fijimunkii / sql_parse_and_geocode.rb
Created March 28, 2014 21:48
ruby: parse csv and get coordinates of addresses
require 'csv'
require 'geocoder'
csv_dir = File.join(__dir__, 'csv/*.csv')
Geocoder.configure(:always_raise => [Geocoder::OverQueryLimitError])
CSV::Converters[:quotes] = lambda{|s|
begin
return '' if s.to_s.empty?

Keybase proof

I hereby claim:

  • I am fijimunkii on github.
  • I am harrisonpowers (https://keybase.io/harrisonpowers) on keybase.
  • I have a public key whose fingerprint is 0308 0282 C2D8 FE6B 45E4 1BC8 27B1 21E8 32E8 2D76

To claim this, I am signing this object: