Skip to content

Instantly share code, notes, and snippets.

@pocketkk
pocketkk / lcd.rb
Created January 12, 2013 06:08
Ruby Library for Parallax 16 x 2 Serial LCD for Raspberry Pi
# LIBRARY FOR CONTROL PARALLAX 16x2 SERIAL LCD DISPLAY ON A RASBERRY PI
#
# Wiring Diagram
# PI LCD
# ****************************
# pin 8 (TX) -------> RX
# pin 6 (GND) -------> GND
# pin 2 (5V) -------> 5V
#
#
@pocketkk
pocketkk / lcd.rb
Created January 27, 2013 17:02
Ruby Serial Library for 4x20 LCD (NHD-0420D3Z-NSW-BBW)
# RUBY LIBRARY FOR SERIAL COMM RS-323 TO 4X20
# LCD COMPATIBLE WITH THE NEW HAVEN DISPLAY COMMANDS
#
# LCD MODEL# NHD-0420D3Z-NSW-BBW
#
# SPEC SHEET LOCATED:
# http://www.newhavendisplay.com/specs/NHD-0420D3Z-NSW-BBW.pdf
#
# HOOK UP PIN 1 TO TX ON RASBERRY PI
# PIN 2 TO GND
@pocketkk
pocketkk / piano_display.rb
Created January 27, 2013 17:13
Pianobar Raspberry PI LCD CTL file
#!/usr/bin/env ruby
# REMOTE CONTROL
# pianobar can be controlled through a fifo. You have to create it
# yourself by executing
# mkfifo ~/.config/pianobar/ctl
# Adjust the path if you set up a $XDG_CONFIG_HOME. Afterwards you can
# write commands directly into the fifo. Example (next song):
@pocketkk
pocketkk / get_ip.rb
Created November 16, 2013 22:52
Local IP Address
#!/usr/bin/env ruby
require 'socket'
require "/home/pi/projects/lcd/lcd"
def local_ip(target)
# turn off reverse DNS resolution
bdns, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
UDPSocket.open do |s|
@pocketkk
pocketkk / Raspberry Pi->Mopidy->Spotify
Last active April 1, 2016 11:31
Raspberry Pi instructions to install Mopidy with Spotify support.
Steps to get Raspberry Pi running with Mopidy and Spotify
1. Raspian Wheezy Installation
2. Install Python tools following these instructions
(had to run most of it as sudo):
http://raspberry.io/wiki/how-to-get-python-on-your-raspberrypi/
3. Install Spotify libspotify
https://developer.spotify.com/technologies/libspotify/#download
4. Install Mopidy following these directions:
http://docs.mopidy.com/en/latest/installation/raspberrypi/
@pocketkk
pocketkk / gitrvmruby.zsh-theme
Last active December 29, 2015 16:39
zsh-theme
if [ -e ~/.rvm/bin/rvm-prompt ]; then
J_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[green]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
else
if which rbenv &> /dev/null; then
J_CURRENT_RUBY_="%{$fg[white]%}[%{fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg[white]%}]%{$reset_color%}"
fi
fi
function get_pwd() {
echo "${PWD/$HOME/~}"
@pocketkk
pocketkk / BlurEffectModal.swift
Last active March 6, 2017 03:26
Swift - UIBlurEffect - Modal with Dismiss
import UIKit
import QuartzCore
class ViewController: UIViewController {
var eView: UIVisualEffectView?
@IBAction func blurOut(sender: UIVisualEffectView) {
//eView?.removeFromSuperview()
var removeTransition = CATransition()
//Presenting Controller
func popOver() {
var popoverContent = self.storyboard.instantiateViewControllerWithIdentifier("popOver") as UIViewController
var nav = UINavigationController(rootViewController: popoverContent)
nav.modalPresentationStyle = UIModalPresentationStyle.Popover
var popover = nav.popoverPresentationController as UIPopoverPresentationController
popoverContent.preferredContentSize = CGSizeMake(500,600);
popover.delegate = self
@pocketkk
pocketkk / gist:e449cc89d40ce9744590
Created July 13, 2014 15:01
Swift - Add subview with transition
UIView.transitionWithView(self.view, duration: 0.5, options: UIViewAnimationOptions.TransitionNone,
animations: {self.view.addSubview(effectView)}, completion: nil)
@pocketkk
pocketkk / Swift UIFactory.swift
Last active August 29, 2015 14:04
Swift - UIFactory
// Playground - noun: a place where people can play
import UIKit
class BaseUIDefaults {
class var sharedInstance : BaseUIDefaults {
struct Static {
static let instance : BaseUIDefaults = BaseUIDefaults()
}