Skip to content

Instantly share code, notes, and snippets.

View ricardofalasca's full-sized avatar

Ricardo Falasca ricardofalasca

View GitHub Profile
@ricardofalasca
ricardofalasca / close_vim_ext.py
Created July 30, 2020 16:16
How to close vim externally on Linux (devpts)
#!/usr/bin/env python3
pts = 15 # set the pts your vim instance is running
""" Run this as super user """
import os, fcntl, termios
fd = os.open(f'/dev/pts/{pts}', os.O_RDWR)
vim_cmd = '\033:wqa!\n'
for i in vim_cmd:
fcntl.ioctl(fd, termios.TIOCSTI, i)
@ricardofalasca
ricardofalasca / nginx-ssl-params.conf
Created March 23, 2019 08:21
SSL Params Configuration for Nginx
# from https://cipherli.st/
# and https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
@ricardofalasca
ricardofalasca / add-nodejs-ppa.sh
Created January 10, 2019 20:27
How to Install Latest npm/nodejs versions
#!/bin/sh
sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_11.x | sudo bash -
@ricardofalasca
ricardofalasca / magicalObject.js
Last active December 21, 2018 20:45
An usage of JavaScript Global Object "Proxy" to create a magical object that can receive any method call - useful for Fake/Mocking objects
var magicalObj = (function magicalMethod() {
return new Proxy(new Object(), {
get(target, propertyName, receiver) {
const theMethod = (target.propertyName) ? target.propertyName : function () { return true }
return function (...args) { return theMethod.apply(this, args) }
}
})
})()
@ricardofalasca
ricardofalasca / .vimrc
Last active October 29, 2019 16:58
My .vimrc
" run pathogen
execute pathogen#infect()
" show line numbers
set nu
" set auto indent
set ai
" enable syntax
syntax on
" open a new tab (control + t)
nmap <C-t> :tabnew<CR>
#!/bin/sh
if [ "$1" == "" ] || [ "$2" == ""] ;
then
echo "\nUse: $0 <es_host> <node_name> [optional] <index_name>\n"
exit;
fi
for index_shards in $(curl -s -XGET http://$1:9200/_cat/shards | grep UNASSIGNED | awk '{print $1"|"$2;}');
do