Skip to content

Instantly share code, notes, and snippets.

View nickcarenza's full-sized avatar

Nick Carenza nickcarenza

View GitHub Profile

Scope Intersection

Observations

Terms in an intersection operation are commutative.

	a ∩ b = b ∩ a
@nickcarenza
nickcarenza / first-commit.js
Created April 3, 2017 17:37
Get first commit of private repo
// extended from https://github.com/FarhadG/init
(b=>fetch(new Request('https://api.github.com/repos/'+b[1]+'/commits?sha='+(b[2]||''),{
headers: new Headers({Authorization:'token ...'}),
}))
.then(c=>Promise.all([c.headers.get('link'),c.json()]))
.then(c=>{
if(c[0]){
var d=c[0].split(',')[1].split(';')[0].slice(2,-1);
return fetch(new Request(d,{
headers: new Headers({Authorization:'token ...'}),
@nickcarenza
nickcarenza / mycnf.go
Created January 30, 2017 22:31
Golang read connection details from my.cnf
package db
// stdlib
import (
"fmt"
"os"
)
// external
import (

Keybase proof

I hereby claim:

  • I am nickcarenza on github.
  • I am nickcarenza (https://keybase.io/nickcarenza) on keybase.
  • I have a public key whose fingerprint is 86AF BF41 246F 7DFB DD46 A114 EB5A 4002 134E F4DA

To claim this, I am signing this object:

@nickcarenza
nickcarenza / regexp-named-parameters.js
Created August 8, 2016 17:34
Implements named parameters on javascript regexp with use of getters.
/**
* The idea here is to support named regexp parameters by returning a proxy with a getter function
* TODO add Proxy
*/
class RegExp2 extends RegExp {
constructor(regexpStr, ...names) {
super(regexpStr)
this.names = names;
}
exec(str) {
let chance = require('chance').Chance();
let math = require('mathjs');
let newItem = function() {
return {
a: chance.natural({min: 1, max: 20}),
b: chance.pickone(['alpha', 'bravo', 'charlie', 'delta', 'echo']),
c: chance.pickset(['alpha', 'bravo', 'charlie', 'delta', 'echo'], 2),
d: chance.natural({min: 1, max: 2}),
sanity: 1
@nickcarenza
nickcarenza / batch-update-firehose.sh
Created February 1, 2016 18:17
Batch update AWS Kinesis Firehose
# This requires the aws cli and jq
# First pull down existing firehose streams
# This will create files with the name of the stream in a 'streams' folder
mkdir streams
aws firehose list-delivery-streams --limit 100 | jq '.DeliveryStreamNames[]' | xargs -L 1 -I {} sh -c "aws firehose describe-delivery-stream --delivery-stream-name {} > streams/{}.json"
# Make your changes to the files...
# This will push the copy options from each file to firehose
@nickcarenza
nickcarenza / nats-multi-reply.go
Created October 1, 2015 17:17
Request/reply with multiple subscribers
package main
import(
"fmt"
"log"
"github.com/nats-io/nats"
"time"
)
func main(){
@nickcarenza
nickcarenza / gist:7338522ccd3e41a8b522
Created April 7, 2015 22:33
Migrate Bitbucket to Github
BITBUCKET_ORG_NAME=''
BITBUCKET_REPO_NAME=$1
if [ -n "$2" ]; then
GITHUB_REPO_NAME=`echo $2 | tr '[:upper:]' '[:lower:]'`
else
GITHUB_REPO_NAME=$BITBUCKET_REPO_NAME
fi
GITHUB_ORG_NAME=''
@nickcarenza
nickcarenza / terminal.sh
Created February 25, 2015 18:28
Messing with terminal view
function tabname {
printf "\e]1;$1\a"
}
function winname {
printf "\e]2;$1\a"
}