Skip to content

Instantly share code, notes, and snippets.

View antonioaguilar's full-sized avatar

Antonio Aguilar antonioaguilar

View GitHub Profile
@antonioaguilar
antonioaguilar / export_vcap_services.sh
Created January 25, 2018 23:49 — forked from micahyoung/export_vcap_services.sh
export all VCAP_SERVICES user-provided credentials as individual environment variables for start command shell script (jq 1.3 or newer)
#!/bin/bash
while read ENV_PAIR; do export "${ENV_PAIR}"; done \
< <(echo $VCAP_SERVICES | jq -r '.["user-provided"] | .[].credentials | to_entries[] | "\(.key)=\(.value)"')
# assuming `cf create-user-provider-service foo-service -p '{"MY_VAR":"foo"}'` and bound
echo $MY_VAR # => foo
@antonioaguilar
antonioaguilar / nginx.conf
Created January 14, 2018 18:10 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@antonioaguilar
antonioaguilar / gist:4acdfd129cc36cbc06992ebfb7b63a4a
Created August 19, 2017 22:11 — forked from jedi4ever/gist:903751
Tuning stuff for Ubuntu hosts
# /etc/security/limits.conf
* soft nofile 999999
* hard nofile 999999
root soft nofile 999999
root hard nofile 999999
===========================================================
# /etc/sysctl.conf
# sysctl for maximum tuning
@antonioaguilar
antonioaguilar / sysctl.conf
Created August 19, 2017 22:11 — forked from techgaun/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@antonioaguilar
antonioaguilar / js-observables-binding.md
Created June 28, 2017 02:24 — forked from austinhyde/js-observables-binding.md
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);

@antonioaguilar
antonioaguilar / flow.js
Created April 10, 2017 21:21 — forked from stevenkaspar/flow.js
VexFlow SVG Javascript Animation
var Note = function(options){
console.log(window);
this.StaveNote = new Vex.Flow.StaveNote(options);
this.removed = false;
/**
* moves the note right from its ORIGINAL position by x pixels
* (sets the trasform: translate(x) value to x)
*/
this.setOffsetX = (x) => {
if(this.removed){
@antonioaguilar
antonioaguilar / Middleware.js
Created December 29, 2016 11:35 — forked from darrenscerri/Middleware.js
A very minimal Javascript (ES5 & ES6) Middleware Pattern Implementation
var Middleware = function() {};
Middleware.prototype.use = function(fn) {
var self = this;
this.go = (function(stack) {
return function(next) {
stack.call(self, function() {
fn.call(self, next.bind(self));
});
@antonioaguilar
antonioaguilar / pubsub-simple.js
Created December 10, 2016 02:00 — forked from fatihacet/pubsub-simple.js
Simple PubSub implementation with JavaScript - taken from Addy Osmani's design patterns book -
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,
@antonioaguilar
antonioaguilar / setup.sh
Created October 14, 2016 00:35 — forked from lazypower/setup.sh
Setup headless chromium driver for selenium (vagrant flavor, but works with any ubuntu variant)
#!/bin/sh
set -e
if [ -e /.installed ]; then
echo 'Already installed.'
else
echo ''
echo 'INSTALLING'
echo '----------'
@antonioaguilar
antonioaguilar / angular-bootstrap-with-config.js
Created October 1, 2016 11:01 — forked from DioNNiS/angular-bootstrap-with-config.js
Initiate angular application with server config
(function(angular) {
'use strict';
fetchConfig().then(bootstrapApplication);
function fetchConfig() {
var injector = angular.injector(['ng']);
var $http = injector.get('$http');
return $http.get('config.json').then(function(response) {