Skip to content

Instantly share code, notes, and snippets.

@jcsrb
jcsrb / authorization.md
Created June 19, 2018 17:39 — forked from nikneroz/authorization.ex
Elixir + Phoenix Framework 1.3 + Guardian 1.0 + JWT(Refresh, Revoke, Recover) + Comeonin

Elixir + Phoenix Framework 1.3 + Guardian + JWT(Refresh, Revoke, Recover) + Comeonin

User model bootstrap

Let's generate User model and controller.

mix ecto.create # create DB table
mix phx.gen.json Accounts User users email:string password_hash:string # scaffold users structure
@jcsrb
jcsrb / a2dp.py
Created March 27, 2017 08:45 — forked from pylover/a2dp.py
Fixing bluetooth stereo headphone/headset problem in ubuntu 16.04, 16.10 and also debian jessie, with bluez5.
#! /usr/bin/env python3.5
"""
Fixing bluetooth stereo headphone/headset problem in ubuntu 16.04 and also debian jessie, with bluez5.
Workaround for bug: https://bugs.launchpad.net/ubuntu/+source/indicator-sound/+bug/1577197
Run it with python3.5 or higher after pairing/connecting the bluetooth stereo headphone.
This will be only fixes the bluez5 problem mentioned above .
@jcsrb
jcsrb / Install Ruby and RubyGems
Last active January 12, 2018 07:17 — forked from chiraggude/Install Ruby and RubyGems
Install Ruby 2.2.1 and RubyGems 2.4.8 on CentOS 6.5
# Install Ruby
wget http://ftp.ruby-lang.org/pub/ruby/2.2/ruby-2.2.1.tar.gz
tar xvzf ruby-2.2.1.tar.gz
cd ruby-2.2.1
./configure --prefix=/usr
make
make install
# remove "ruby-2.1.1" folder in /root
@jcsrb
jcsrb / install-squid.sh
Created August 29, 2016 16:38 — forked from cdodd/install-squid.sh
Install a basic squid proxy with authentication on Centos 6 x64. Just modify the variables at the top and run the script on a clean system.
#!/bin/sh
PROXY_USER=user
PROXY_PASS=password
PROXY_PORT=3128
# Clear the repository index caches
yum clean all
# Update the operating system
@jcsrb
jcsrb / InstallHaProxy.sh
Last active August 31, 2016 10:51
RHEL 6.7 Install HAProxy From Source (1.6.9 release pre configured). chmod +x InstallHaProxy.sh then ./InstallHaProxy.sh
#!/bin/bash
### VARIABLES ###
PRE_PACK="openssl-devel pcre-devel make gcc"
VER="1.6.9"
# Setup Colours
black='\E[30;40m'
red='\E[31;40m'
@jcsrb
jcsrb / InstallHaProxy.sh
Created August 29, 2016 15:41 — forked from ChrisMcKee/InstallHaProxy.sh
Centos 6.5 Install HAProxy From Source (1.5.1 release pre configured). chmod +x InstallHaProxy.sh then ./InstallHaProxy.sh
#!/bin/bash
### VARIABLES ###
PRE_PACK="openssl-devel pcre-devel make gcc"
VER="1.5.1"
# Setup Colours
black='\E[30;40m'
red='\E[31;40m'
@jcsrb
jcsrb / rate_limit.js
Created August 22, 2016 12:39 — forked from mattheworiordan/rate_limit.js
Rate limiting function calls with JavaScript and Underscore.js
/* Extend the Underscore object with the following methods */
// Rate limit ensures a function is never called more than every [rate]ms
// Unlike underscore's _.throttle function, function calls are queued so that
// requests are never lost and simply deferred until some other time
//
// Parameters
// * func - function to rate limit
// * rate - minimum time to wait between function calls
// * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request
#/bin/bash
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
if [ -z "$REPO_URL" ]; then
echo "-- ERROR: Could not identify Repo url."
echo " It is possible this repo is already using SSH instead of HTTPS."
exit
fi
@jcsrb
jcsrb / style.js
Last active August 29, 2015 14:12 — forked from potch/style.js
// Bad
"Your Framework Sucks."
// Bad
"Browserify? Have you heard about WebPack?"
// Bad
"Ember vs Angular: 10 Things You Should Know"
require 'net/http'
module Net
class HTTP
def self.enable_debug!
raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development'
class << self
alias_method :__new__, :new
def new(*args, &blk)
instance = __new__(*args, &blk)
instance.set_debug_output($stderr)