Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
building stuff on Tezos ꜩ

Diego spacecowb0y

💻
building stuff on Tezos ꜩ
View GitHub Profile
@spacecowb0y
spacecowb0y / params.js
Created May 10, 2011
Return GET params value
View params.js
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || false;
}
// $.urlParam('param');
View stats.rb
<% 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 Jun 5, 2011
console log cinderella error
View gist:1009212
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
View projects_by_date.rb
@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')
View find_provider.js
// 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 Aug 15, 2011
Cuanto falta para el verano?
View verano.rb
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!"
@spacecowb0y
spacecowb0y / application.js
Created Oct 14, 2011
JavaScript Template for Winners
View application.js
// @author: Franco Laiuppa
try {
var home = {
log: function(data) {
// return false; // if you dont want messages to be logged
try {
if (typeof data != 'string') {
console.warn('Debug of variable ===>');
console.debug(data);
View comments.rb
# lib/active_admin/comments.rb
# Always redirect to the resource on show
before_filter :only => :show do
flash[:notice] = flash[:notice].dup if flash[:notice]
comment = ActiveAdmin::Comment.find(params[:id])
resource_config = active_admin_config.namespace.resource_for(comment.resource.class)
# I don't know why this is not working... yet.
# redirect_to send(resource_config.route_instance_path, comment.resource)
View projects.rb
# Customizing the form
form do |f|
f.inputs "Customer" do
f.input :user, :as => :select, :collection => User.find(:all, :order => "created_at ASC").map{ |u| [u.email, u.id] }
end
f.inputs do
f.input :category, :as => :select, :collection => Project.category_collection
f.input :status, :as => :select, :collection => Project.status_collection
f.input :due_date
end
@spacecowb0y
spacecowb0y / console.log
Created Feb 10, 2012
WTF!? Ruby error.
View console.log
Rendered /Users/diegoperalta/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.6ms)
/Users/diegoperalta/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:181: [BUG] pthread_cond_signal: Resource temporarily unavailable (EAGAIN)
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
-- control frame ----------
c:0159 p:---- s:0869 b:0869 l:000868 d:000868 CFUNC :popen
c:0158 p:0083 s:0864 b:0864 l:000863 d:000863 METHOD /Users/diegoperalta/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:181
c:0157 p:0044 s:0858 b:0858 l:000857 d:000857 METHOD /Users/diegoperalta/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:146
c:0156 p:0023 s:0853 b:0852 l:000843 d:000851 BLOCK /Users/diegoperalta/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:27
c:0155 p:0063 s:0849 b:0849 l:000848 d:000848 METHOD /Users/diegoperalta