Skip to content

Instantly share code, notes, and snippets.

View graudeejs's full-sized avatar

Aldis Berjoza graudeejs

View GitHub Profile
@mattetti
mattetti / gist:1015948
Created June 9, 2011 02:44
some excel formulas in Ruby
module Excel
module Formulas
def pmt(rate, nper, pv, fv=0, type=0)
((-pv * pvif(rate, nper) - fv ) / ((1.0 + rate * type) * fvifa(rate, nper)))
end
def ipmt(rate, per, nper, pv, fv=0, type=0)
p = pmt(rate, nper, pv, fv, 0);
ip = -(pv * pow1p(rate, per - 1) * rate + p * pow1pm1(rate, per - 1))
(type == 0) ? ip : ip / (1 + rate)
@xxx
xxx / watermark.rb
Created June 28, 2011 19:11
Paperclip watermarking processor
module Paperclip
class Watermark < Processor
# Handles watermarking of images that are uploaded.
attr_accessor :current_geometry, :target_geometry, :format, :whiny, :convert_options, :watermark_path, :watermark_offset, :overlay, :position
def initialize file, options = {}, attachment = nil
super
geometry = options[:geometry]
@file = file
@crop = geometry[-1,1] == '#'
@argent-smith
argent-smith / how-to.markdown
Created August 17, 2011 10:21
ruby 1.9.2 installation WITH ICONV under rvm and FreeBSD

Ruby 1.9.2 RVM w/iconv FreeBSD installation HOWTO

The Problem

Recently, trying to run some of my crutches (the Ruby thingies I use to help me sysadmining) under RVM, I've found that require 'iconv' doesn't work. Since I knew it's working in standard lang/ruby18 and lang/ruby19 ports I started to search where is the trap and have found that. Here's how.

Prerequisites

  • rvm installed
  • system ruby installed
@graudeejs
graudeejs / gist:1257651
Created October 2, 2011 17:12
Firefox settings
browser.backspace_action = 0
browser.cache.disk.capacity = 0
browser.cache.disk.enable = 0
browser.cache.offline.capacity = 0
browser.download.manager.scanWhenDone = false
browser.formfill.enable = false
browser.fullscreen.animateUp = 0
browser.fullscreen.autohide = false
browser.link.open_newwindow = 3
browser.link.open_newwindow.restriction = 0
@nesquena
nesquena / markdown_yard.md
Created November 29, 2011 21:51
Github Flavored Markdown in YARD
@chetan
chetan / yardoc_cheatsheet.md
Last active May 10, 2024 02:53
YARD cheatsheet
@randym
randym / axlsx.example.rb
Created April 12, 2012 23:42
axlsx Generating Excel documents with Ruby
require 'axlsx'
Axlsx::Package.new do |p|
p.workbook do |wb|
styles = wb.styles
header = styles.add_style :bg_color => "DD", :sz => 16, :b => true, :alignment => {:horizontal => :center}
tbl_header = styles.add_style :b => true, :alignment => { :horizontal => :center }
ind_header = styles.add_style :bg_color => "FFDFDEDF", :b => true, :alignment => {:indent => 1}
col_header = styles.add_style :bg_color => "FFDFDEDF", :b => true, :alignment => { :horizontal => :center }
label = styles.add_style :alignment => { :indent => 1 }
@bradpauly
bradpauly / custom_file_store.rb
Created August 12, 2012 22:37
simple file store for rails sessions
module ActionDispatch
module Session
class CustomFileStore < ActionDispatch::Session::AbstractStore
def get_session(env, session_id)
session_data = {}
session_id ||= generate_sid
File.open(tmp_file(session_id),'r') do |f|
data = f.read
session_data = ::Marshal.load(data) unless data.empty?
end rescue nil
@kazpsp
kazpsp / passwords_controller.rb
Created August 14, 2012 16:40 — forked from guilleiguaran/passwords_controller.rb
StrongParameters with Devise
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
@abeluck
abeluck / gpg-offline-master.md
Last active October 22, 2023 02:59 — forked from KenMacD/cmd.md
GPG Offline Master Key w/ smartcard