Skip to content

Instantly share code, notes, and snippets.

View serweb-labs's full-sized avatar

Luciano Rodríguez serweb-labs

View GitHub Profile
@serweb-labs
serweb-labs / calc.js
Created April 26, 2021 02:38
token stake compund optimizator
function cci(principal, rate, frequency, years) {
return principal * Math.pow(1 + rate / frequency, frequency * years);
}
var capital = 550;
var tokenRate = 1.185;
var apr = 2.15;
var compoundFee = 0.45;
@serweb-labs
serweb-labs / isEmoji.js
Created May 22, 2020 00:06
two functions tocheck if a text is emoji regular expression based and canvas based
// regular expression based
function isEmoji(text) {
return (new RegExp(/[\uD800-\uDBFF]/g).test(text) && new RegExp(/[\uDC00-\uDFFF]/g).test(text));
}
// canvas bases, slow and depend if the system can draw the emoji
function isEmojiCanvas(text) {
const ArrayLikeToString = arg => Array.prototype.toString.call(arg);
const getTextFeature = (text, color) => {
try {
@serweb-labs
serweb-labs / .bash_profile
Last active April 28, 2020 06:29
developer mac bash_profile (android, node, java, yarn etc)
# Java
export JAVA_HOME=$(/usr/libexec/java_home)
# NVM / Node
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# Yarm
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
@serweb-labs
serweb-labs / adduser.sh
Created September 29, 2019 20:17
add user to mysql and add privileges on prefix db
CREATE USER 'el_user'@'%' IDENTIFIED BY 'elpass';
GRANT ALL PRIVILEGES ON el_user_*.* TO 'cleek_dba'@'%';
GRANT ALL PRIVILEGES ON `el_user_\_%` . * TO 'el_user'@'%';
@serweb-labs
serweb-labs / https-on-localhost.md
Created December 10, 2018 16:10
create my own Root CA and issue my own certificates (https on local host)

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@serweb-labs
serweb-labs / getAttr.js
Created August 2, 2018 04:12
safe get attribute
function getAttr(o, p, d) {
if (!Array.isArray(p)) { p = p.split("."); }
var def = (d === null) ? null : (d || false);
return p.reduce((xs, x) => (xs && xs[x] !== undefined) ? xs[x] : def, o)
}
@serweb-labs
serweb-labs / Dockerfile
Created May 31, 2018 18:38
readthedocs docker
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y \
build-essential \
python-pip \
python-setuptools \
libxml2-dev \
libxslt1-dev \
zlib1g-dev \
elasticsearch \
redis-server \
@serweb-labs
serweb-labs / add_user_sftp_serverpilot.sh
Last active April 2, 2019 07:44
add only sftp user to serverpilot app
#! /bin/bash
# $1 user
# $2 from path
# prerequisites:
# create sftp-only group
# sudo groupadd sftp-only
# add sftp-only configurations
# we need to modify the ssh configuration on file /etc/ssh/sshd_config replacing the following line:
@serweb-labs
serweb-labs / add_sftp_users_moss.sh
Last active May 6, 2018 10:59
moss servers: add sftp user
#! /bin/bash
# $1 user
# $2 from path
# prerequisites:
# create sftp-only group
# sudo groupadd sftp-only
# add sftp-only configurations
# we need to modify the ssh configuration on file /etc/ssh/sshd_config replacing the following line:
@serweb-labs
serweb-labs / app.js
Last active February 7, 2018 17:14
smooth scroll
// for jquery
$( document ).ready(function() {
$(".smoothScroll").on('click', function(e){
smoothScroll(e);
})
});