Skip to content

Instantly share code, notes, and snippets.

View spacecowb0y's full-sized avatar

[object Object] spacecowb0y

View GitHub Profile
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(e(){9 d={t:e(){6.f=6.k(6.u)||"K l f";6.v=6.m(3.7)||6.m(3.L)||"w l v";6.n=6.k(6.x)||"w l n"},k:e(a){M(9 i=0;i<a.y;i++){9 b=a[i].4;9 c=a[i].z;6.o=a[i].8||a[i].2;g(b){g(b.A(a[i].5)!=-1)h a[i].2}N g(c)h a[i].2}},m:e(a){9 b=a.A(6.o);g(b==-1)h;h O(a.P(b+6.o.y+1))},u:[{4:3.7,5:"B",2:"B"},{4:3.7,5:"p",8:"p/",2:"p"},{4:3.j,5:"Q",2:"R",8:"S"},{z:C.T,2:"U"},{4:3.j,5:"D",2:"D"},{4:3.j,5:"V",2:"W"},{4:3.7,5:"E",2:"E"},{4:3.j,5:"F",2:"F"},{4:3.7,5:"q",2:"q"},{4:3.7,5:"G",2:"X",8:"G"},{4:3.7,5:"Y",2:"r",8:"Z"},{4:3.7,5:"r",2:"q",8:"r"}],x:[{4:3.s,5:"10",2:"11"},{4:3.s,5:"H",2:"H"},{4:3.7,5:"I",2:"I/12"},{4:3.s,5:"J",2:"J"}]};d.t();C.$.13={14:d.n,f:d.f}})();',62,67,'||identity|navigator|string|subString|
@spacecowb0y
spacecowb0y / User Model
Created March 31, 2011 17:34
default name: "Chuck Norris"
class User
include DataMapper::Resource
# PROPERTIES
property :id, Serial
property :fullname, String, :default => "Chuck Norris"
property :password, String
property :created_at, DateTime
property :updated_at, DateTime
def password_changed?
new? or dirty_attributes.has_key?(:password)
end
@spacecowb0y
spacecowb0y / Time in Words - Ruby Helper
Created April 7, 2011 19:18
Time in Words - Ruby Helper
def time_ago_in_words(timestamp)
minutes = (((Time.now - timestamp).abs)/60).round
return nil if minutes < 0
case
when minutes < 1 then "less than a minute ago"
when minutes == 1 then "1 minute ago"
when minutes < 50 then "#{minutes} minutes ago"
when minutes < 90 then "1 hour ago"
when minutes < 1440 then "#{(minutes / 60).round} hours ago"
else
@spacecowb0y
spacecowb0y / params.js
Created May 10, 2011 12:41
Return GET params value
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || false;
}
// $.urlParam('param');
@spacecowb0y
spacecowb0y / stats.rb
Created May 29, 2011 18:22
Stats by Month
<% for i in 1..12 do %>
<tr>
<th><%= Date::MONTHNAMES[i][0..2] %></th>
<td>
<%= @projects.all(:conditions => { :created_at => Date.civil(2011, 0+i.to_f, 1)..Date.civil(2011, 0+i.to_f, -1)}).count %>
</td>
</tr>
<% end %>
@spacecowb0y
spacecowb0y / gist:1009212
Created June 5, 2011 17:40
console log cinderella error
Diego-Peraltas-MacBook-Pro:var kerberoS$ cd
Diego-Peraltas-MacBook-Pro:~ kerberoS$ curl https://github.com/atmos/cinderella/raw/master/bootstrap.sh \-o - | sh % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
101 1424 101 1424 0 0 939 0 0:00:01 0:00:01 --:--:-- 3641
Ensuring we have the latest version of cinderella installed
A first time install takes about 45 minutes on a modern machine
You need to upgrade rubygems to 1.7.2
Cinderella installed successfully
[Sun, 05 Jun 2011 13:55:04 -0300] INFO: *** Chef 0.10.0 ***
[Sun, 05 Jun 2011 13:55:08 -0300] INFO: Setting the run_list to ["homebrew", "homebrew::dbs", "homebrew::misc", "ruby", "ruby::irbrc", "node", "python"] from JSON
@projects_by_date = repository(:default).adapter.select('SELECT id,DAYOFWEEK(created_at) AS creation_day, COUNT(id) AS per_day FROM projects GROUP BY creation_day ORDER BY creation_day ASC')
@spacecowb0y
spacecowb0y / find_provider.js
Created August 6, 2011 01:59
Find provider
// medio cabeza, es la primera version, lo escribí de corrido eh, sin ningún error.
$(function(){
function find_provider(str) {
str = str.split("@");
str = str[1];
str = str.split(".");
str = str[0];
if ( (str != "gmail") || (str != "yahoo") || (str != "hotmail") ) {
$('form small span').removeClass('current');
@spacecowb0y
spacecowb0y / verano.rb
Created August 15, 2011 11:51
Cuanto falta para el verano?
require 'date'
def cuanto_falta_para_el_verano?
return (DateTime.new(Time.now.year, 12, 21)-DateTime.now).to_i
end
# TEST => $ ruby verano.rb
puts "Faltan #{cuanto_falta_para_el_verano?} días para el verano!"