Skip to content

Instantly share code, notes, and snippets.

View kristianfreeman's full-sized avatar
🙃

Kristian Freeman kristianfreeman

🙃
View GitHub Profile
//
// emojis.h
// NSStringEmojize
//
// Created by Andrew Sliwinski on 1/6/14.
// Copyright (c) 2014 DIY. All rights reserved.
//
#define EMOJI_HASH @{ \
@":+1:" : @"\U0001F44D", \
@kristianfreeman
kristianfreeman / lol.rb
Created January 15, 2014 01:41
imessage is garbage
# run this shit in ~/Library/Messages
@last = ""
while true do
@mine = false
@new = `sqlite3 chat.db 'select text, is_from_me from message order by date desc limit 1;'`
@from = @new.split("|").last.chomp
@mine = true if @from == "1"
@new = @new.split("|").first
unless @last == @new.split("|").first
class Fixnum
def double
self * 2
end
end
nmux() {
current=$(echo $(basename $(pwd)))
tmux new -s $current
}
@kristianfreeman
kristianfreeman / nginx.conf
Created November 23, 2013 21:06
nginx.conf with HTTPS
server {
listen 80;
server_name MYURL.com;
return 301 https://$host$request_uri;
}
server {
# Static Site
listen 443 ssl;
server_name MYURL.com;
@kristianfreeman
kristianfreeman / gist:7282881
Created November 2, 2013 20:01
jekyll deploy
HOME=/home/user
GIT_REPO=$HOME/bare_repo
TMP_GIT_CLONE=$HOME/tmp_bare
PUBLIC_WWW=$HOME/site_location
echo "Cloning $GIT_REPO to $TMP_GIT_CLONE"
git clone $GIT_REPO $TMP_GIT_CLONE
echo "Building the jekyll site from $TMP_GIT_CLONE to $PUBLIC_WWW"
jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW
tell application "iTunes"
set art to artist of current track
set na to name of current track
set value to art & " - " & na & return
end tell
@kristianfreeman
kristianfreeman / artist.rb
Created September 1, 2013 17:44
getting most recently played artists using last.fm
require 'rss'
require 'open-uri'
url = 'http://ws.audioscrobbler.com/1.0/user/kristianfr/recenttracks.rss'
file = '/Users/kristian/.bin/artist.txt'
loop do
begin
open(url) do |rss|
feed = RSS::Parser.parse(rss)
class Array
def self.unwrap(array)
object, _ = array
object
end
end
array = ['foo']
Array.unwrap(array) == 'foo' # => true
user = User.where(name: "Michael Jordan")
user.class == User # => false
user.class == ActiveRecord::Relation # => true
user # => [#<User id: 1, name: "Michael Jordan", sport: "Basketball">]