This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"database/sql" | |
"database/sql/driver" | |
"errors" | |
"fmt" | |
_ "github.com/mattn/go-sqlite3" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: ./set-access-points.sh [network SSID] [network interface id = wlan0] | |
# Read in the arguements | |
ssid=$1; | |
interface=$2; | |
# SSID is required | |
if [ -z "$ssid" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "money" | |
class Decorator < BasicObject | |
undef_method :== | |
def initialize(component) | |
@component = component | |
end | |
def method_missing(name, *args, &block) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://api.rubyonrails.org/classes/ActiveRecord/EagerLoadPolymorphicError.html | |
# https://github.com/chaps-io/public_activity/issues/297 | |
# https://ksylvest.com/posts/2017-08-23/eager-loading-polymorphic-associations-with-ruby-on-rails | |
class ActivityFinder | |
attr_reader :activities, :user | |
def initialize(user) | |
@user = user | |
@activities = Activity.all.where(:user_id => user_ids). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://medium.com/rubyinside/asynchronous-elasticsearch-bulk-reindexing-with-rails-searchkick-and-sidekiq-26f2f9aa8513 | |
# https://github.com/ankane/searchkick | |
# 2.3.2 [unreleased] | |
# - Added wait option to async reindex | |
# Searchkick.reindex(async: {wait: true}) | |
# This code has been ported to searchkick. | |
require 'sidekiq/api' | |
# BulkReindexer | |
module BulkReindexer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comment < ActiveRecord::Base | |
delegate :email, to: author, prefix: true, allow_nil: true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'dotenv' | |
Dotenv.load | |
require 'aws-sdk' | |
# USAGE: | |
# Put credentials in .env file, wrapped in single quotes. DO NOT COMMMIT this file to git! | |
# Wrap values in single quotes and escape all quotes inside strings with \. | |
# bundle exec ruby script/dev/example_s3.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'dotenv' | |
Dotenv.load | |
require 'redis' | |
# USAGE: | |
# Put credentials in .env file, wrapped in single quotes. DO NOT COMMMIT this file to git! | |
# Wrap values in single quotes and escape all quotes inside strings with \. | |
# bundle exec ruby script/dev/example_redis-rb.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# USAGE: | |
# sudo port install pwgen | |
# bundle exec ruby script/dev/bash_friendly_password.rb nil 49 | |
def bash_friendly_password(password=nil, length=128) | |
password ||= `pwgen -syv #{length} 1` | |
password.size.times do |i| | |
password = password. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/a/29490456 | |
#!/bin/bash | |
# Uninstall node.js | |
# | |
# Options: | |
# | |
# -d Actually delete files, otherwise the script just _prints_ a command to delete. | |
# -p Installation prefix. Default /usr/local | |
# -f BOM file. Default /var/db/receipts/org.nodejs.pkg.bom |
NewerOlder