Skip to content

Instantly share code, notes, and snippets.

@TylerBrock
TylerBrock / build_and_push.sh
Last active September 15, 2022 07:36
Amazon ECS Deploy Script -- for public use
#!/usr/bin/env bash
set -e
status() {
echo -e "[DEPLOY]: ${1}"
}
# Set the version to the branch name by default
ver_tag=${CIRCLE_BRANCH}
@TylerBrock
TylerBrock / mta-turnstile.js
Last active March 29, 2020 04:21
Get the turnstile data from NYC MTA website
const fs = require('fs');
const axios = require('axios');
const cheerio = require('cheerio');
const downloadDir = './downloads';
const siteUrl = 'http://web.mta.info/developers/turnstile.html';
async function fetchData() {
const result = await axios.get(siteUrl);
return cheerio.load(result.data);
@TylerBrock
TylerBrock / lru.js
Created February 21, 2020 20:53
Skeleton for LRU cache
/**
Design and implement a Least Recently Used (LRU) cache. It should support the following operations: get and put.
 - get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.
 - put(key, value) - Set or insert the value if the key is not already present. When the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item.
The cache is always initialized with a positive capacity.
@TylerBrock
TylerBrock / orphanage.js
Created May 10, 2012 01:33
MongoDB Sharded Cluster Orphaned (Duplicate) Document Finder/Remover
/*
*
* orphanage.js -- Utility to find and remove orphaned documents
* 10gen 2012 -- Tyler Brock
*
* Script Orphan Finder Procedure:
* - Set up a connection to each shard
* - Turn of the balancer
* - For each chunk of data
* - Query each shard that is not in config
@TylerBrock
TylerBrock / GitHub-Forking.md
Created October 12, 2016 16:52 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, when I started going through the process of forking and issuing pull requests, I had some trouble figuring out the proper method for doing so and made quite a few mistakes along the way. I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your

@TylerBrock
TylerBrock / find_stuff.py
Last active January 3, 2016 12:19
Script to find headers required for building libmongoclient.
#!/usr/bin/env python
import subprocess
import argparse
import shutil
import os
from sets import Set
client_source_basic = [
#'mongo/base/error_codes.cpp',
'mongo/base/global_initializer.cpp',
diff --git a/src/third_party/v8/src/spaces.h b/src/third_party/v8/src/spaces.h
index 6602c89..d7a79c6 100644
--- a/src/third_party/v8/src/spaces.h
+++ b/src/third_party/v8/src/spaces.h
@@ -321,7 +321,8 @@ class MemoryChunk {
Space* owner() const {
if ((reinterpret_cast<intptr_t>(owner_) & kFailureTagMask) ==
kFailureTag) {
- return reinterpret_cast<Space*>(owner_ - kFailureTag);
+ return reinterpret_cast<Space*>(reinterpret_cast<intptr_t>(owner_) -
vagrant box add precise64 http://files.vagrantup.com/precise64.box
vagrant box add precise32 http://files.vagrantup.com/precise32.box
vagrant box add centos64 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130427.box
vagrant box add centos32 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-i386-v20130427.box
gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/tbrock/.rbenv/versions/2.0.0-p247/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
gem install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/Users/tbrock/.rbenv/versions/2.0.0-p247/bin/ruby extconf.rb
checking for mysql_ssl_set()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.