Skip to content

Instantly share code, notes, and snippets.

View minimul's full-sized avatar
🎯
Focusing

Christian Pelczarski minimul

🎯
Focusing
View GitHub Profile
require 'hirb'
# don't show [created|updated|deleted]_at fields from ActiveRecord tables
class Hirb::Helpers::MyActiveRecordTable < Hirb::Helpers::ActiveRecordTable
def self.render(rows,opts={})
rows = [rows] unless rows.is_a?(Array)
opts[:fields] = rows.first.class.columns.reject {|c| c.type == :datetime}.map {|c| c.name.to_sym}
super(rows, opts)
end
end
@cowboy
cowboy / ba-postMessage-detect.js
Created September 15, 2010 16:50
postMessage detector
/*!
* postMessage detector - v0.1pre - 9/15/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// If `window.postMessage.complex` is true, postMessage can pass complex non-string
@sethbro
sethbro / _speech_bubble.sass
Created March 10, 2011 22:31
Speech bubble Sass mixin
=speech_bubble($arrow_dir: left, $arrow_pos: 50%, $color: #efefef, $border_width: 2px, $border_color: #ccc)
border-style: solid
border-width: $border_width
border-color: $border_color
+border-radius
background-color: $color
position: relative
overflow: visible
$dir_x: right
@avdi
avdi / deep_fetch.rb
Created June 28, 2011 19:28
Deep Fetch
module DeepFetch
def deep_fetch(*keys, &fetch_default)
throw_fetch_default = fetch_default && lambda {|key, coll|
args = [key, coll]
# only provide extra block args if requested
args = args.slice(0, fetch_default.arity) if fetch_default.arity >= 0
# If we need the default, we need to stop processing the loop immediately
throw :df_value, fetch_default.call(*args)
}
catch(:df_value){
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 22, 2024 17:28
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@sr75
sr75 / wildcard-ssl-cert-for-testing-nginx-conf.md
Created June 1, 2013 18:35
create a self signed wildcard ssl cert for testing with nginx.conf example

just change out app_name for your purposes

openssl genrsa 2048 > app_name-wildcard.key

openssl req -new -x509 -nodes -sha1 -days 3650 -key app_name-wildcard.key > app_name-wildcard.cert

# Common Name (eg, your name or your server's hostname) []:*.app_name.com

openssl x509 -noout -fingerprint -text &lt; app_name-wildcard.cert &gt; app_name-wildcard.info
@tylerneylon
tylerneylon / learn.lua
Last active July 11, 2024 15:28
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@andycamp
andycamp / truncate_db_task.rb
Created January 30, 2014 16:41
Rake Task for truncating all tables in a rails app. Preserves the schema_migrations.
desc "Truncate all tables in the database"
task :truncate_all_tables! => :environment do
unless Rails.env.production?
puts "TRUNCATING ALL TABLES in 3 seconds!!!!"
sleep 3
ActiveRecord::Base.connection.tables.each do |table|
unless table == "schema_migrations"
puts "Truncating #{table}."
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table} RESTART IDENTITY CASCADE;")
else
@stevenyap
stevenyap / Mina.md
Created February 21, 2014 08:45
Mina - Faster deployment than Capistrano!!!
@lfender6445
lfender6445 / gist:9919357
Last active July 3, 2024 20:50
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger