Skip to content

Instantly share code, notes, and snippets.

View superscott's full-sized avatar
👺
щ(ಠ益ಠщ) (✖╭╮✖) ᕦ(ò_óˇ)ᕤ

superscott superscott

👺
щ(ಠ益ಠщ) (✖╭╮✖) ᕦ(ò_óˇ)ᕤ
View GitHub Profile
@superscott
superscott / gist:3897081
Created October 16, 2012 03:18
Rails Date.today oddity
Ruby 1.9.2 -- Rails 3.2.8
1.9.2p320 :001 > Date.today
=> Mon, 15 Oct 2012
1.9.2p320 :002 > Date.tomorrow
=> Wed, 17 Oct 2012
1.9.2p320 :003 > Date.yesterday
=> Mon, 15 Oct 2012
1.9.2p320 :004 > Time.zone
=> (GMT+00:00) UTC
@superscott
superscott / gist:3908076
Created October 17, 2012 20:47
two arrays as hash
saturday.each_with_index { |k,i| datehash[k] = friday[i] }
saturday (array one)
datehash (resulting hash)
friday (array two)
def data_links_helper(data, model)
output = ""
for report in data
output << "<tr>"
report.each do |k,v|
output << "<td>#{v}</td>"
end
@select_options = { "value" => "value", "name" => "name" }
<%= select_tag 'group_by', options_from_collection_for_select(@select_options, "value", "name") %>
asd = Price.where("min_color <= ? AND min_qty <= ? ", 1, 34)
def self.clean(value, level)
case level
when 1 #strip html and tags
results = Sanitize.clean(value)
when 2 #includes level 1, regex to allow symbols
leveltwo = Sanitize.clean(value)
leveltwo.strip!
results = leveltwo.gsub(/[^0-9a-zA-Z\(\)\|\:\/\,\'\.\-\@\_\[\]\&\?\=\s]/, "")
@superscott
superscott / gem_make.out
Last active December 14, 2015 08:49
gem install error?
cat /Users/.rvm/gems/ruby-2.0.0-p0@gems/gems/therubyracer-0.11.4/ext/v8/gem_make.out
/Users/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
creating Makefile
make
compiling accessor.cc
accessor.cc:1: error: bad value (corei7) for -march= switch
accessor.cc:1: error: bad value (corei7) for -mtune= switch
@superscott
superscott / gist:5085435
Created March 4, 2013 20:39
remove formatting on numbers.
Example:: v.first == "1,000" or v.first == "$15,000.00"
<td>
<div>
<span title=<%= !v.first.nil? ? v.first.gsub(',', '') : nil %>></span>
<% v.each do |col_value| %>
<%= col_value %>
<% end %>
</div>
</td>
[4] pry(main)> asd = ('A'..'Z')
=> "A".."Z"
[5] pry(main)> asd.each do |p|
[5] pry(main)* puts p
[5] pry(main)* end
A
B
C
D
E
@superscott
superscott / search.js
Last active December 19, 2015 10:09
jQuery Search.
<div id='search_div'>
<input type="text" class="search-query" id="search_text">
<button class="btn" id='search_button'><i class='icon-search'></i></button>
</div>
<address id="2106">
<strong>RandoZZ ZZMcCracken</strong><br>
<small>home:</small> <a href="mailto:[email protected]">[email protected]</a><br><small>work:</small> <a href="mailto:[email protected]">[email protected]</a><br><small>primary:</small> <a href="mailto:[email protected]">[email protected]</a><br><small>other:</small> <a href="mailto:[email protected]">[email protected]</a><br>
<small>home phone:</small> 1-310-555-5555 <br><small>work phone:</small> 1-310-555-3333 <br><small>cell phone:</small> 1.310.555.1212
</address>