Skip to content

Instantly share code, notes, and snippets.

View oma's full-sized avatar

Ole Morten Amundsen oma

View GitHub Profile
@oma
oma / show_indexes.rb
Created November 21, 2018 21:10
show database indexes in rails
ActiveRecord::Base.connection.tables.each do |table|
indexes = ActiveRecord::Base.connection.indexes(table)
if indexes.length > 0
puts "====> #{table} <===="
indexes.each do |ind|
puts "----> #{ind.name}"
end
puts "====> #{table} <===="
2.times{ puts ''}
end
@oma
oma / README.txt
Created August 21, 2012 19:26 — forked from i-scorpion/README.txt
Twitter bootstrap fixed table header using jQuery
Here is a simple jQuery plugin to make a table header fixed on top when window is scrolled.
Using the code from twitter bootstrap documentation page, this code is customized for table header.
Create the table with following layout -
<table class="table-fixed-header">
<thead class="header">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
@oma
oma / mongoid.yml
Created June 9, 2012 12:28 — forked from tal/mongoid.yml
development: &defaults
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default: &default_session
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: delight_development
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
@oma
oma / .gemrc
Created January 31, 2012 14:00
git colors, gem methods. At user root ~
# disse filene ligger alle under home. eks: /users/oma
---
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
- http://rubygems.org/
- http://gems.github.com
:update_sources: true
:verbose: true
<!--
Used for https://github.com/rubykurs/bootstrap
branch auth
@Gemfile
gem 'devise'
$ rails g devise:install
$ rails g devise admin
$ rake db:migrate
-->
@oma
oma / _form.html.erb
Created January 29, 2012 13:04
SimpleForm twitter bootstrap ERB
<!-- Simple form EXAMPLE using twitter bootstrap
Referenced at https://github.com/rubykurs/bootstrap
With related gists https://gist.github.com/1698584 and https://gist.github.com/1695634
app/views/reports/_form.html.erb
rails generate scaffold report title:string description:text email:string
-->
@oma
oma / _flashes.html.erb
Created January 29, 2012 12:29
twitter bootstrap homepage rails
<!-- app/views/common/_flashes.html.erb -->
<% unless flash[:notice].blank? %>
<div class="alert-message success">
<%= content_tag :div, flash[:notice] %>
</div>
<% end %>
<% unless flash[:error].blank? %>
<div class="alert-message error">
@oma
oma / simple_form.rb
Created January 28, 2012 20:15
rails 3.2 simple_form-2.0 twitter bootstrap
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a complete input.
# You can remove any component from the wrapper, change the order or even
# add your own to the stack. The options given to the wrappers method
# are used to wrap the whole input (if any exists).
config.wrappers :bootstrap, :tag => 'fieldset', :class => 'control-group', :error_class => 'error' do |b|
b.use :placeholder
b.use :label, :class => 'control-label'
b.use :tag => 'div', :class => 'controls' do |ba|
ba.use :input
@oma
oma / mongo.rb
Created May 5, 2011 16:15
oma mongomapper setup
# config/initializers/mongo.rb
#
# MonkeyPatch to fix the error going on in mongomapper + rails3 + ruby 1.9.2
#
MongoMapper::Plugins.class_eval do
def plugins
@plugins ||= []
end
ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
rails -v
Rails 2.3.2
Mac OS X 10.5
(/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/ is used)
mysql --version
mysql Ver 14.12 Distrib 5.0.67, for apple-darwin9.0.0b5 (i686) using readline 5.1