Skip to content

Instantly share code, notes, and snippets.

Nathan terakilobyte

Block or report user

Report or block terakilobyte

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View foo.sh
# set rc file
RC_FILE=""
case $SHELL in
*/zsh)
RC_FILE="$HOME/.zshrc"
;;
*/bash)
RC_FILE="$HOME/.bashrc"
;;
esac
@terakilobyte
terakilobyte / requirements.txt
Created Jun 27, 2019
MongoDB Documentation Python 2 requirements
View requirements.txt
alabaster==0.7.12
argh==0.26.2
asn1crypto==0.24.0
Babel==2.7.0
certifi==2019.6.16
cffi==1.12.3
chardet==3.0.4
Click==7.0
cryptography==2.7
defusedxml==0.6.0
View .babelrc
{
"presets": [
"env",
"stage-1"
],
"plugins": [
"transform-runtime"
]
}
@terakilobyte
terakilobyte / flood_fill.rs
Last active Dec 29, 2018
borrow checker is very unhappy
View flood_fill.rs
fn flood_fill(board: &mut Vec<Vec<Cell>>, cell_x: usize, cell_y: usize) {
let mut queue: VecDeque<&Cell> = VecDeque::new();
queue.push_front(&board[cell_x][cell_y]);
let is: Vec<i8> = vec![-1, 0, 1];
while !queue.is_empty() {
let mut cell = queue.pop_front().unwrap();
let (x, y) = (cell.position[0] as usize, cell.position[1] as usize);
if cell.rust_count == 0 {
board[x][y].is_hidden = false; <--- mutable borrow occurs here
View valleys.py
def count_valleys(s):
elevation = 0
valleys = 0
for i in s:
if i == "D":
elevation -= 1
if elevation == -1:
valleys += 1
else:
elevation += 1
View commands.py
admins_and_mods = ["tremorai", "swarmlogic", "firecopy"]
def do_command(message):
def command(nick):
print(message)
return command
def do_admin_command(message):
def command(nick):
if nick in admins_and_mods:
View request.js
/**
* Parses the JSON returned by a network request
*
* @param {object} response A response from a network request
*
* @return {object} The parsed JSON, status from the response
*/
function parseJSON(response) {
return new Promise(resolve =>
response.json().then(json =>
View leaf.png
<svg width="52px" height="95px" viewBox="0 0 52 95" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 43.2 (39069) - http://www.bohemiancoding.com/sketch -->
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Artboard" transform="translate(-117.000000, -100.000000)">
<g id="Group" transform="translate(117.000000, 100.000000)">
<rect id="Rectangle" fill="#70C70B" x="18" y="8" width="8" height="8"></rect>
<rect id="Rectangle" fill="#70C70B" x="27" y="8" width="8" height="8"></rect>
View Dockerfile
# Grabbing Ubuntu
FROM ubuntu
# Install MongoDB
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 && \
echo "deb [ arch=amd64 ] http://repo.mongodb.com/apt/ubuntu trusty/mongodb-enterprise/3.6 multiverse" | tee /etc/apt/sources.list.d/mongodb-enterprise.list && \
apt-get update && \
apt-get install -y mongodb-enterprise && apt-get install -y libgssapi-krb5-2 libsasl2-2 libssl1.0.0 libstdc++6 snmp && \
echo 'manual' | tee /etc/init/mongod.override
@terakilobyte
terakilobyte / scratch.js
Created Nov 16, 2017
validatePipeline1.js
View scratch.js
function validateLab1 (pipeline) {
var aggregations = db.getSiblingDB("aggregations")
if (!pipeline) {
print("var pipeline isn't properly set up!")
} else {
var studentSubmission = aggregations.movies.aggregate(pipeline)
try {
var keys = Object.keys(Object.getPrototypeOf(studentSubmission)).length
var batchSize = studentSubmission._batch.length
var totalReturned = studentSubmission.itcount()
You can’t perform that action at this time.