Skip to content

Instantly share code, notes, and snippets.

View alfg's full-sized avatar

Alfred Gutierrez alfg

  • NBCUniversal / PeacockTV
  • ☀️ Los Angeles, CA
  • 11:44 (UTC -07:00)
View GitHub Profile
@alfg
alfg / README.md
Created January 17, 2017 06:20
Golang CGO Example
dcleanup(){
docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null
}
dcleanup()
@alfg
alfg / auth.go
Created October 27, 2015 22:30 — forked from tristanwietsma/auth.go
Golang web server example
package main
import (
"encoding/base64"
"net/http"
"strings"
)
type handler func(w http.ResponseWriter, r *http.Request)
@alfg
alfg / loader.js
Created October 26, 2015 17:36
Module loader snippet for Node.js.
// Loads all modules in tasks directory.
require('fs')
.readdirSync(__dirname + '/tasks').forEach(function(file) {
if (file.match(/\.js$/) !== null) {
var name = file.replace('.js', '');
require('./tasks/' + name)(gulp, config);
}
});
@alfg
alfg / gulpfile.js
Created October 20, 2015 18:36 — forked from adamrneary/gulpfile.js
Sample gulpfile for pushing functions to Lambda
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var rename = require('gulp-rename');
var install = require('gulp-install');
var zip = require('gulp-zip');
var AWS = require('aws-sdk');
var fs = require('fs');
var runSequence = require('run-sequence');
@alfg
alfg / .jshintrc.js
Last active August 29, 2015 14:27 — forked from connor/.jshintrc.js
jshintrc example
// NOTE: I added the .js extension to this gist so it would have syntax highlighting. This file should have NO file extension
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
@alfg
alfg / cache.js
Last active August 29, 2015 14:25
node-cache getOrSet caching pattern.
var NodeCache = require('node-cache');
var myCache = new NodeCache();
var cache = {
/** Gets key from cache if exists, else sets the cache and returns data.
* @param {string} cacheKey - Key to get or set.
* @param {integer} timeout - Timeout (in seconds) for cache to release.
* @param {Function} fn - Function to get data if key does not exist.
* @param {Function} callback - Callback function to send back data or value.
@alfg
alfg / main.js
Created December 31, 2014 18:48
Basic constructor pattern with jQuery support
;(function($) {
// Plugin constructor with options and methods
var MainPlugin = function() {
var _self = this;
var _options = {
foo: "bar"
};
@alfg
alfg / demo.html
Last active July 22, 2017 00:41
Ping.js example
<!DOCTYPE html>
<html>
<head>
<title>Ping.JS Demo</title>
<style>
ul span {
color: green;
}
</style>
@alfg
alfg / widget-bootstrap.html
Last active November 20, 2019 01:20
Bootstrap files for creating embedded widgets for your site
<html>
<head>
<title>Sample Widget Page</title>
</head>
<body>
<h1>Sample Widget Page</h1>
<script type="text/javascript" src="http://localhost:81/widget-bootstrap.js"></script>
<div id="widget-container"></div>