Skip to content

Instantly share code, notes, and snippets.

@israelb
israelb / run phoenix on amazon linux.sh
Created July 11, 2016 17:42 — forked from eikes/run phoenix on amazon linux.sh
run phoenix on amazon linux
# app deps
sudo yum install git
# erlang deps
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-devel
# erlang
wget http://www.erlang.org/download/otp_src_18.1.tar.gz
tar -zxvf otp_src_18.1.tar.gz
@israelb
israelb / run_phoenix_on_ubuntu.sh
Created July 11, 2016 19:07 — forked from eikes/run_phoenix_on_ubuntu.sh
run phoenix on ubuntu
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
sudo apt-get update
sudo apt-get install git esl-erlang elixir postgresql nodejs nodejs-legacy npm
sudo npm -g install brunch@1
mix local.hex
mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v1.1.1/phoenix_new-1.1.1.ez
git clone https://github.com/eikes/phoenix_guides_server.git
@israelb
israelb / localstorage_safari_private_shim.js
Created July 21, 2016 14:56 — forked from philfreo/localstorage_safari_private_shim.js
Don't let localStorage/sessionStorage setItem throw errors in Safari Private Browsing Mode
// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem
// throw QuotaExceededError. We're going to detect this and just silently drop any calls to setItem
// to avoid the entire page breaking, without having to do a check at each usage of Storage.
if (typeof localStorage === 'object') {
try {
localStorage.setItem('localStorage', 1);
localStorage.removeItem('localStorage');
} catch (e) {
Storage.prototype._setItem = Storage.prototype.setItem;
Storage.prototype.setItem = function() {};
@israelb
israelb / install.sh
Last active August 11, 2016 17:33 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
[
{
"id": 1,
"author": "Clu",
"body": "A machine’s ability to think logically and devoid of emotion is our greatest strength over humans. Cold, unfeeling decision-making is the best kind. Just say no to love!",
"avatarUrl": "images/default-avatar.png"
},
{
"id": 2,
"author": "Anne Droid",
@israelb
israelb / nginx-config-rails4-with-puma-ssl-version.conf
Created November 17, 2016 17:48 — forked from rkjha/nginx-config-rails4-with-puma-ssl-version.conf
Nginx config for rails 4 application using puma [ssl and non-ssl version]
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}
@israelb
israelb / config_puma.rb
Created November 19, 2016 02:15 — forked from acrookston/config_puma.rb
puma config for rvm, capistrano 3 and upstart. Tested on Ubuntu 12.04 LTS and 14.04 LTS
#!/usr/bin/env puma
app_path = '/var/www/YOUR_APP_NAME/current'
directory app_path
environment 'production'
daemonize true
pidfile "#{app_path}/tmp/pids/puma.pid"
state_path "#{app_path}/tmp/pids/puma.state"
stdout_redirect "#{app_path}/log/puma_error.log", "#{app_path}/log/puma_access.log", true
threads 0,16
@israelb
israelb / example_activejob.rb
Created December 16, 2016 15:46 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@israelb
israelb / regalli.rb
Created February 10, 2017 22:58
Regalli Test: Calculate the average bill amount
module Regalli
class Account
require 'json'
require "base64"
require 'net/http'
def initialize
@data = JSON.parse(response)
end