Skip to content

Instantly share code, notes, and snippets.

View jll90's full-sized avatar

Nicola Luongo jll90

View GitHub Profile
@jll90
jll90 / callbacks.js
Created January 22, 2016 02:05
Example of JavaScript callbacks.
// executes a single function
function single(callback){
callback();
}
function b(){
console.log("I'm b");
}
function d(){
@jll90
jll90 / install-ejabberd.sh
Last active October 7, 2018 11:34
Install ejabberd on centos7
#! bin bash
#This script installs a ejabberd on centos7
echo 'Updating packages...'
sudo yum update -y
echo 'Install wget'
sudo yum install wget -y
echo 'Download EPEL'
@jll90
jll90 / install-mysql.sh
Created May 24, 2016 12:52
Remove older version of mysql and install mysql 5.6 - Ubuntu 16.04
#! bin bash
#removes older packages
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
#removes configuration files
sudo rm -rf /var/lib/mysql
@jll90
jll90 / gist:a72ff1461c9918a2874cf4808f72e73f
Last active June 4, 2016 21:06
import geonames to postgresql
sudo -i -u postgres psql
CREATE DATABASE geonames;
DROP TABLE geoname;
CREATE TABLE geoname (
geonameid int,
name varchar(200),
asciiname varchar(200),
alternatenames varchar(12000),
@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)
@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 / 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 / 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 / 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 / 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: .