Skip to content

Instantly share code, notes, and snippets.

View shamil614's full-sized avatar

scott hamilton shamil614

View GitHub Profile
@shamil614
shamil614 / search_bundler_version.sh
Created January 15, 2020 22:31
install bundler from gemfile.lock
gem install bundler -v $(cat Gemfile.lock | grep -A1 "BUNDLED WITH" | tail -n 1 | xargs)
@shamil614
shamil614 / no_publishers.json
Created August 9, 2019 16:46
Janus Admin Panel No Publishers
{
"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": {
@shamil614
shamil614 / thread_queue.rb
Created February 8, 2017 22:26
thread queue example
require "thread"
require "awesome_print"
start_time = Time.now
results = { body: [] }
queue = Queue.new
0..50.times { |x| queue.push x }
@shamil614
shamil614 / math.exs
Created November 29, 2016 17:36
Learn Elixir Episode 06
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
@shamil614
shamil614 / attachment.rb
Created November 2, 2012 16:12
Carrierwave Attachment Uploader with AWS and Zencoder.
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
@shamil614
shamil614 / logstash.rb
Created June 10, 2016 16:57
Snipped of how Logstash is setup
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
# 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
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|
@shamil614
shamil614 / docker_scripts.sh
Last active December 4, 2015 17:41
Quick and dirty bash scripts to streamline repetitive tasks.
#!/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' ' ')
@shamil614
shamil614 / config.exs
Last active November 11, 2015 16:06
Override Dogma LineLength
# 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 ] }