Skip to content

Instantly share code, notes, and snippets.

View kristianfreeman's full-sized avatar
🙃

Kristian Freeman kristianfreeman

🙃
View GitHub Profile
require 'date'
require 'time'
dates = File.open('dates.txt')
csv_array = Array.new
dates.readlines.each_with_index do |line, i|
next if i == 0
t = Time.parse(line)
fixed_date = t.strftime("%F")
@kristianfreeman
kristianfreeman / .tmux.conf
Created December 9, 2012 07:26 — forked from fholgado/.tmux.conf
Show iTunes current track/song in tmux
# Custom status bar
# # Powerline symbols: ⮂ ⮃ ⮀ ⮁ ⭤
set -g status-left-length 32
set -g status-right-length 150
set -g status-interval 5
set -g status-left '#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour234,nobold]⮀'
set -g status-right '#[fg=colour245]⮃ %R ⮃ %d %b #[fg=colour254,bg=colour234,nobold]#(~/Documents/AppleScripts/itunes-current-track-tmux.sh)⮂#[fg=colour16,bg=colour254,bold] #h '
# set -g status-right '#(~/Documents/AppleScripts/itunes-current-track-tmux.sh)'
set -g window-status-format "#[fg=white,bg=colour234] #I #W "
set -g window-status-current-format "#[fg=colour234,bg=colour39]⮀#[fg=colour16,g=colour39,noreverse,bold] #I ⮁ #W #[fg=colour39,bg=colour234,nobold]⮀"
@kristianfreeman
kristianfreeman / lastfm.rb
Last active December 10, 2015 17:58
Wrap the lastexport tool and make nice things with it
#!/usr/bin/env ruby
require 'choice'
USERNAME = 'kristianfr'
# Get some command-line arguments (or one)
Choice.options do
option :export, :required => true do
short '-e'

An edited version for usage with Last.fm data.

Bubble charts encode data in the area of circles. Although less perceptually-accurate than bar charts, they can pack hundreds of values into a small space. Implementation based on work by Jeff Heer. Data shows the Flare class hierarchy, also courtesy Jeff Heer.

@kristianfreeman
kristianfreeman / rdio.applescript
Created January 26, 2013 19:32
Rdio now playing - nice in TextExpander
tell application "Rdio"
if player state is playing then
set the_string to "\"" & name of current track & "\""
if artist of current track is not "" then
set the_string to the_string & " - " & artist of current track
end if
if album of current track is "" then
set the_string to the_string
else if album of current track is not "" then
set the_string to "*" & "♫ " & the_string & " (" & album of current track & ")" & "*"
@kristianfreeman
kristianfreeman / show.sh
Last active December 15, 2015 11:59
Bash script to show the first couple lines of every file based on extension
# Usage: `show rb`, `show php`, `show txt`
function show {
head -3 *.$1
}
@kristianfreeman
kristianfreeman / gpg.md
Last active August 31, 2022 18:46
what is a gpg key?

(taken from http://aplawrence.com/Basics/gpg.html, hosted on gist for safety)

Recently someone asked me for a GPG or PGP public key so that they could send some sensitive material to me by email. I understood what they meant, but inwardly I groaned because I've just never had any reason to use public key encryption, and had no idea how to create the key or decrypt what would be sent back to me. Looking at "man bgp" on my Linux box didn't make me feel any better, and a Google search for gpg docs didn't immediately turn up anything that wasn't techno gobbledy-dee-geek. Eventually (after I had figured out the basics by trial and error), I did find GNU Privacy Guard HandBook, which probably would have gotten me up to speed a little faster, but which still was more than I needed to know at the moment. This, therefore, is a quick introduction so that you don't have to get a headache from the man page as I did. After learning what is presented here, you can visit the GNU page for more in depth coverage. Public key,

class User < ActiveRecord::Base
at_most(5)
end
>> 5.times do User.create!; end
>> User.create!
=> ActiveRecord::RecordInvalid: Validation failed: The maximum number of users has
been reached.
class User < ActiveRecord::Base
at_most(5, { message: "Sorry, all our spots are full!" })
end