Skip to content

Instantly share code, notes, and snippets.

View dfl's full-sized avatar

David Löwenfels dfl

View GitHub Profile
@josevalim
josevalim / _yerb.rb
Created March 18, 2010 16:41
Who needs HAML when you have YAML + ERB?
# = YERB
#
# Who needs HAML when you have YAML + ERB? ;)
#
# See example.yaml below for an example. You can run this code
# by cloning this gist and then `ruby _yerb.rb example.yaml`.
#
# Notice that you need Ruby 1.9 so the hash order is preserved.
# Obviously, this is just for fun. Definitely slow as hell.
#
@asux
asux / deploy.rb
Last active September 27, 2015 04:38
My typical multistaging deploy.rb for Vlad
require 'bundler/vlad'
require 'vlad/rvm'
set :default_stage, 'production'
set :shared_paths, {
'log' => 'log',
'system' => 'public/system',
'pids' => 'tmp/pids',
'sockets' => 'tmp/sockets',
@JangoSteve
JangoSteve / cache.rake
Created November 17, 2011 03:32
Automatically cache pages in Rails, put this in /lib/tasks/cache.rake
# See rails source:
# https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/caching/pages.rb
#
# Turn on caching in development, by changing this line to true in config/environments/development.rb:
#
# config.action_controller.perform_caching = true
#
# Then run:
#
# bundle exec rake pages:cache
class Users::Register
def self.call(attributes)
new(attributes).call
end
def initialize(attributes)
@attributes = attributes
end
@coreyhaines
coreyhaines / .rspec
Last active August 15, 2024 15:13
Active Record Spec Helper - Loading just active record
--colour
-I app
@felipeelias
felipeelias / spec_helper.rb
Last active December 10, 2015 17:48
Simple 'database cleaner' approach using `config.around`. Was able to cut down some seconds out of the suite. Thanks to @brandonhilkert
RSpec.configure do |config|
config.around do |example|
# For examples using capybara-webkit for example.
# Remove this if you don't use it or anything similar
if example.metadata[:js]
example.run
ActiveRecord::Base.connection.execute("TRUNCATE #{ActiveRecord::Base.connection.tables.join(',')} RESTART IDENTITY")
else
ActiveRecord::Base.transaction do
@dhavaln
dhavaln / PlaySoundsViewController.swift
Last active August 29, 2019 13:42
Change Pitch Rate of Sound in Swift - XCode 6.4
var engine: AVAudioEngine!
var file: AVAudioFile!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
engine = AVAudioEngine()
audioFile = AVAudioFile(forReading: filePathUrl, error: nil)
@wannyk
wannyk / SVD.swift
Created October 30, 2015 08:04
MATLAB svd(x) in Swift
//
// SVD.swift
//
// Created by Dongwan Kim on 2015. 10. 30..
//
/* MATLAB svd(X)
For the matrix
@mnishiguchi
mnishiguchi / rails_js_timezone.md
Last active June 16, 2025 15:12
Rails, JS - Time zone

Time zone considerations for a Rails app

Time zones in Rails (3 types)

1. system time

  • Our machine's time zone.
# Check our system time zone.
Time.now.getlocal.zone
@spk
spk / deploy.yaml
Created January 7, 2020 10:36
Github Action Heroku Git Deploy
# https://github.com/marketplace/actions/checkout
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#issue-comment-event-issue_comment
# https://devcenter.heroku.com/changelog-items/775
# https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
# https://github.com/cirrus-actions/rebase#installation
# https://github.com/actions/heroku/issues/10
---
name: Deploy to HEROKU_APP_NAME
on: