Skip to content

Instantly share code, notes, and snippets.

View thejsj's full-sized avatar

Jorge Silva thejsj

View GitHub Profile
@thejsj
thejsj / pearson-hashing.js
Last active September 11, 2021 03:59
Pearson Hashing Function
'use strict'
// Ideally, this table would be shuffled...
// 256 will be the highest value provided by this hashing function
let table = [...new Array(256)].map((_, i) => i)
const hash8 = (message, table) => {
return message.split('').reduce((hash, c) => {
return table[(hash + c.charCodeAt(0)) % (table.length - 1)]
}, message.length % (table.length - 1))
@thejsj
thejsj / keybase.md
Created April 13, 2017 18:38
keybase.md

Keybase proof

I hereby claim:

  • I am thejsj on github.
  • I am hiphipjorge (https://keybase.io/hiphipjorge) on keybase.
  • I have a public key whose fingerprint is 8470 BA42 28BE A599 BD6D 629E 0B0E 77B6 4B7B BD88

To claim this, I am signing this object:

@thejsj
thejsj / 1-fixed.py
Last active April 20, 2017 06:19
Dani + Python
import requests
import xlwt
import datetime
from bs4 import BeautifulSoup
# Turn lines of code used multiples times into functions
def fetch_soup(uri):
response = requests.get(uri)
# Add "html.paser" so beautiful soup doesn't complain
return BeautifulSoup(response.content, "html.parser")
@thejsj
thejsj / install-mongo.sh
Created June 2, 2017 17:26
Install Mongo in Docker Container
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list
apt-get update -y
apt-get install -y mongodb-org
@thejsj
thejsj / gist:73d4ae8077dce91528b5bcc907d5f9b0
Created November 22, 2017 01:11
Creating user and assigning ownership inside Dockerfile
FROM ubuntu:latest
RUN useradd --uid 2000 -ms /bin/bash example
RUN mkdir -p /etc/example
RUN chown -Rv 2000 /etc/example
RUN ls -la /etc | grep example
USER 2000
CMD ["sh", "-c ls -la /etc | grep example"]
function pull_image () {
echo $1
devdocker_image="devdocker.mulesoft.com:18078/mulesoft/$1"
apiserver_image="apiserver:5000/mulesoft/$1"
docker pull $devdocker_image
docker tag $devdocker_image $apiserver_image
docker push $apiserver_image
}
@thejsj
thejsj / 1.js
Last active September 19, 2018 01:50
Callback Example
console.log('Start') // Will execute first
setTimeout(1000, function thisWillHappenLater () {
console.log('After Timeout') // Will execute third (after 1 second)
})
console.log('Keep going') // Will execute second
@thejsj
thejsj / main.bash
Last active February 4, 2019 19:44
Pillow Test
virtualenv -p python3 venv # Delete Later with `rm -rf venv`
source venv/bin/activate
pip install Pillow
python -c "from PIL import Image; import urllib.request; urllib.request.urlretrieve('https://images.unsplash.com/photo-1518791841217-8f162f1e1131', '/tmp/cat.jpg'); im = Image.open('/tmp/cat.jpg'); im.thumbnail((256, 256)); im.save('/tmp/cat-resize.jpg', 'JPEG'); im = Image.open('/tmp/cat-resize.jpg'); print(im.format, im.size, im.mode)"
@thejsj
thejsj / README.md
Last active February 5, 2019 06:33
Image Testing (Pillow + Basilica)

How to run this

If you have virtualenv

curl https://gist.github.com/thejsj/f79b18e8a0dedadbee34c7ff72037d73/raw/d5908867a8901c81848b6d86b316bb10d5ff117a/basilica_images-with-virtualenv.bash | bash

If you have Python 2.7 (Most probable)

@thejsj
thejsj / main.bash
Last active May 23, 2019 19:07
Nginx Ingress Controller Configiguration
# For Gcloud
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin \
--user $(gcloud config get-value account)
kubectl create namespace ingress-nginx
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/cloud-generic.yaml
kubectl edit cm -n ingress-nginx nginx-configuration