This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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 /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hash = { one: { foo: 'bar', fizz: 'buzz' }, two: { whizz: 'bang', slap: 'stick' } } | |
result = {} | |
[:one, :two].each do |key| | |
result.merge!(hash[key]) | |
end | |
result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################################### | |
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE tablename_backup LIKE tablename; INSERT tablename_backup SELECT * FROM tablename; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
OlderNewer