Skip to content

Instantly share code, notes, and snippets.

View ericboehs's full-sized avatar

Eric Boehs ericboehs

  • Oddball
  • Enid, OK
  • 17:30 (UTC -05:00)
View GitHub Profile
$port = 3000 # UDP port assigned by cloud provider
require 'socket'
u1 = UDPSocket.new
u1.bind "0.0.0.0", $port
# to be saved to remote postgres database
hex_dgram = u1.recvfrom(53)[0]
p hex_dgram.unpack('H*')[0]
@ericboehs
ericboehs / gist:a62df00a09baef313fc0
Last active August 29, 2015 14:07
Parsing fields from a byte string
module LmdDecoder
class FieldToByteMapper
FIELD_TO_BYTE = {
full_message: {
start: 0,
length: -1
},
options_present: {
start: 0,
length: 1
@ericboehs
ericboehs / comments.coffee
Last active August 29, 2015 14:13
Binding to page:load and document ready event w/ Turbolinks
@Comments =
ready: ->
@bindComments()
@initializeComments()
load: ->
@initializeComments()
bindComments: ->
$(document).on 'click', "a[data-comment]", (e) =>
SourceAnnotationExtractor::Annotation.register_extensions(
"coffee", "yml", "yaml", "gemspec", "feature") { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
SourceAnnotationExtractor::Annotation.register_extensions(
"scss", "sass", "less") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
SourceAnnotationExtractor::Annotation.register_extensions(
"haml") { |tag| /-\s*#\s*(#{tag}):?\s*(.*)$/ }
SourceAnnotationExtractor::Annotation.register_extensions(
"slim") { |tag| /\/\s*\s*(#{tag}):?\s*(.*)$/ }
@ericboehs
ericboehs / comments_show.html.slim
Created May 7, 2015 21:23
Poll for changes using Rails js partials
/ ...
javascript:
Poller.startPolling = true
Poller.poll_url = "#{comment_path @comment, format: :js}"
@ericboehs
ericboehs / after.rb
Created June 9, 2015 23:30
Zone intersections
class Reading < ActiveRecord::Base
def persist_zone_events
device.zones.outside.intersecting(lat, lon).each do |zone|
zone_events.create status: :inside, zone: zone
end
device.zones.inside.not_intersecting(lat, lon).each do |zone|
zone_events.create status: :outside, zone: zone
end
end
require 'bundler/setup'
require 'yaml'
require 'selenium-webdriver'
require 'dotenv'; Dotenv.load
basic_auth = "#{ENV.fetch('BS_USERNAME')}:#{ENV.fetch('BS_API_KEY')}"
config = YAML.load_file("win7-ie10.yml")
caps = Selenium::WebDriver::Remote::Capabilities.new config
driver = Selenium::WebDriver.for(
@ericboehs
ericboehs / postgis.rb
Last active August 29, 2015 14:28 — forked from jgeo/postgis.rb
postgis 1.5.3
require 'formula'
class Postgis < Formula
url 'http://postgis.refractions.net/download/postgis-1.5.3.tar.gz'
homepage 'http://postgis.refractions.net/'
sha256 'a2334f8b229446c0497d48a430a40152a3b71a5da02f414a0340a0a025d416cf'
head 'http://svn.osgeo.org/postgis/trunk/', :using => :svn
depends_on 'postgresql91'
# ~/.bash_profile
# Eric Boehs's git aliases
alias gb='git branch'
alias gba='git branch -a'
alias gc='git commit -v'
alias gd='git diff | mate'
alias gl='git pull'
alias gp='git push'
alias gst='git status'