Skip to content

Instantly share code, notes, and snippets.

View verticonaut's full-sized avatar

Martin Schweizer verticonaut

  • private
  • Stans, Switzerland
View GitHub Profile
- rvm
- rvm install 1.9.2-head
- rmv create gemset 1.9.2-head@r3
- rmv use above
- gem install rails3b
- gem install rails --pre
- gem install sqlite3
- gem install haml
- gem install rspec --pre
- gem install rspec-rails --pre
@verticonaut
verticonaut / rails3_base_app_template.rb
Created August 17, 2010 21:34
Rails3 application template
# *******************************************************************************************
# Collected and assembled from various sources - thanks to all OS providers
#
# call> rails new my_app -J -T -m 'this template'
# *******************************************************************************************
rvmrc = <<-RVMRC
rvm_gemset_create_on_use_flag=1
rvm gemset use 1.9.2-pre@#{app_name}
RVMRC
@verticonaut
verticonaut / oracle_grant_role.rake
Created September 2, 2010 10:07
Grant a user/role to Oracle tables and views
namespace :oracle do
desc "Grant SELECT to ROLE 'SDD_READ' on all table and views in the schema rerefenced by RAILS_ENV"
task :grant_selects => :environment do
# Define Role (or User) to be granted
RoleToGrant = "your_role_or_user"
begin
db_objects = ActiveRecord::Base.connection.send(:select, "select object_name, object_type from user_objects where object_type in ('VIEW', 'TABLE')")
module ActiveRecord
module ConnectionAdapters
class TableDefinition
# Creates author columns ...
#
# @param Symbol type The desired type for the columns, defaults to :string
# @param Hash *args Column options from rails
@verticonaut
verticonaut / mine
Created September 7, 2011 12:49
RubyMine CommandLine Launcher updated
#!/usr/bin/python
import socket
import struct
import sys
import os
import os.path
import time
# see com.intelij.idea.SocketLock for the server side of this interface
@verticonaut
verticonaut / seed.rb
Created December 5, 2011 19:25
Seed script differentiating for environments (for yaml and rb files)
require 'pp'
puts "Seeding for env '#{Rails.env}'"
# disable AR logger
old_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = nil unless $VERBOSE
env_seed_file = "#{Rails.root}/db/seeds/#{Rails.env.downcase}/seeds.rb"
# first load yaml files that is "base" loading
@verticonaut
verticonaut / workday.rb
Created December 14, 2011 20:00
Add the concept of workdays to Rails
# encoding: utf-8
require 'active_support/basic_object'
require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/object/acts_like'
class Date
def workday?
workdays = ::I18n.t!('definitions.workday.days', :default => (1..5))
none_workdays = ::I18n.t!('definitions.workday.public_holidays', :default => [[]]) # Returns first elememnt within array if translatio is missing (I18n principle)
@verticonaut
verticonaut / sample_code.rb
Last active December 11, 2015 07:09
Merging PDFs
# ************************************************************************************************
# *** Mergin with ghostscript
# ************************************************************************************************
GhostScript = `which gs`.chomp
dir = Rails.root.join('tmp').to_s
file_names = [
'2013_01_24_Pfandhalterschaft_DE.pdf',
'2013_01_24_Passivitaetserklaerung_DE.pdf',
@verticonaut
verticonaut / property_struct.rb
Last active December 19, 2015 02:28
Read and write in property style. Sample: ps = PropertyStruct.new; p['a1.a2.a3']=3 ps['a1'] = #<PropertyStruct:...> ps['a1.a2.a3'] = 3
class PropertyStruct
def initialize(nil_safe = true)
@nil_safe = !!nil_safe
@data = {}
end
def [](attribute)
result = @data
@verticonaut
verticonaut / docker_commands.txt
Created January 17, 2018 12:57
Docker commands
docker ps
# running docker container
docker stop <contaienrId>
# stop the container
docker images
# list all installed images
# Start containers ==========================================
# REDIS
docker run -it --rm -p 6379:6379 -d --name redis redis:alpine