Skip to content

Instantly share code, notes, and snippets.

Avatar
🌱
I help developers craft their best work, achieve goals, and never stop growing.

Jonathan Lee Martin nybblr

🌱
I help developers craft their best work, achieve goals, and never stop growing.
View GitHub Profile
@iamvery
iamvery / Chat.elm
Last active Jul 11, 2017
Elm with a React head, cause why not?
View Chat.elm
port module Chat exposing (main)
-- https://github.com/elm-lang/core/issues/703
import Json.Decode
import WebSocket
port messages : List String -> Cmd msg
@niksumeiko
niksumeiko / mongoose-findOrCreate.js
Last active May 15, 2020
Mongoose schema static `findOrCreate` method in ES6/7 async/await syntax
View mongoose-findOrCreate.js
import mongoose from 'mongoose';
let schema = new mongoose.Schema({
email: { type: String, required: true, unique: true },
password: { type: String, required: true }
});
schema.statics.findOrCreate = async (conditions, opt_attr) => {
let document = await User.findOne(conditions);
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active Nov 12, 2022
Uninstall nodejs from OSX Yosemite
View gist:d75101d9bdf764c890ef
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@ef4
ef4 / gist:82f37eb5dae4e56467b6
Created Jun 16, 2014
Example Application Cache "Bootloader"
View gist:82f37eb5dae4e56467b6
(function(){
function useManifest(content){
var tag;
var stylesheets = content.match(/\/css\/.*\.css/g);
for (var i=0; i<stylesheets.length; i++){
tag = document.createElement('link');
tag.href = stylesheets[i];
tag.rel = "stylesheet";
document.getElementsByTagName('head')[0].appendChild(tag);
@iamvery
iamvery / conway.coffee
Created Jun 3, 2014
Game of Life WIP with @nybblr
View conway.coffee
# Live cells with < 2 living neighbors dies to underpop
# > 3 living neighbors dies to overpop
# Otherwise, lives!
#
# Dead cells with exactly 3 living neighbors is born
# . 0 .
# . 0 .
# . 0 .
#
@visnup
visnup / listenOnPortOrSocketFile.js
Last active May 17, 2019
Listen on a TCP port or a UNIX socket file in node.js. Handle EADDRINUSE for the socket file by deleting it and re-listening.
View listenOnPortOrSocketFile.js
var fs = require('fs')
, net = require('net')
, http = require('http')
, port = process.env.PORT;
var app = function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
};
@oprypin
oprypin / diffcolor.py
Last active Sep 17, 2022
Diffs with syntax highlight
View diffcolor.py
import difflib
import pygments
import pygments.lexers
import pygments.formatters
def read_file(fn):
with open(fn) as f:
return f.read()
View ios-bootcamp-resources.markdown

Blogs

  • ASCII WWDC - WWDC session transcripts.
  • NSHipster - Cocoa weekly from Mattt Thompson. Creator of AFNetworking.
  • objc.io - Great resource where each issue consists of a collection posts that all focus on one over arching topic such as testing, Auto Layout, Swift, etc.
  • Mike Ash - Self described as "Wizard without portfolio" Mike Ash is very widely read in the Cocoa community.
  • Bill Bumgarner's Stack Overflow answers - Long time Apple developer who provides well written answers to some of the hairier questions on ObjC and iOS.
  • iOS Dev Weekly - Excellent and widely read weekly that aggregates some of the best writing in the Cocoa developer community.
  • Stable Kernel - Joe Conway, one of the original authors of BNR's Beginning iOS book and former BNR engineer and instructor.
  • [Big Nerd Ran
@jarrodhroberson
jarrodhroberson / CalcMD5Worker.js
Created Nov 26, 2013
Reading a File in chunks with the HTML5 FileReader API and calculating MD5 hash codes of the contents with the spark-md5 library in a WebWorker.
View CalcMD5Worker.js
importScripts('spark-md5.min.js');
function calcMD5(f) {
var blobSlice = Blob.prototype.slice;
var chunkSize = 2097152;
var chunks = Math.ceil(f.size/chunkSize);
var spark = new SparkMD5.ArrayBuffer();
var currentChunk = 0;
var fr = new FileReader();
@tinabeans
tinabeans / template.html
Last active Jun 29, 2022
A super-barebones single-column responsive email template, assuming a max-width of 540px. Read about it on the Fog Creek blog.
View template.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Single-Column Responsive Email Template</title>
<style>
@media only screen and (min-device-width: 541px) {
.content {