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
gem install bundler -v $(cat Gemfile.lock | grep -A1 "BUNDLED WITH" | tail -n 1 | xargs) |
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
{ | |
"session_id": 7621671552239865, | |
"session_last_activity": 50548431047, | |
"session_transport": "janus.transport.websockets", | |
"handle_id": 6462710068811725, | |
"loop-running": true, | |
"created": 50218045447, | |
"current_time": 50554957482, | |
"plugin": "janus.plugin.videoroom", | |
"plugin_specific": { |
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 "thread" | |
require "awesome_print" | |
start_time = Time.now | |
results = { body: [] } | |
queue = Queue.new | |
0..50.times { |x| queue.push x } |
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
defmodule Math do | |
def sum(list) do | |
sum(list, 0) | |
end | |
def sum([], 0), do: 0 | |
def sum([], total) when total > 0, do: total | |
def sum(list, total) do |
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 Attachment < ActiveRecord::Base | |
belongs_to :attachable, :polymorphic => true | |
mount_uploader :item, AttachmentUploader | |
# background the storage of files to AWS and processing | |
# makes for fast uploads! | |
store_in_background :item | |
attr_accessible :item | |
before_save :update_attachment_attributes |
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 "logstash-logger" | |
# Sensible configuration options that we want to share accross ENVs | |
Rails.application.configure do | |
# Logstash has a bunch more config options that have sensible defaults. | |
config.logstash.uri = ENV["LOG_SERVER"] | |
# Use the lowest log level to ensure availability of diagnostic information | |
# when problems arise. | |
config.log_level = ENV["LOG_LEVEL"] || :info |
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
# find any jobs that chronologically overlap an array of job_assignments | |
# ex: find any jobs that overlap an interpreter's existing jobs via the job_assignments | |
def self.overlapping(job_assignments) | |
jobs_table = Job.arel_table | |
query = Job.scoped | |
job_assignments.each do |ja| | |
query = query.where((jobs_table[:start_datetime].in(ja.scheduled_start..ja.estimated_end)). | |
or(jobs_table[:end_datetime].in(ja.scheduled_start..ja.estimated_end))) | |
end | |
query |
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
if Rails.env.staging? || Rails.env.production? | |
begin | |
redis_config = YAML.load_file(Rails.root + 'config/redis.yml')[Rails.env] | |
Sidekiq.configure_server do |config| | |
config.redis = { :url => "redis://#{redis_config['host']}:#{redis_config['port']}", :namespace => 'nin' } | |
end | |
# When in Unicorn, this block needs to go in unicorn's `after_fork` callback: | |
Sidekiq.configure_client do |config| |
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 | |
# Instructions | |
# 1. Download to ~/scripts | |
# 2. chmod u+x ~/scripts/docker_scripts.sh | |
# 3. Add the /scripts into your PATH by including this in your ~/.bashrc `export PATH="$PATH:/$HOME/scripts"` | |
# 4. Open a new terminal and execute `docker_scripts.sh` | |
# 5. Choose from any of the options at the prompt | |
function stop_containers() { | |
id=$(docker ps | awk 'NR > 1 {print $1}' | tr '\n' ' ') |
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
# Keep your sanity by making a simple change to Dogma config. | |
# Known to be compatible with v0.0.11 | |
# Override the default 80 for max_length and set it to 120 | |
config :dogma, | |
rule_set: Dogma.RuleSet.All, | |
override: %{ LineLength => [ max_length: 120 ] } |
NewerOlder