Skip to content

Instantly share code, notes, and snippets.

@tzapu
tzapu / gist:f47924daae9d64b65fdfaf92b64f587c
Last active September 3, 2021 20:50
connecting to a kubernets hosted kafka cluster from macOS
# you will need to alias the internal kube IPs to your loopback interface
# get pods with IPs
kubectl get pods -n kafka -o wide
# add aliases
sudo ifconfig lo0 100.101.168.109 alias
sudo ifconfig lo0 100.117.38.251 alias
sudo ifconfig lo0 100.121.158.154 alias
@addyosmani
addyosmani / appcache-tooling.md
Last active August 29, 2015 14:05
AppCache manifest generation tooling

Tools that read through a directory, stream or tree and create an Application Cache manifest for you.

AppCache is still a douche but luckily there are tools available to take the pain out of generating your initial manifest files:

  • Grunt: grunt-manifest is currently the de facto option, but the project lead is looking for a new maintainer. In light of that grunt-appcache is an alternative in case you're looking for more active support.
  • Gulp: gulp-manifest is inspired by grunt-manifest and has a similar set of options.
  • Broccoli: broccoli-manifest brings manifest file compilation based on trees.

Do review what is generated. As with any automation tooling, be careful that what is being generated is what you actually intend on being cached. I generally rel

@callumacrae
callumacrae / build-tools.md
Last active October 25, 2023 15:14
Build tools written in JavaScript
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@peterbraden
peterbraden / gist:3455116
Created August 24, 2012 20:11
Webcam Face Detection in 16 lines of Javascript
var cv = require('opencv')
new cv.VideoCapture(0).read(function(mat){
mat.resize(200,100)
mat.detectObject("./data/haarcascade_frontalface_alt.xml", {min : [30,30]}, function(err, faces){
for (var i=0;i<faces.length; i++){
var x = faces[i]
mat.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
@vojtajina
vojtajina / grunt.js
Created August 14, 2012 08:17
Grunt script for inlining AngularJS templates
module.exports = function(grunt) {
grunt.initConfig({
inline: {
'index.html': ['tpl/*.html']
}
});
grunt.registerMultiTask('inline', 'Inline AngularJS templates into single file.', function() {
var SCRIPT = '<script type="text/ng-template" id="<%= id %>"><%= content %></script>\n';
@abourget
abourget / directives.js
Created August 8, 2012 20:24
Hammer.js integration with AngularJS
/**
* Inspired by AngularJS' implementation of "click dblclick mousedown..."
*
* This ties in the Hammer events to attributes like:
*
* hm-tap="add_something()"
* hm-swipe="remove_something()"
*
* and also has support for Hammer options with:
*
@vojtajina
vojtajina / get-last-modified-fixed.js
Created August 7, 2012 09:14
Example of predictableNextTick
var fs = require('fs');
var getLastModified = function(files, done) {
var timestamps = new Array(files.length);
var pending = files.length;
files.forEach(function(file, idx) {
fs.stat(file, function(err, stat) {
timestamps[idx] = stat.mtime;
@javan
javan / screenshot.js
Created June 19, 2012 21:40
Create a screenshot of any URL using phantomjs (headless webkit)
//
// Example usage: phantomjs screenshot.js http://yahoo.com /tmp/yahoo.png
//
var system = require('system');
var url = system.args[1];
var filename = system.args[2];
var page = new WebPage();
page.open(url, function (status) {
@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD