Skip to content

Instantly share code, notes, and snippets.

Avatar
🐦

Dustin Deus StarpTech

🐦
View GitHub Profile
@substack
substack / test.js
Created Mar 15, 2014
setup and teardown in tape
View test.js
var test = require('tape');
test('setup', function (t) {
// ...
t.end();
});
// tests go here
test('teardown', function (t) {
@timknight
timknight / breakpoint.scss
Created May 5, 2014
A simple responsive breakpoint mixin that takes both attribute names and custom widths. See https://medium.com/p/889927b37740/
View breakpoint.scss
@mixin breakpoint($min: 0, $max: 0) {
$type: type-of($min);
@if $type == string {
@if $min == xs {
@media (max-width: 767px) { @content; } // Mobile Devices
}
@else if $min == sm {
@media (min-width: 768px) { @content; } // Tablet Devices
View html-cache.js
const stream = require('stream')
const cache = new Map() // you might wanna use an lru here
function createCacheStream (url) {
const buf = []
return stream.Transform({
transform: function (data, enc, cb) {
buffer.push(data)
cb(null, data)
},
@lernerd
lernerd / nginx.conf
Created Sep 10, 2012
nginx proxy server example
View nginx.conf
upstream my_upstream { #this line starts the list of real resources that exist behind the nginx server
server 127.0.0.1:1337;
server 127.0.0.1:1338; #these servers are used in the order they are defined, in round robin fashion. there's more ways of load balancing in the docs
server 127.0.0.1:1339 backup; #amazingness no.1, the keyword "backup" means that this server should only be used when the rest are non-responsive
keepalive 64;
}
server {
listen 80;
location /resource.html { #in my example the server only responds to requests for the file /request.html
@domenic
domenic / README.md
Created Mar 29, 2012
Cross-platform git hooks for Node.js
View README.md

Here's how this works:

  • Include a git_hooks/ directory in your project, with these two files (plus other hooks if you want, written in a similar style).
  • Add "npm" to your devDependencies in package.json, so that the pre-commit hook can do its magic.
  • Add test and lint scripts to your package.json, e.g.
    "scripts": {
        "test": "mocha",
        "lint": "jshint ./lib --show-non-errors"
@jashmenn
jashmenn / self-eq-this-vs-bind.md
Last active Jul 31, 2020
Javascript var self = this; vs. .bind
View self-eq-this-vs-bind.md

The Problem

In Javascript this is bound in unexpected ways. Functions, in particular, create a new 'this' and so when you want to keep a reference to an "outer" object you sometimes see the pattern:

var self = this;

as in:

var self = this;
@stephenway
stephenway / README.md
Last active Sep 4, 2020
BEMIT Cheatsheet
View README.md
View latency.markdown

Latency numbers every programmer should know

1 typical CPU instruction ..................   1 ns
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs
@nodkz
nodkz / .babelrc.js
Last active Sep 15, 2020
Babel 7.0 with .babelrc.js DEPRECATED! This config was created when babel 7 was in beta
View .babelrc.js
/* eslint-disable prefer-template */
const path = require('path');
const aliases = require('./aliases');
// ///////////////////////////////////////////////////////////////
// ////////////////// PLUGINS ////////////////////////////////
// ///////////////////////////////////////////////////////////////
const commonPlugins = [
@pdxjohnny
pdxjohnny / .gitignore
Last active Sep 23, 2020
Setting Up k3s for Serverless (knative) on a $5 DigitalOcean Droplet Using k3d
View .gitignore
.terraform/
*.pem
*.tf
*.tfstate
*.yaml
*.backup
istio-*/
cert-manager-*/
*.swp
env
You can’t perform that action at this time.