Skip to content

Instantly share code, notes, and snippets.

@gpfeiffer
gpfeiffer / extended_gcd.rb
Last active January 29, 2022 14:16
Extended Euclidean Algorithm in Ruby
#############################################################################
##
## extended_gcd.rb
##
## given non-negative integers a > b, compute
## coefficients s, t such that gcd(a, b) == s*a + t*b
##
def extended_gcd(a, b)
# trivial case first: gcd(a, 0) == 1*a + 0*0
@basgys
basgys / simple_paperclip.rb
Created June 5, 2013 08:25
Use Paperclip without ActiveRecord
# == Paperclip without ActiveRecord
#
# Simple and lightweight object that can use Paperclip
#
#
# Customized part can be extracted in another class which
# would inherit from SimplePaperclip.
#
# class MyClass < SimplePaperclip
# attr_accessor :image_file_name # :<atached_file_name>_file_name
@juno
juno / styles_controller.rb
Created June 12, 2013 11:16
Rails 3.2でコントローラーアクションの実行時に動的にSassテンプレートをCSS化する方法。 template.sass.erb => template.sass => CSS
class StylesController
def show
# Local variables assign to ERb
locals = {
base_color: current_user.base_color
}
# Render ERb to Sass (app/views/styles/template.sass.erb)
sass_contents = self.class.new.render_to_string('template',
formats: [:sass],
@tsuemura
tsuemura / ja-SR.js
Last active November 16, 2019 06:52
CodeceptJS神龍語翻訳ファイル
module.exports = {
I: '我が名は神龍',
actions: {
waitForElement: '要素が表示されるまで待ってやろう',
waitForClickable: 'クリック可能になるまで待ってやろう',
waitForVisible: '要素が見えるようになるまで待ってやろう',
waitForText: 'テキストが表示されるまで待ってやろう',
refresh: 'ページを更新してやろう',
amOnPage: 'URLにアクセスしてやろう',
click: 'クリックしてやろう',