Skip to content

Instantly share code, notes, and snippets.

View ibanez270dx's full-sized avatar
:shipit:
shippin' it

Jeff Miller ibanez270dx

:shipit:
shippin' it
View GitHub Profile
@ibanez270dx
ibanez270dx / ConditionalValidations.rb
Last active April 10, 2018 11:31
A simple module that allows validation of only certain attributes of any given model. Created for CoverHound.com.
#
# At CoverHound, we use conditional validations all over the form. However, there is no proper way to do
# this in Rails. Instead, we can provide an array of attributes (validated_fields attribute)
# and ensure they are the only ones to get validated.
#
module ConditionalValidations
attr_accessor :validated_fields
def field_is_required?(field)
@ibanez270dx
ibanez270dx / example.html
Last active October 19, 2021 13:13
HTML5 Web Audio Example
<!DOCTYPE html>
<html>
<head>
<title>Web audio: Filter Playground</title>
<link href="http://www.smartjava.org/examples/webaudio-filters/css/bootstrap.css" rel="stylesheet"/>
</head>
<body>
<div class="container">
<h1 class="pagination-centered">HTML5 Web audio</h1>
@ibanez270dx
ibanez270dx / rtc_test_speech.html
Last active December 23, 2020 21:35
HTML5 Audio + Speech to Text...once you enable both microphone and voice recognition, say "facebook", "hack", or "what is my name"
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Web audio capture + Speech Recognition</title>
<link href="http://www.smartjava.org/examples/webaudio-filters/css/bootstrap.css" rel="stylesheet"/>
</head>
<body>
<div class="container">
<h1 class="pagination-centered">HTML5 Web audio capture + Speech Recognition</h1><br />
@ibanez270dx
ibanez270dx / merge_nested_hashes.rb
Last active August 29, 2015 13:58
Merge hashes inside a hash
hash = { one: { foo: 'bar', fizz: 'buzz' }, two: { whizz: 'bang', slap: 'stick' } }
result = {}
[:one, :two].each do |key|
result.merge!(hash[key])
end
result
@ibanez270dx
ibanez270dx / gradient_generator.rb
Last active June 20, 2019 09:09
Ruby Gradient Generator
#####################################################################################
# gradient.rb 11.29.2014
#
# Ruby Gradient Generator
# author: Jeff Miller
# website: humani.se
# github: github.com/ibanez270dx
#
# USAGE:
# Enter RGB or Hex color values and number of steps
@ibanez270dx
ibanez270dx / copytable.sql
Last active August 29, 2015 14:11
Copying a table in MYSQL
CREATE TABLE tablename_backup LIKE tablename; INSERT tablename_backup SELECT * FROM tablename;
@ibanez270dx
ibanez270dx / download_data.rb
Last active August 29, 2015 14:15
Scrape a title from specifically formatted content then download and rename
require 'nokogiri'
require 'open-uri'
dir = Dir.pwd
url = "some_url"
data = Nokogiri::HTML(open(url))
data.css('a').each do |link|
filename = link['href']
if filename =~ /^BD/
@ibanez270dx
ibanez270dx / hex2rgba.rb
Last active August 29, 2015 14:17
Convert Hex color to RGBA
def hex_to_rgba(input, alpha=1)
components = (input.match /#?([0-9A-F]{2})/ )[1..3]
components.map!{ |x| x + x } if input.size == 4
"rgba(#{components.collect(&:hex).join(',')},#{alpha})"
end
@ibanez270dx
ibanez270dx / prompt.sh
Last active August 29, 2015 14:17
Bash Prompt -- Git, RbEnv, etc...
#!/usr/bin/env bash
# Examples:
#
# ps1_set --prompt ∴
#
# This will yield a prompt like the following, for example,
#
# 00:00:50 jeff@edison:~/dev/humani.se (git:master:156d0b4) ruby-2.2.0
@ibanez270dx
ibanez270dx / shkip.rb
Created May 19, 2015 01:15
SKHIP work in progress
require 'io/console'
require 'optparse'
require 'ostruct'
require 'fileutils'
NAME = "Safari Keyword History Index Parser"
VERSION = "v0.0.1"
TIME = Time.now
def box_me_up(str)