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);| #!/usr/bin/env bash | |
| # Prune local branches whose PRs are merged (and optionally closed-unmerged). | |
| # Also removes the matching worktree if one exists. | |
| # | |
| # Usage: | |
| # prune-stale-branches # prompt per merged branch (default) | |
| # prune-stale-branches -f # also include closed-unmerged PRs | |
| # prune-stale-branches --apply # no prompts, delete all candidates | |
| # prune-stale-branches --dry-run # print only, no deletion |
| #!/bin/bash | |
| pr_url="$1" | |
| if [ -z "$pr_url" ]; then | |
| pr_url="$(pbpaste)" | |
| if [[ "$pr_url" =~ ^https://github\.com/.+/pull/[0-9]+ ]]; then | |
| echo "Using PR URL from clipboard: $pr_url" | |
| else | |
| echo "Usage: slapr <github-pr-url>" | |
| echo "Copies a Slack-formatted PR link to clipboard" | |
| echo "You can provide an argument, or simply copy the GitHub PR URL and run slapr with no args" |
| #!/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 |