Skip to content

Instantly share code, notes, and snippets.

@focusaurus
focusaurus / gist:03b814ea78e3952749dd
Created June 26, 2015 23:25
DB integrity checker instructions

Hi friend! So I just put up an alpha of my data analyzer that can scan any mongodb or couchdb server you can access from your laptop (including your local dev ones). It works by ssh tunneling and the "UI" is all ssh.

Could you give it a try and see what it says about your data?

Here's how to run it:

  1. ssh setup@carson.peterlyons.com
  • use password "password" when prompted
  1. Answer the questions about your db server it asks you
  • it will print another longer ssh command
@focusaurus
focusaurus / comcast.sh
Created September 17, 2015 13:25
using the "comcast" utility to throttle network traffic to a specific application
# https://github.com/tylertreat/Comcast
# In this example, the application I want to throttle is on TCP port 9110
comcast="${HOME}/projects/comcast/bin/comcast"
throttle() {
local profile="${1-wifi}"
local bandwidth=30000
local latency=40
@focusaurus
focusaurus / .babelrc
Created January 28, 2016 06:43
iron-node and babel step through
{
"presets": ["es2015", "stage-0"],
"plugins": [
"transform-decorators-legacy",
"transform-export-extensions"
]
}
@focusaurus
focusaurus / promises-are-always-async.js
Created January 29, 2016 16:52
Promises are always async
Promise.resolve('foo').then(console.log)
console.log('bar')
// outputs:
// bar
// foo
function listUsers (req, callback) {
// use req as immutable input
// standard node error-first callback API
// success value of callback is a response-shaped object with properties: statusCode, headers, body
}
// I haven't built one of these, just riffing.
// Look at clojure and other functional languages for examples that might
// have reasonable counterparts in "functional-light" JS
// Thinking more along the lines of react/redux reducer style
@focusaurus
focusaurus / package.json
Created October 10, 2016 16:50
atom-format-shell package.json
{
"activationHooks": [
"language-shellscript:grammar-used"
],
"author": "Peter Lyons <pete@peterlyons.com> (http://peterlyons.com)",
"bugs": {
"url": "https://github.com/focusaurus/atom-format-shell/issues"
},
"configSchema": {
"shfmtPath": {
@focusaurus
focusaurus / sign-in.elm
Last active November 7, 2016 22:28
How to handle Http POST
module SignIn exposing (..)
import Html exposing (..)
import Html.App
import Http
import Json.Decode
import Task
type alias Model =
@focusaurus
focusaurus / A.elm
Created December 5, 2016 00:26
Decode JSON string enum into elm union type
module A exposing (..)
import Json.Decode as JD
import Json.Encode as JE
type alias User =
{ id : Int
, theme : Theme
}
@focusaurus
focusaurus / A.elm
Created December 14, 2016 18:00
Trying to handle blur event and get at event.target.textContent as a String
module A exposing (..)
import Debug
import Html
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onBlur, onClick, on)
import Json.Decode as JD
import Json.Encode as JE
@focusaurus
focusaurus / WebDataPagination.elm
Created January 18, 2017 17:57
WebData for pagination
module Lab.WebDataPagination exposing (main)
import Html exposing (..)
import RemoteData as RD
import Json.Decode as JD
import Http
-- import Html.Attributes exposing (..)