# application.rb:
config.exceptions_app = lambda do |env|
exception = env['action_dispatch.exception']
params = env['action_dispatch.request.parameters']
request = Rack::Request.new(env)
status_code = ActionDispatch::ExceptionWrapper.new(env, exception).status_code
Rails.logger.info [
source "https://rubygems.org" | |
gem "rack-proxy" | |
gem "sidekiq" | |
gem "sinatra" | |
gem "sinatra-contrib" | |
gem "py" |
module Commands | |
module Meeting | |
AcceptSchema = Dry::Validation.Schema do | |
required(:user_id).filled | |
required(:status).value(eql?: :scheduled) | |
end | |
class Accept < Command | |
def call | |
return validate if validate.failure? |
// Faster solution for: | |
// http://www.boyter.org/2017/03/golang-solution-faster-equivalent-java-solution/ | |
// With threading. | |
// g++ -std=c++11 -Wall -Wextra -O3 -pthread | |
// On my computer (i5-6600K 3.50 GHz 4 cores), takes about ~160 ms after the CPU | |
// has warmed up, or ~80 ms if the CPU is cold (due to Turbo Boost). | |
// How it works: Start by generating a list of losing states -- states where the | |
// game can end in one turn. Generate a new list of states by running the game |
# Adjust Rxvt to suit your terminal emulator | |
# Created with | |
# ITERM_COLOR_MULTIPLIER=2.5 ./itermcolors2Xdefaults.rb Jellybeans.itermcolors | |
# https://github.com/richo/jellybeans.vim/blob/c7ff7e9555881a5671fcc8753b381ba142b5ea82/Xdefaults/jellybeans.Xdefaults | |
Rxvt*color0: #393939 | |
Rxvt*color1: #ca674a | |
Rxvt*color2: #96a967 | |
Rxvt*color3: #d3a94a | |
Rxvt*color4: #5778c1 | |
Rxvt*color5: #9c35ac |
Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.
This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would
#Simple Authentication with Bcrypt
This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.
The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).
You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault
##Steps
AllCops: | |
RunRailsCops: true | |
# Commonly used screens these days easily fit more than 80 characters. | |
Metrics/LineLength: | |
Max: 120 | |
# Too short methods lead to extraction of single-use methods, which can make | |
# the code easier to read (by naming things), but can also clutter the class | |
Metrics/MethodLength: |
// adapted from http://www.youtube.com/watch?v=qNM0k522R7o | |
extern vec2 size; | |
extern int samples = 5; // pixels per axis; higher = bigger glow, worse performance | |
extern float quality = 2.5; // lower = smaller glow, better quality | |
vec4 effect(vec4 colour, Image tex, vec2 tc, vec2 sc) | |
{ | |
vec4 source = Texel(tex, tc); | |
vec4 sum = vec4(0); |
import numpy as np | |
from math import pi, log | |
import pylab | |
from scipy import fft, ifft | |
from scipy.optimize import curve_fit | |
i = 10000 | |
x = np.linspace(0, 3.5 * pi, i) | |
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 * | |
np.random.randn(i)) |