Skip to content

Instantly share code, notes, and snippets.

View alexanderadam's full-sized avatar
⌨️
⌨️

Alexander ADAM alexanderadam

⌨️
⌨️
View GitHub Profile
/*
* Minimal classList shim for IE 9
* By Devon Govett
* MIT LICENSE
*/
if (!("classList" in document.documentElement) && Object.defineProperty && typeof HTMLElement !== 'undefined') {
Object.defineProperty(HTMLElement.prototype, 'classList', {
get: function() {
@zorab47
zorab47 / offline_template.rb
Created November 22, 2011 16:18
Offline Template for Rails 2.3.x
# Public: Template to render views outside the context of a controller.
#
# Useful for rendering Rails 2.3.x views in rake tasks or background jobs when a
# controller is unavailable.
#
# Examples
#
# template = OfflineTemplate.new(:users)
# template.render("users/index", :layout => false, :locals => { :users => users })
#
@JeffreyWay
JeffreyWay / gist:1525217
Created December 27, 2011 21:29
Instant Server for Current Directory
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@manuelvanrijn
manuelvanrijn / database.rake
Created January 19, 2012 14:54
Retrieve and convert PostgreSQL database to SQLite database (with ssh)
require 'fileutils'
namespace :db do
desc 'pull the production PostgreSQL database into the development SQLite'
task :pull do
Rake::Task['db:download_pg_dump'].invoke
Rake::Task['db:optimze_pg_dump_for_sqlite'].invoke
Rake::Task['db:recreate_with_dump'].invoke
end
@sandinist
sandinist / gist:1659881
Created January 23, 2012 01:38
pry iterm forward delete
-If you're using a Mac terminal, take a look at [this article](http://www.21croissants.com/howto/fix-forward-delete-key-on-snow-leopard-for-irb).
+#### iTerm2
+
+* Go to iTerm > Preferences... > Keys
+* Add a Global Shortcut Key
+* Type the `delete` key as Shortcut
+* Select Send Hex Codes as Action and type 0x004
+* Click on `OK` and you're good to go
+
+#### iTerm
@Overbryd
Overbryd / download.rb
Created January 28, 2012 19:33
A very fast spaghetti-script written in Ruby that downloads files
#!/usr/bin/env ruby
# download (Works for me™)
#
# A simple & fast download script that utilizes em-http-request as http client
# Usage: download <url>
#
# The filename is determined either by the GET path or by the Content-Disposition response header if given.
# The script will check if there is an existing file and try to resume the download if possible.
#
# Sometimes writing Spaghetti code can be a lot of fun. Don't use it, I do not want to maintain this script.
!!! Strict
%html{:xmlns => 'http://www.w3.org/1999/xhtml'}
%head
%meta{'http-equip' => 'Content-Type', :content => 'text/html; charset=utf-8'}
%meta{:name => 'viewport', :content => 'widt=device-width, initial-scale=1.0'}
%title= subject
:css
/* Based on The MailChimp Reset INLINE: Yes. */
/* Client-specific Styles */
#outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */
@tjh
tjh / character_set_and_collation.rb
Created January 31, 2012 16:07
Convert all Rails table column collation and character set
#!/usr/bin/env ruby
# Put this file in the root of your Rails project,
# then run it to output the SQL needed to change all
# your tables and columns to the same character set
# and collation.
#
# > ruby character_set_and_collation.rb
DATABASE = ''
@henrik
henrik / example_spec.rb
Created February 16, 2012 18:55
Testing Draper decorators with real helpers, including URL helpers.
require "spec_helper"
# :draper_with_helpers is necessary for the Draper objects
# to access real helpers, including URL helpers, in the spec.
describe MyDecorator, "#foo", :draper_with_helpers do
# This is necessary for the spec itself to use URL helpers
# like some_path().
include Rails.application.routes.url_helpers