Skip to content

Instantly share code, notes, and snippets.

View jll90's full-sized avatar

Nicola Luongo jll90

View GitHub Profile
@jll90
jll90 / install.sh
Created September 7, 2021 14:38
Elixir Language Server Installation
cd ## change to home directory
git clone git@github.com:elixir-lsp/elixir-ls.git .elixir-ls
cd .elixir-ls
mkdir release
mix deps.get && mix compile
mix elixir_ls.release -o release
## language server lives in
## ~/.elixir-ls/release/language_server.sh
@jll90
jll90 / auth.lua
Last active December 24, 2020 02:12
Lua Nginx Module Authorization auth.lua
function parseAuthHeader(headers)
local authHeader = headers['Authorization']
if authHeader == nil then
return nil
end
return string.match(authHeader, "Bearer%s(%a+)")
end
function write403Message ()
@jll90
jll90 / nginx.conf
Last active December 24, 2020 02:24
Lua Nginx Module Authorization nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
@jll90
jll90 / Dockerfile
Created December 24, 2020 01:50
Lua Nginx Module Authorization Dockerfile nginx
FROM fabiocicerchia/nginx-lua
COPY ./nginx.conf /etc/nginx/nginx.conf
RUN mkdir /etc/nginx/conf.d
RUN mkdir /etc/nginx/lua
COPY lua/. /etc/nginx/lua
CMD [ "nginx", "-g", "daemon off;" ]
@jll90
jll90 / docker-compose.yml
Last active December 24, 2020 01:40
Lua Nginx Module Authorization docker-compose.yml
version: "3"
networks:
cluster:
external: false
services:
proxy:
build:
context: .
@jll90
jll90 / write-to-csv.exs
Created July 27, 2020 21:27
Write CSV data to a file
f = File.stream!("Locations.csv")
%File.Stream{
line_or_bytes: :line,
modes: [:raw, :read_ahead, :binary],
path: "Locations.csv",
raw: true
}
City |> Repo.all() |> Repo.preload([:county, county: [:state]]) |> Enum.map(&([&1.id, &1.county.state.id])) |> CSV.encode() |> Stream.into(f) |> Stream.run()
@jll90
jll90 / throttle-debounce-comparison.js
Created February 13, 2020 14:55
JavaScript Throttle & Debounce Comparison
const throttle = (func, limit) => {
let engaged = false;
return function () {
const args = arguments;
const context = this;
if (!engaged) {
func.apply(context, args);
engaged = true;
setTimeout(() => engaged = false, limit);
}
@jll90
jll90 / content-flex-grow-bottom-nav.html
Created February 3, 2019 19:58
Page content flex-grows between top navbar and footer
<html>
<style>
body {
padding: 0;
margin: 0;
box-sizing: border-box;
width: 100%;
background: red;
height: 100vh;
@jll90
jll90 / sw-testing.sh
Last active March 10, 2020 16:27
Chrome Treat Insecure Origin as Secure (useful for SW testing)
#For Ubuntu 16.04 LTS
#First you need to know where google-chrome is installed. To find out run:
which google-chrome
#For my case, google-chrome is installed inside both /usr/bin/google-chrome and /usr/bin/google-chrome-stable.
#I decided to use the stable version.
#Now, list the domains that you'd like chrome to treat as secure. Make sure that you have access to the folder following --user-data-dir. I used $HOME for convenience.
#Run the following command:
@jll90
jll90 / update-ruby.sh
Last active August 26, 2021 17:57
Update ruby version with rbenv
#!/bin/bash
#This command lists all the ruby versions available for install. Make sure the ruby version you want to install is shown on the list
#In this case we will be looking to install 2.3.1
rbenv install --list
#In case the ruby version (2.3.1) you want to install is not on the list, you will have to update both the rbenv
#and the ruby_build/plugin repositories
#Run the following two commands to update the corresponding git repositories (assuming both are installed inside your home folder)