Skip to content

Instantly share code, notes, and snippets.

View hgmnz's full-sized avatar

Harold Giménez hgmnz

View GitHub Profile
(Using Fedora Core 9)
http://wiki.rubyonrails.org/database-support/ms-sql
sudo yum install unixODBC.x86_64 unixODBC-devel.x86_64
sudo yum install freetds.x86_64 freetds-devel.x86_64
sudo gem install dbd-odbc
sudo gem install dbi
sudo gem install activerecord-sqlserver-adapter --source=http://gems.rubyonrails.org
@hgmnz
hgmnz / number_percent_extension.rb
Last active August 30, 2015 03:24
Simple Ruby extension to do stuff like 4.twenty_percent
module NumberPercentageExtension
module InstanceMethods
# the idea converting english to numbers taken from http://www.ruby-forum.com/topic/132735#591799
ENGLISH_VALUE = {}
%w| zero one two three four five six seven eight nine ten eleven
twelve thirteen fourteen fifteen sixteen seventeen eighteen
nineteen |.each_with_index{ |word,i| ENGLISH_VALUE[word] = i }
%w| zero ten twenty thirty forty fifty sixty seventy eighty
ninety|.each_with_index{ |word,i| ENGLISH_VALUE[word] = i*10 }
=== Cron
Here's how to create a crontab that runs a rake task every 15 minutes, as the user webapp:
<tt>
sudo crontab -u webapp -e
</tt>
Vim pops up. Add a line to the file as follows:
# PostgreSQL Notes
For first time Postgres users, the tutorial section on the documentation is a must read: http://www.postgresql.org/docs/8.4/interactive/tutorial.html
### Installation
Easiest way is to use your package manager (yum, apt-get, etc). On MacOS, macports made it easy. Building the source is straightforward as well. There are plenty of resources online...
### Get acquainted with psql
@hgmnz
hgmnz / DDL
Created November 7, 2009 17:18
create table count_cache (
id serial primary key,
table_name varchar(255) not null,
count int not null
)
create table people (
id serial primary key,
name varchar(255) not null
)
include 'singleton'
class Configuration
include Singleton
def self.run
yield Configuration.instance
post_config_process
end
end
# -------------------------------------------
# Simple PostgreSQL Configuration File v. 8.4
# -------------------------------------------
# This file provides a simple configuration with the most common options
# which most users need to modify for running PostgreSQL in production,
# including extensive notes on how to set each of these. If your configuration
# needs are more specific, then use the standard postgresql.conf, or add
# additional configuration options to the bottom of this file.
#
# authorization matchers
module AuthorizationMatcher
class RequireAuthentication
def initialize(method, action, params, context)
@method = method
@action = action
@params = params
@context = context
end
@hgmnz
hgmnz / gist:719171
Created November 28, 2010 18:34
Object#method
ree-1.8.7-2010.02 > some_string = "hi there"
=> "hi there"
ree-1.8.7-2010.02 > some_string.capitalize
=> "Hi there"
ree-1.8.7-2010.02 > some_method = some_string.method :capitalize
=> #<Method: String#capitalize>
ree-1.8.7-2010.02 > some_method.call
=> "Hi there"
ree-1.8.7-2010.02 > String.class_eval { remove_method(:capitalize) }
=> String
@hgmnz
hgmnz / gist:877001
Created March 18, 2011 22:57
rvm gemset export hoptoad_notifier
# hoptoad_notifier generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator
abstract -v1.0.0
actionmailer -v3.0.3
actionmailer -v3.0.2
actionmailer -v3.0.1
actionmailer -v3.0.0
actionmailer -v2.3.8
actionpack -v3.0.3
actionpack -v3.0.2
actionpack -v3.0.1