Skip to content

Instantly share code, notes, and snippets.

View nickcarenza's full-sized avatar

Nick Carenza nickcarenza

View GitHub Profile
@nickcarenza
nickcarenza / nodejs.sh
Created February 25, 2015 18:27
Useful nodejs shell script
source $(brew --prefix nvm)/nvm.sh
export NVM_DIR=~/.nvm
nvm use default &> /dev/null
@nickcarenza
nickcarenza / prompt.sh
Created February 25, 2015 18:28
Messing with the shell prompt
bold=`tput bold`
normal=`tput sgr0`
prompt_user() {
echo "${bold}\u${normal} in ${bold}\W${normal} >> "
}
prompt_vagrant() {
# Find closest .vagrant folder or exit
# @TODO
@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"
}
@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 / 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 / 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
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 / 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) {

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 / mycnf.go
Created January 30, 2017 22:31
Golang read connection details from my.cnf
package db
// stdlib
import (
"fmt"
"os"
)
// external
import (