This PR adds support for default parameter values in function definitions, reducing boilerplate and improving API ergonomics:
// Define with defaults
lowpass(freq, q=0.707) = fi.resonlp(freq, q, 1);| #!/bin/bash | |
| filetype=$(file -b --mime-type "$1") | |
| if [[ "$(uname)" == "Darwin" ]]; then # MacOS | |
| # Check if ImageMagick is installed | |
| if ! command -v identify >/dev/null 2>&1; then | |
| echo "ImageMagick is not installed. Installing..." | |
| brew install imagemagick | |
| fi |
| # test helpers for integration testing written by David Lowenfels | |
| # place in lib/internaut/shoulda_extensions.rb | |
| require "rails-dom-testing" # for css_select method | |
| ## Example usage | |
| module Internaut | |
| module ShouldaExtensions | |
| extend ActiveSupport::Concern |
| # This script requires the nokogiri gem, and youtube-dl to be installed. | |
| # It will fetch video, mp3, and text results. | |
| # download cookies.txt using Chrome plugin "Get cookies.txt" | |
| # download page source as course-page.html | |
| quality = "iphone-360p" # to find quality options, use youtube-dl -v -F --cookies cookies.txt https://{KAJABI_COURSE}/categories/#####/posts/##### | |
| cookies = "=cookies.txt" | |
| course_url = "https://www.MYCOURSE.COM" | |
| domain = course_url.split("/")[2] |
| require 'yaml' | |
| require 'fileutils' | |
| namespace :db do | |
| desc "create the db/backup directory if it doesn't exist" | |
| task :create_backup_dir do | |
| FileUtils.mkdir_p backup_dir | |
| end |
| # mysql db backup and restore for rails | |
| # by David Lowenfels <david@internautdesign.com> 4/2011 | |
| require 'yaml' | |
| namespace :db do | |
| def backup_prep | |
| @directory = File.join(RAILS_ROOT, 'db', 'backup') | |
| @db = YAML::load( File.open( File.join(RAILS_ROOT, 'config', 'database.yml') ) )[ RAILS_ENV ] | |
| @db_params = "-u #{@db['username']} #{@db['database']}" |
| require 'digest/sha1' | |
| module FactoriesAndWorkers | |
| module Factory | |
| def self.included( base ) | |
| def factory( kind, default_attrs, opts={}, &block ) | |
| FactoryBuilder.new( kind, default_attrs, opts, self, &block ) | |
| end |
| module Internaut | |
| module ActiveRecord | |
| module CallbackExtensions | |
| def self.included(base) #:nodoc: | |
| base.extend ClassMethods | |
| base.class_eval do | |
| class_inheritable_accessor :disabled_callbacks | |
| self.disabled_callbacks = [] # set default to empty array | |
| end |
| # example unit test context using should_change and should_not_change | |
| context "Given a user" do | |
| setup do | |
| @user = create_user | |
| end | |
| context "when sent initials with a hyphen and lower case" do | |
| setup do | |
| @user.update_attributes!( :first_name => "Jason", :last_name => "happy-Klein" ) |