Skip to content

Instantly share code, notes, and snippets.

Avatar

John Santiago Jr. jdsantiagojr

View GitHub Profile
@jdsantiagojr
jdsantiagojr / README.md
Last active Jan 31, 2019
K8 Desktop Hello World
View README.md

Run the commands below to create deployment and service, or use the kubectl apply -f <filename.yaml> command.

# View nodes
NAME                 STATUS    ROLES     AGE       VERSION
docker-for-desktop   Ready     master    1h        v1.10.11

# Create ReplicaSet
kubectl run echo --image=hashicorp/http-echo --port=8080 -- "-text=hello kubernetes" "-listen=:8080"
@jdsantiagojr
jdsantiagojr / ArrayProxy.js
Created Oct 18, 2018
Experimenting with JavaScript Proxy
View ArrayProxy.js
const EventEmitter = require("events");
const _ = require("lodash");
const timestamp = function () {
const now = new Date();
return new Date(now.getTime() + now.getTimezoneOffset() * 60000);
};
const ArrayProxy = function (array = [], keys = []) {
@jdsantiagojr
jdsantiagojr / promise-sequence.js
Created Oct 11, 2018
Promise Sequence Example
View promise-sequence.js
function transaction(delay) {
return new Promise((resolve, reject) => {
console.log(delay, "seconds");
setTimeout(() => resolve(delay), delay * 1000);
});
}
function main() {
return [5, 4, 3, 2, 1].reduce((prev, next) => prev.then(() => transaction(next)), Promise.resolve());
@jdsantiagojr
jdsantiagojr / push.sh
Created Aug 7, 2018
Git push current branch
View push.sh
git push -u origin $(git branch | grep \* | sed "s/* //g")
@jdsantiagojr
jdsantiagojr / ex-list-slice.py
Created Jul 30, 2018
Python list slice examples
View ex-list-slice.py
# Python's list slice syntax can be used without indices
# for a few fun and useful things:
lst = [1, 2, 3, 4, 5]
del lst[:]
# >>> []
# You can replace all elements of the list
# without creating a new list object:
a = lst
list[:] = [7, 8, 9]
@jdsantiagojr
jdsantiagojr / Avatar.js
Created Dec 1, 2017
45% Faster React Functional Component
View Avatar.js
import React from "react";
const Avatar = (props) => {
return <img src={props.url} />;
};
export default Avatar;
@jdsantiagojr
jdsantiagojr / Dockerfile
Created Aug 2, 2017 — forked from andyshinn/Dockerfile
BusyBox cron container example
View Dockerfile
FROM gliderlabs/alpine:3.3
COPY myawesomescript /bin/myawesomescript
COPY root /var/spool/cron/crontabs/root
RUN chmod +x /bin/myawesomescript
CMD crond -l 2 -f
@jdsantiagojr
jdsantiagojr / lambda-example.js
Created Jul 20, 2017
Simple lambda handler example.
View lambda-example.js
"use strict";
const request = require("request");
exports.handler = function handler(event, context, callback)
{
request(`http://api.openweathermap.org/data/2.5/weather?zip=${event.zip}us&appid=287050e4a6505be74bfdc324567h&units=imperial`, (error, response, body) => {
if (!error) {
body = JSON.parse(body);
const payload = {
@jdsantiagojr
jdsantiagojr / ha-proxy-stats.py
Last active Jul 21, 2017
HAProxy stats CSV to JSON
View ha-proxy-stats.py
#!/usr/bin/env python3
from csv import DictReader
from sanic import Sanic
from sanic.response import json
import aiohttp
import uvloop
# Create an event loop manually so that we can use it for both sanic & aiohttp
@jdsantiagojr
jdsantiagojr / AWS-Lambda-HTML.md
Created Mar 6, 2017
AWS HTML Lambda Settings
View AWS-Lambda-HTML.md

Lambda HTML Response

Method Response

  1. Navigate to the Method Response for the API's GET method.
  2. Open up the 200 under HTTP Status and add a Response Header named Content-Type.
  3. Delete the application/json Response Model for 200.
You can’t perform that action at this time.