Skip to content

Instantly share code, notes, and snippets.

View thejsj's full-sized avatar

Jorge Silva thejsj

View GitHub Profile
@thejsj
thejsj / main.R
Last active June 1, 2019 00:33
Basilica R Demo
# Install Basilica
install.packages("https://storage.googleapis.com/basilica-r-client/basilica_0.0.2.tar.gz", repos=NULL)
library(basilica)
# Create a connection
conn = connect(auth_key="SLOW_DEMO_KEY")
# Change the working directory
# Besure to download the demo file first
# wget https://storage.googleapis.com/basilica-public/cats_dogs_demo.tgz
@thejsj
thejsj / main.bash
Created May 24, 2019 23:01
Install postgres in Docker container
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
apt-get install postgresql-client -y
@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
def all_perms(elements):
if len(elements) <=1:
yield elements
else:
for perm in all_perms(elements[1:]):
for i in range(len(elements)):
#nb elements[0:1] works in both string and list contexts
yield perm[:i] + elements[0:1] + perm[i:]
@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 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 / createDatabaseAndUser
Created October 24, 2013 21:44
Bash script to automatically create MySQL databases where the database name and the username are the same. First argument: database name/username. Second argument: mysql_user password.
#!/bin/bash
params=" -uroot -p"
echo ' - - - - - - - '
echo 'DB Name : '$1
echo 'Password: '$2
# Create Database
echo ' - - - - - - - '
echo 'CREATE DATABASE IF NOT EXISTS $1;'
# Grant Options (Creates User Automatically)
echo ' - - - - - - - '
@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 / parseJSON.js
Last active August 15, 2018 16:10
A custom parseJSON funciton
const parseJSON = function (json) {
// Higher-order function to be used for detecting type
const firstAndLastChars = function (first, last) {
return (str) => str[0] === first && str[str.length - 1] === last
}
const isArray = firstAndLastChars('[', ']')
const isObj = firstAndLastChars('{', '}')
const hasDoubleQuotes = firstAndLastChars('"', '"')
const hasSingleQuotes = firstAndLastChars("'", "'")
const isNumber = (str) => (+(str)) + '' === str
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
}