Skip to content

Instantly share code, notes, and snippets.

@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;
}
[
{
"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 / 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"
@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 / 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 / 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
# Console postgres command:
$ sudo -u postgres psql
# list users
\du
$ sudo su - postgres
$ psql
@israelb
israelb / angularjs_directive_attribute_explanation.md
Created June 20, 2016 19:01 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
<script type='text/javascript'>
//...
//...
gptadslots[6]= googletag.defineSlot('/72776159/LifeandStyle/' + var_section, [[300,250]],'box_4').defineSizeMapping(mappingBox).setTargeting('pos',['6']).addService(googletag.pubads());
// ...
//...
</script>
<div id='box_4'>
<script type='text/javascript'>
@israelb
israelb / base_controller.rb
Created May 18, 2016 14:41 — forked from dhoelzgen/base_controller.rb
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'