Skip to content

Instantly share code, notes, and snippets.

import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static targets = ['launcher']
initialize () {
this.launchModal = this.launchModal.bind(this)
}
connect () {
@awd
awd / circle.yml
Created April 11, 2014 18:59
Circle CI database override
## Customize database setup
database:
override:
- echo "no database setup"
en:
errors:
format: "%{message}"
messages:
blank: "%{attribute} can't be blank"
activerecord:
errors:
models:
user:
attributes:
@awd
awd / gist:5859328
Last active December 18, 2015 23:08
Save yourself some key strokes bro. Drop this into your .bash_profile
function gitmerged() {
git checkout master; git pull; git fetch -p; git branch -D $1
}
@awd
awd / forward.bash
Created March 27, 2013 20:50
Ruby 2.0.0, RVM 1.19.0 - there is a known issue in rubygems and rvm at this time, it might be related.
/Users/username/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'forward' (>= 0) among 120 total gem(s) (Gem::LoadError)
from /Users/username/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /Users/username/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /Users/username/.rvm/gems/ruby-2.0.0-p0@global/bin/forward:22:in `<main>'
from /Users/username/.rvm/gems/ruby-2.0.0-p0@global/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/username/.rvm/gems/ruby-2.0.0-p0@global/bin/ruby_noexec_wrapper:14:in `<main>'
@awd
awd / buffer.rb
Created January 12, 2013 19:52
Determine if a number is Prime. I was recently asked to create a method which given a number would return if a number was Prime or not.
# determine if a number is prime
# not divisible by a natural number greater than 1, and less than itself
def is_prime?(n)
return false if n == 1
# start the range greater than 1
# do not include the number itself
range = (2..(n-1)).to_a
detection = range.detect do |n2|
@awd
awd / gist:3994607
Created November 1, 2012 16:06
how to determine one name vs another..
selections = []
1000.times { selections << ["manage", "settings"].sample }
selections.select { |s| s == "manage" }.size > selections.select { |s| s == "settings" }.size
@awd
awd / like_test.rb
Created July 24, 2012 17:34
wrap validation rules in a context
require 'test_helper'
class LikeTest < ActiveSupport::TestCase
should belong_to(:viewable)
should belong_to(:user)
context "validations" do
subject { Like.create(user_id: 1, viewable_id: 2, liked: false) }
should validate_uniqueness_of(:user_id).scoped_to(:viewable_id)
resources :courses, only: [:show] do
resources :assessments, controller: :assessment_results, only: [:create, :edit, :show], path_names: { edit: 'start' }
member do
get ':lesson_id', to: 'lessons#show', as: 'lesson'
end
end
:tddium:
:submodules: true