Skip to content

Instantly share code, notes, and snippets.

let alreadyRun = document.querySelector('body').classList.contains("vl-bookmarklet");
let domainCheck = window.location.origin == "http://legaldiary.courts.ie"
function wrap(el, wrapper) {
el.parentNode.insertBefore(wrapper, el);
wrapper.appendChild(el);
}
function addStyle(styleString) {
const style = document.createElement('style');
@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 / extract.rb
Created March 7, 2018 15:24
Dig in hashes or arrays
def extract_stuff(stuff, path)
path.empty? stuff : extract_stuff(stuff[path.shift], path)
end
@jcsrb
jcsrb / map-values-async.js
Created January 28, 2018 17:24
Lodash's .mapValues but for async functions
const mapValuesAsync = (obj, asyncFn) => {
const keys = Object.keys(obj);
const promises = keys.map(k => {
return asyncFn(obj[k]).then(newValue => {
return {key: k, value: newValue};
});
});
return Promise.all(promises).then(values => {
const newObj = {};
values.forEach(v => {
### Keybase proof
I hereby claim:
* I am jcsrb on github.
* I am jcsrb (https://keybase.io/jcsrb) on keybase.
* I have a public key ASAPauepdarl-YvGUpS_RF7U_p6RxbLQ5f7splmcXzQnaQo
To claim this, I am signing this object:
@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 .

Keybase proof

I hereby claim:

  • I am jcsrb on github.
  • I am jcsrb (https://keybase.io/jcsrb) on keybase.
  • I have a public key ASCcxeaPZDsY8ETLqzw4mxAFz2nD6WD0lxGjm0avOP2_RQo

To claim this, I am signing this object:

@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 / a.html
Last active September 23, 2016 12:08
<html style="margin:0">
<body style="margin:0">
<img src='http://i.imgur.com/QwA1fvX.png' width='100%'>
</body>
</html>
@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