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
# frozen_string_literal: true | |
require "active_record" | |
module JustAndExactly | |
module ActiveRecordExtensions | |
MultipleRecordsFound = Class.new(ActiveRecord::ActiveRecordError) | |
# Like +first!+, but will also fail if the query would match more than | |
# one record. |
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
PS1='\[\e[1m\]\[\e[34m\]\u@\h$([ "$DOCKER_MACHINE_NAME" = "" ] || echo " \[\e[33m\][docker-machine:$DOCKER_MACHINE_NAME]\[\e[34m\]"): \[\e[35m\]\w\[\e[33m\]$(__git_ps1) \[\e[34m\]$\[\e[0m\] ' | |
docker-machine-auth () { | |
MACHINE_NAME=$1 | |
if [ "$MACHINE_NAME" = "" ] | |
then | |
eval "$(docker-machine env -u)" | |
else | |
eval "$(docker-machine env $MACHINE_NAME)" | |
fi | |
} |
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 :db do | |
desc "Wait for db. Used for initial boot up" | |
task wait: :environment do | |
puts "*** Giving DB time to boot" | |
catch :done do | |
10.times do | |
Timeout.timeout(1) do | |
begin | |
ActiveRecord::Base.establish_connection | |
ActiveRecord::Base.connection.execute("SELECT NOW()") |
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 'raven' | |
require 'rake/task' | |
if Rails.env.production? | |
Raven.configure do |config| | |
config.dsn = 'http://xxx:xxx@app.getsentry.com/xxxxx' | |
end | |
module Rake | |
class Task |
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 "open3" | |
def execute_shell(command, verbose: false) | |
Rails.logger.info "[SHELL] #{command}" | |
# see: https://nickcharlton.net/posts/ruby-subprocesses-with-stdout-stderr-streams.html | |
# see: http://stackoverflow.com/a/1162850/83386 | |
output = [] | |
Open3.popen3(command) do |stdin, stdout, stderr, thread| | |
# read each stream from a new thread |
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
<?php | |
function is_valid_iban($str) { | |
static $charmap = array ( | |
'A' => 10, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15, 'G' => 16, 'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20, 'L' => 21, 'M' => 22, 'N' => 23, 'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27, 'S' => 28, 'T' => 29, 'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34, 'Z' => 35, | |
); | |
if (!preg_match("/\A[A-Z]{2}\d{2} ?[A-Z\d]{4}( ?\d{4}){1,} ?\d{1,4}\z/", $str)) { | |
return false; | |
} | |
$iban = str_replace(' ', '', $str); | |
$iban = substr($iban, 4) . substr($iban, 0, 4); |
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
import sys | |
import os | |
import subprocess | |
def git(args, **kwargs): | |
environ = os.environ.copy() | |
if 'repo' in kwargs: | |
environ['GIT_DIR'] = kwargs['repo'] | |
if 'work' in kwargs: | |
environ['GIT_WORK_TREE'] = kwargs['work'] |
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
# Install dependencies manually | |
apt-get install odbcinst1debian2 libodbc1 unixodbc libpq5 | |
# Fetch deb package | |
mkdir -p /usr/local/build ; cd /usr/local/build && [-f sphinxsearch_2.1.4-release-0ubuntu11~precise_amd64.deb ] || wget http://sphinxsearch.com/files/sphinxsearch_2.1.4-release-0ubuntu11~precise_amd64.deb | |
# Install package | |
dpkg --install /usr/local/build/sphinxsearch_2.1.4-release-0ubuntu11~precise_amd64.deb |
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
<!-- app/views/devise/omniauth/link_user.html.erb --> | |
<h2>Link your account</h2> | |
<%= form_for(@user, :url => user_omniauth_link_url, :html => { :method => :put }) do |f| %> | |
<p>You already have an account, that was created with email and password. To link your Facebook account, please enter your password. If you can't remember your password, you can recover it by clicking the link below.</p> | |
<%= render "devise/shared/error_messages" %> | |
<div> |
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
# config/initializers/sprockets.rb | |
module Sprockets | |
if respond_to?(:register_transformer) | |
register_mime_type 'text/jsx', extensions: ['.jsx'], charset: :unicode | |
register_transformer 'text/jsx', 'application/javascript', ::BabelTransformer | |
register_preprocessor 'text/jsx', DirectiveProcessor | |
end | |
if respond_to?(:register_engine) | |
args = ['.jsx', ::BabelTransformer] |