Skip to content

Instantly share code, notes, and snippets.

View jenrzzz's full-sized avatar

Jenner La Fave jenrzzz

View GitHub Profile
class Like < ActiveRecord::Base
belongs_to :likeable, polymorphic: true
belongs_to :user
end
class Project < ActiveRecord::Base
has_many :likes, as: :likeable
end
class Source < ActiveRecord::Base

Keybase proof

I hereby claim:

  • I am jenrzzz on github.
  • I am jenrzzz (https://keybase.io/jenrzzz) on keybase.
  • I have a public key whose fingerprint is B598 9E66 2182 C4FA 74E6 A5AB F423 CA23 8536 8436

To claim this, I am signing this object:

@jenrzzz
jenrzzz / itunes-nowplaying.py
Last active August 29, 2015 14:09
Powerline segment for iTunes now playing
class iTunesPlayerSegment(PlayerSegment):
def get_player_status(self, pl):
status_delimiter = '-~`/='
ascript = '''
tell application "System Events"
set process_list to (name of every process)
end tell
if process_list contains "iTunes" then
tell application "iTunes"
var quotes = new Array;
quotes.push("Avuncular at best in a church of new things<br>He traded the records for rings<br>As I sat back and watched what I thought would ensue not ensue");
quotes.push("If you don't believe in recompense, who will fix the fence for you?");
quotes.push("What is it about music that lends itself so well to business as fucking usual?");
quotes.push("I am a tastemaker, and I kill things<br>I am not a tastemaker and I kill things");
quotes.push("Jennifer, your halter top: a consecrated altar<br>But I've wrung my hands and knees in shame there one too many times");
quotes.push("Girls are great<br>Grated on my plate<br>And boys are best<br>Served with a stake through the chest");
quotes.push("There are no wills, there are no keys<br>Only executors and executees");
quotes.push("One might say we've lost the space race<br>Another one might say we've won");
quotes.push("The pedagogue in me asked &quot;What have you read lately?&quot;<br>A pleasantry the blonde in you responded to");
@jenrzzz
jenrzzz / gist:2876718
Created June 5, 2012 18:25
Normalize row height
$(document).ready(function() {
$('.normheight').css({
'height': $('.normheight').height()
});
});
@jenrzzz
jenrzzz / gist:3308273
Created August 9, 2012 21:40
puppet host lookup
require 'resolv'
module Puppet::Parser::Functions
newfunction(:get_ip_addr, :type => :rvalue) do |args|
# Super sexy regex to match valid IPs
ip_addr_re = /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/
hostname = args[0].strip
if hostname =~ ip_addr_re then return hostname end
begin
Resolv::DNS.open { |dns| return dns.getaddress hostname }
@jenrzzz
jenrzzz / gss-test.c
Last active December 10, 2015 09:21
Trying to find a portable way to get the active Kerberos principal name
#include <stdio.h>
#ifdef __APPLE__
/* /System/Library/Frameworks/GSS.framework/GSS should be statically linked */
#include <GSS/GSS.h>
#else
#include <gssapi/gssapi.h>
#include <gssapi/gssapi_krb5.h>
#endif
@jenrzzz
jenrzzz / client.go
Created April 16, 2013 06:46
199 Go sockets practice
package main
import ("net"; "fmt"; "log")
func main() {
conn, err := net.Dial("tcp", "localhost:9999")
if err != nil {
log.Panic(err)
}
@jenrzzz
jenrzzz / gist:5588205
Created May 15, 2013 23:19
tmux session switcher function
function sesh() {
if [[ $# -gt 0 ]]; then
case "$1" in
new)
tmux new -s "$2"
;;
*)
if tmux list-sessions | grep "attached"; then
tmux switch -t "$1"
else
@jenrzzz
jenrzzz / test.s
Last active December 17, 2015 18:18
.section ".data"
.global fmt
fmt:
.asciz "uninit value: %d\n"
.section ".bss"
.global a
a: .skip 4
.section ".text"