Skip to content

Instantly share code, notes, and snippets.

View listrophy's full-sized avatar

Brad Grzesiak listrophy

View GitHub Profile
@listrophy
listrophy / spotlight_ignore_node_modules.sh
Created October 9, 2018 23:08
Tell spotlight to ignore node_modules in a subdirectory
#!/usr/bin/env bash
# Use like:
# spotlight_ignore_node_modules.sh ~
PROGNAME=$(basename $0)
BASE=${1:-$HOME}
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
@listrophy
listrophy / postgres.sh
Last active June 26, 2018 16:18 — forked from mrw34/postgres.sh
Enabling SSL for PostgreSQL in Docker
#!/bin/bash
set -eu -o pipefail
openssl req -new -text -passout pass:abcd -subj /CN=localhost -out server.req -keyout privkey.pem
openssl rsa -in privkey.pem -passin pass:abcd -out server.key
openssl req -x509 -in server.req -text -key server.key -out server.crt
chmod og-rwx server.key
# insert the following argument if you want to expose a different port for postgres:
@listrophy
listrophy / await-promise.ts
Created February 9, 2018 19:49
await without unchecked exceptions
declare var document: any;
declare var setTimeout: any;
import { R, RahRah } from "./rah-rah";
function addDiv(text: string): void {
let el = document.createElement("div");
el.innerHTML = text;
document.body.appendChild(el);
}
@listrophy
listrophy / my-component.ts
Last active July 12, 2017 20:28
Trying to call an Angular Component's method in the template
@Component({
selector: 'my-component',
template: `
<my-component [value]="someValue">
<!-- Does not work -->
<div>{{aFunctionThatExistsInMyComponent()}}</div>
</my-component>`
})
export class MyComponent {
value: string;
@listrophy
listrophy / SendableData.elm
Created December 8, 2016 22:03
Sendable Data for Elm
module SendableData exposing (..)
import Http
type SendableData e r wrapped
= NotSent wrapped
| Sending wrapped
| FailedSending e wrapped
| Sent r wrapped
@listrophy
listrophy / keybase.md
Created February 15, 2016 17:02
keybase.md

Keybase proof

I hereby claim:

  • I am listrophy on github.
  • I am listrophy (https://keybase.io/listrophy) on keybase.
  • I have a public key ASA6atdQXkcOVAjd_ssdipntcPZj2b-l8w6dEWIODpAWiwo

To claim this, I am signing this object:

@listrophy
listrophy / Glob.swift
Created June 25, 2015 17:14
Wrap glob(3) in Swift
//
// Glob.swift
//
// Created by Brad Grzesiak on 6/25/15.
// Copyright © 2015 Bendyworks Inc.
// Released under the Apache v2 License.
//
import Foundation
@listrophy
listrophy / unwrap.swift
Last active August 29, 2015 14:23
if-let => try
func unwrap<T>(wrapped: T?) throws -> T {
guard let unwrapped = wrapped else {
throw NSError(domain: "custom", code: 1, userInfo: nil)
}
return unwrapped
}
@listrophy
listrophy / rpsls.rb
Created February 21, 2015 20:11
Rock, Paper, Scissors, Lizard, Spock
# Exactly 140 characters! :)
# We rescue StandardError and re-raise a RuntimeError
# because that's nicer than getting NoMethodError or TypeError
def play a, b
t = %w(scissors paper rock lizard spock)
['tie', b, a, b, a][(t.index(a)-t.index(b)) % 5]
rescue StandardError
raise 'invalid'
end
@listrophy
listrophy / Mutator.swift
Created January 7, 2015 00:42
Quick does not instantiate new objects for each test
class Mutator {
var mutated: Bool
init() {
mutated = false
}
func mutate() {
mutated = true
}
}