Skip to content

Instantly share code, notes, and snippets.

View jgrevich's full-sized avatar

Justin Grevich jgrevich

View GitHub Profile
module PIFRecord
class Record
require "coreaudio"
include Celluloid
def initialize
dev = CoreAudio.default_input_device
@buf = dev.input_buffer(1024)
filename = Time.now.strftime("%Y.%m.%d.wav")
require 'celluloid/autostart'
module PIFRecord
PIFRECORD_ROOT = File.expand_path('.')
Dir[File.join(PIFRECORD_ROOT,"lib/pif_record/*.rb")].each {|file| require file }
# Handle the input, this would probably run some method
# as a part of the DSL you'd have to create. Place this
# repl as your command line interface to your service.
end
@jgrevich
jgrevich / bic_abstract_import.rb
Created June 12, 2013 20:52
import abstract data from excel spreadsheet into bic website
require 'roo'
def find_and_update_abstract(updated_data)
abstract = Abstract.find(updated_data[0]).update_attributes(poster_number: updated_data[1], session: updated_data[2])
end
def load_and_import_data
imported_data = Roo::Excelx.new("/Users/jjg/Desktop/abstract_assignments_revised_check.xlsx")
i = 1
@jgrevich
jgrevich / fizzbuzz.rb
Last active December 17, 2015 15:19
fizzbuzz solution
# Write a program that prints the numbers from 1 to 100. But for multiples of three
# print "Fizz" instead of the number and for the multiples of five print "Buzz".
# For numbers which are multiples of both three and five print "FizzBuzz".
def fb
(1..100).each do |n|
case
when n%3 == 0 && n%5 == 0
puts "FizzBuzz"
when n%5 == 0
@jgrevich
jgrevich / google.rb
Created May 1, 2013 20:17
example of google search
module Scraper
class Google
include Capybara::DSL
Capybara.app_host = "http://www.google.com"
def search(query="I love Ruby!")
visit('/')
wait = 0 unless wait
sleep(wait)
@jgrevich
jgrevich / .irbrc
Last active December 16, 2015 13:19
my .irbrc
require 'rubygems'
require 'ap' # Awesome Print
require 'net-http-spy' # Print information about any HTTP requests being made
%w{wirble what_methods}.each { |lib| require lib }
# %w{what_methods}.each { |lib| require lib }
%w{init colorize}.each { |message| Wirble.send(message) }
@jgrevich
jgrevich / handbrake.sh
Last active October 30, 2015 01:47
Handbrake command to crop and resize a 2560x1600 video down to 1920x1080, but it doesn't crop/scale
HandBrakeCLI -vv \
--main-feature \
-m \
-e x264 \
--x264-preset veryslow \
--x264-tune film \
--x264-profile high \
--h264-level 4.1 \
-x "ref=4;threads=12:lookahead_threads=2:no-fast-pskip" \
-2 \
@jgrevich
jgrevich / gist:4102105
Created November 18, 2012 00:46
attempt to overlay video from one mp4 onto another
gst-launch -e videomixer name=mix ! filesink location=test.mp4 \
filesrc location=Video.mov ! decodebin name=decode1 decode1. ! videobox border-alpha=0 top=-320 left=-640 ! mix. \
filesrc location=Slides.mov ! decodebin name=decode2 decode2. ! videobox border-alpha=0 top=0 left=0 ! mix.
@jgrevich
jgrevich / gist:4026572
Created November 6, 2012 18:31
Creation of a self-signed cert with SAN in Ubuntu 12
openssl genrsa -out /etc/ssl/private/test.key 2048
openssl req -new -key /etc/ssl/private/test.key -out /etc/ssl/private/test.csr
openssl x509 -req -extensions v3_req -days 365 -in /etc/ssl/private/test.csr -signkey /etc/ssl/private/test.key -out /etc/ssl/certs/test.pem
openssl req -text -noout -in /etc/ssl/private/test.csr
root@jx:/etc/ssl/private# openssl req -text -noout -in /etc/ssl/private/test.csr
Certificate Request:
Data:
Version: 0 (0x0)
Subject: C=US, ST=California, L=La Jolla, O=grevi.ch, CN=grevi.ch/emailAddress=justin@grevi.ch
@jgrevich
jgrevich / gist:3174407
Created July 25, 2012 04:32
~/.asoundrc
pcm.dmixer {
type dmix
ipc_key 1024
ipc_key_add_uid false
ipc_perm 0660
slave {
pcm "hw:0,3" #HDMI, defaults to 48000 kHz
channels 2
period_size 1024
buffer_size 4096