Skip to content

Instantly share code, notes, and snippets.

View betacar's full-sized avatar
🤓
Tidsoptimist

Carlos Betancourt Carrero betacar

🤓
Tidsoptimist
View GitHub Profile
@modelos = Modelo.all(:params => {:client => @client_code})
@toamitkumar
toamitkumar / gist:952211
Created May 2, 2011 19:35
Inspect and test routes on console (Rails 3)
$ rails console
Loading development environment (Rails 3.0.6)
ruby-1.8.7-p334 :001 > r = Rails.application.routes
Gives you a handle of all the routes (config/routes.rb)
#Inspect a named route:
ruby-1.8.7-p334 :005 > r.recognize_path(app.destroy_user_session_path)
=> {:action=>"destroy", :controller=>"sessions"}
@daz4126
daz4126 / main.rb
Created July 27, 2011 18:06
Robot Factory part 1 - Adding and Deleting Resources in Sinatra
%w[sinatra dm-core dm-migrations slim sass].each{ |lib| require lib }
DataMapper.setup(:default, ENV['DATABASE_URL'] || File.join("sqlite3://",settings.root, "development.db"))
class Robot
include DataMapper::Resource
property :id, Serial
property :top, Integer, :default => proc { 1+rand(6) }
property :middle, Integer, :default => proc { 1+rand(4) }
property :bottom, Integer, :default => proc { 1+rand(5) }
@edgar
edgar / git_svn_bash_prompt
Created August 22, 2011 14:46
Set the bash prompt according to: branch/status of the current git/svn repository, rvm/ruby version and gemset used
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the branch/status of the current git/svn repository
# * the return value of the previous command
# * the current rvm ruby version and gemset (or plain ruby, check parse_ruby_version function)
#
# USAGE:
@LeZuse
LeZuse / detect.py
Created May 2, 2012 18:28
Flask browser detection
browser = request.user_agent.browser
version = request.user_agent.version and int(request.user_agent.version.split('.')[0])
platform = request.user_agent.platform
uas = request.user_agent.string
if browser and version:
if (browser == 'msie' and version < 9) \
or (browser == 'firefox' and version < 4) \
or (platform == 'android' and browser == 'safari' and version < 534) \
or (platform == 'iphone' and browser == 'safari' and version < 7000) \
// Make it Nasty
function increment (i) {
i ^= (i & ~-~i) | (~i & -~i)
return i
}
// write a function that takes an argument
// and returns that argument.
function identity(x) {
return x;
}
// write two binary functions, add and mul,
// that take two numbers and return their sum and product.
@psi
psi / -
Created April 29, 2014 21:02
Colleagues don't let colleagues code sober.
===========
= Spirits =
===========
- Santa Teresa 1796 rum
- Black Maple Hill bourbon
- Bruichladdich Rocks scotch
- Templeton rye
- Whistlepig Straight Rye Whiskey
@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active April 19, 2024 01:50
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@searls
searls / github-wiki-override-test-double-style.css
Last active May 11, 2021 16:33
Some CSS that will make Github Wiki content full-screen friendly (useful when presenting). Override with your browser or an extension like greasemonkey or Stylish to apply to the wikis you want.
/* and now with 100% more branding */
body { border: 10px solid #82FA32; min-height: 720px; }
.container { width: inherit; }
.header { display: none; }
.gh-header { padding: 30px 0px 30px 0px; background-color: black; color: white; }
.gh-header-actions { float: inherit; text-align: center; }
.btn-primary { border-color: #000; background-image: linear-gradient(#333, #000); }
.gh-header-actions .btn { float: inherit; }
.gh-header-title { padding-top: 20px; text-align: center; font-size: 4.2em; margin-right: 0px; font-weight: 100; }
.pagehead { display: none; }