Skip to content

Instantly share code, notes, and snippets.

View nybblr's full-sized 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
@visnup
visnup / listenOnPortOrSocketFile.js
Last active May 17, 2019 11:57
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.
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');
};
@iamvery
iamvery / Chat.elm
Last active July 11, 2017 15:54
Elm with a React head, cause why not?
port module Chat exposing (main)
-- https://github.com/elm-lang/core/issues/703
import Json.Decode
import WebSocket
port messages : List String -> Cmd msg
@pouriaalmassi
pouriaalmassi / ios-bootcamp-resources.markdown
Last active January 4, 2016 06:58 — forked from owen-bnr/ios-bootcamp-resources
iOS & OS X Developer Resources

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
class Module
def dispatch(*klasses, last)
last_klass, mid = last.first
klasses << last_klass
__dispatch_list << [klasses, instance_method(mid)]
define_method(mid, __dispatch_proc(__dispatch_list))
end
def __dispatch_list
@__dispatch_list ||= []
@stevenharman
stevenharman / bin-puma
Last active December 21, 2015 04:39
A wrapper script that will start a local SSH tunnel (only in development environment), and then start Puma as normal. I use this with foreman from a Procfile.
#!/usr/bin/env sh
CURRENT_ENV=${RACK_ENV:-development}
# For the payment gateway callback URL
if [ "$CURRENT_ENV" == "development" ]; then
PORT_SSL=$(expr $PORT + 1)
echo "starting an SSL tunnel from :$PORT_SSL --(--)--> :$PORT"
bundle exec tunnels $PORT_SSL 0.0.0.0:$PORT &
fi
@oivoodoo
oivoodoo / nested_attributes_parameters.rb
Created July 25, 2013 14:12
Enabled not numeric ids for the nested attributes using strong parameters
require 'delegate'
# Because of using guid ids for the nested attributes we should define
# custom permit method. By default strong_parameters accept only numeric
# keys for the nested attributes in the fields_for form.
# Usage:
# params[:app][:nested_attributes] = NestedAttributesParameters.new(params[:app][:nested_attributes](
# params.require(:app).permit(:nested_attributes => [:id, :attribute1, :attribute2] => { '51e52eb101790c31ba000001' => { 'id' => '51e52eb101790c31ba000001', 'attribute1' => 'value1', 'attribute2' => 'value2' } } }
@ef4
ef4 / gist:82f37eb5dae4e56467b6
Created June 16, 2014 21:13
Example Application Cache "Bootloader"
(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 June 3, 2014 18:59
Game of Life WIP with @nybblr
# 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 .
#