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 'digest/sha2' | |
# usage: | |
# PeriodicalToken.generate(:min) # -> returns unique token in a minute. | |
# | |
class PeriodicalToken | |
SALT = 'RANDOMLLY-GENERATED-STRING' | |
RANGE_TO_DIV = { | |
min: 60, | |
min5: 60 * 5, |
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
FROM ruby:2.3.0 | |
# see update.sh for why all "apt-get install"s have to stay as one long line | |
RUN apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/* | |
# see http://guides.rubyonrails.org/command_line.html#rails-dbconsole | |
RUN apt-get update && apt-get install -y mysql-client postgresql-client sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/* | |
ENV RAILS_VERSION 5.0.0.beta3 | |
RUN gem install rails --version "$RAILS_VERSION" |
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 'tmpdir' | |
require 'shellwords' | |
webloc_file = ARGV[0] | |
webloc_ext = File.extname(webloc_file) | |
webarchive_file = webloc_file.gsub(/#{webloc_ext}$/, '.webarchive') | |
url = nil |
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
# GenericUtils | |
module GenericSupport | |
module Pathable | |
module ClassMethods | |
def path(hash, *pathes) | |
target = hash | |
pathes.map! do |p| | |
p.to_s.split(/[\/\.]+/) | |
end | |
pathes.flatten.each do |element| |
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
module NOP | |
def self.nop(*args) | |
opts = args.extract_options! | |
methods = args | |
raise ArgumentError if methods.size < 2 | |
klass = methods.shift | |
raise ArgumentError unless klass.is_a?(Class) | |
do_backup, backup_prefix, backup_suffix = extract_backup_options opts[:backup] | |
methods.map(&:to_sym).each do |method| | |
next unless klass.instance_methods.include? method |
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
namespace :eb do | |
namespace :env do | |
desc "Fetch env vars from eb" | |
task :fetch, [:envname] do |t, params| | |
lines = `eb printenv #{params[:envname]}`.strip.split(/\r?\n/) | |
lines.shift if lines[0] =~ /Environment Variables:/ | |
hash = {} | |
lines.sort.each do |line| | |
if line =~ /^\s+(.+)\s+=\s+(.+)$/ | |
hash[$1] = $2 |
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
# note: This code does not point correct paths on "initializer". | |
# Use after all initialization process are completed. | |
# | |
class GetRoutePaths | |
def self.list | |
@@list ||= Rails.application.routes.routes.map { |r| r.path.spec.to_s }.uniq | |
end | |
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
class QueueHandlerController < ApplicationController | |
skip_before_action :verify_authenticity_token | |
before_action :verify_worker_tier | |
def receive | |
ActiveJob::Base.execute params | |
render text: '' | |
end | |
private | |
def verify_worker_tier |
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
upstream my_app { | |
server unix:///var/run/puma/my_app.sock; | |
} | |
server { | |
listen 80; | |
server_name _ localhost; # need to listen to localhost for worker tier | |
location / { | |
proxy_pass http://my_app; # match the name of upstream directive which is defined above |