Skip to content

Instantly share code, notes, and snippets.

@nikcorg
nikcorg / package.json
Created November 24, 2015 15:37
StackOverflow answer
{
"scripts": {
"build": "browserify index.js > bundle.js"
},
"browserify-shim": {
"./sorts/tablesort.date.js": {
"depends": "tablesort:Tablesort"
}
},
"browserify": {
@nikcorg
nikcorg / active-javascript.md
Last active May 18, 2016 17:25
Finnish GitHub users stats

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Sun, 19 Apr 2015 17:59:08 GMT till Tue, 19 Apr 2016 17:59:08 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter(user => user.followers > 11)
@nikcorg
nikcorg / flatmaplatest.js
Last active November 11, 2015 13:43
Flat Map Latest (through events)
export const VALUE = Symbol("VALUE");
const attempt = (fn, ...args) => {
try {
return fn(...args)
} catch (e) {}
}
const listen = function (event, cb) {
const eProp = Symbol.for(event);
@nikcorg
nikcorg / rot13.js
Last active August 29, 2015 14:26
Streaming (8-bit) rot13 - still teaching myself streams, this seemed like a "useful" idea.
var through = require("through");
var rot13 = through(function write(buffer) {
var transformed = new Buffer(buffer.length);
var rot = 13;
var lcase = { min: 97, max: 122 };
var ucase = { min: 65, max: 90 };
for (var i = 0, b = buffer.readUInt8(i); i < buffer.length; ++i, b = buffer.readUInt8(i, true)) {
if (ucase.min <= b && b <= ucase.max) {
b += rot;
@nikcorg
nikcorg / lambda-bundle.sh
Last active August 29, 2015 14:25
Compile a self-contained bundle for use in AWS Lambda
#!/usr/bin/env bash
ERR_BROWSERIFY_NOT_FOUND=1
ERR_SOURCE_NOT_FOUND=2
AWS_STDLIBS="aws-sdk dynamodb-doc"
err_exit()
{
if [ "x$2" != "x" ]; then
@nikcorg
nikcorg / index.html
Last active August 29, 2015 14:25
Tab key in Textarea
<!DOCTYPE html>
<html>
<head>
<title>Tab in form</title>
</head>
<body>
<form>
<textarea rows="15" cols="82">lorem ipsum
dolor sit amet
@nikcorg
nikcorg / ssh-complete.bash
Last active August 29, 2015 14:15
Tab completion for Host entries in `~/.ssh/config`
_find_all_ssh_hosts() {
grep "^Host " ~/.ssh/config | cut -d " " -f 2 | sort | uniq
}
_find_ssh_host() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@nikcorg
nikcorg / update-git-helpers.sh
Last active August 29, 2015 14:13
Git helper scripts updater
#!/bin/bash
# Usage: simply run the script,
# add -q for message suppression
# add -qq for all output suppression
# If you plan to run this script using cron and you feel unsure of
# your cron environment, uncomment the line below and edit the path
#HOME="<path to your home directory here>"
@nikcorg
nikcorg / rot13.js
Last active August 29, 2015 14:11
ROT-13
String.prototype.map = function (fn) {
var input = this;
function step(acc, i, idx) {
return acc + fn(i, idx, input);
}
return Array.prototype.reduce.call(this, step, "");
};