Skip to content

Instantly share code, notes, and snippets.

@jart
jart / .screenrc
Created October 10, 2013 03:35
GNU Screen Bitcoin Ticker
## GNU Screen Configuration
## Justine Tunney <jtunney@gmail.com>
# GNU Screen + this config allow you to:
#
# - Have tabs inside your terminal.
#
# - Have your terminal sessions persist, even if you close your ssh connection.
# This is especially great if you hop between multiple computers or simply
# don't want to lose what you're working on.
@jart
jart / euler.py
Last active March 19, 2016 18:32
These are the Project Euler solutions I wrote to sharpen my coding skills when I was preparing for my Google interviews. I don't have a strong background in math. So sometimes you'll notice I just kludge things and treat numbers as strings.
# problem 1
# add all natural numbers below one thousand that are multiples of 3 or 5.
print sum(n for n in xrange(1, 1000) if n % 3 == 0 or n % 5 == 0)
# problem 2
# sum of even value fibs below four million
def fib():
yield 1
yield 1
a, b = 1, 1
@jart
jart / gzip-benchmark.py
Created August 11, 2016 22:43
Python GZip Benchmark
#!/usr/bin/env python
#
# tl;dr: compresslevel=1 is 4x faster than the default and nearly as good
#
# https://docs.python.org/2/library/gzip.html
#
# http11 jart@compy://third_party/tensorflow/tensorboard$ python ~/doodle.py
# 1 5% 151ms
# 2 4% 149ms
# 3 4% 143ms
@jart
jart / npm.bashrc.sh
Last active October 11, 2016 19:38
NPM Transitive Deps Calculator
# NPM Dependency Calculator
#
# Author: Justine Tunney <jart@google.com>
# Copyright 2016 Google Inc. All Rights Reserved.
# Licensed under the Apache 2.0 license
# Last Updated on 2016-09-22
#
# This is a .bashrc addition that lets you inspect the transitive closure of
# dependencies for an NPM package. It does not require NPM or node.js to be
# installed on your system. It takes into consideration the fact that NPM
@jart
jart / BUILD
Created October 17, 2016 20:50
SWIG Bazel BUILD
licenses(["restricted"]) # GPLv3
exports_files(["LICENSE"])
cc_binary(
name = "swig",
srcs = [
"Source/CParse/cparse.h",
"Source/CParse/cscanner.c",
"Source/CParse/parser.c",
@jart
jart / nasm.BUILD.py
Last active November 12, 2016 00:47
NASM build file
# http://www.nasm.us/pub/nasm/releasebuilds/2.12.02/nasm-2.12.02.tar.bz2
licenses(["notice"]) # As of v2.07, nasm is licensed under the 2-clause BSD license.
cc_binary(
name = "nasm",
srcs = [
"assemble.c",
"crc64.c",
"directiv.c",
@jart
jart / bazel-maven-repo-name.js
Last active January 16, 2017 21:36
Bazel Maven Repository Naming Algorithm
/**
* @fileoverview Bazel external repository naming algorithm for Maven.
*/
var CLEANSE_CHARS_ = new RegExp('[^_0-9A-Za-z]', 'g');
/**
* Turns Maven group and artifact into Bazel repository name.
*
* <p>This algorithm works by turning illegal characters into underscores and
@jart
jart / java_import_external.bzl
Last active January 16, 2017 21:56
Bazel Java External Library Rule
# Copyright 2016 The Closure Rules Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@jart
jart / ordinary.c
Created December 28, 2015 16:38
Perfectly Ordinary C
/**//*
*//** This is perfectly ordinary C
**//*
*//** cc -std=c99 lol.c
**//* ./a.out justine 31
*//**/
#include <stdio.h>
#include <stdlib.h>
@jart
jart / .bashrc
Last active October 6, 2017 00:08
TensorBoard Profiling Script
# pip install yappi
# tensorboard-profile-wall-time --logdir=/google/data/ro/users/ja/jart/tensorboard/userlogdirs/1
tensorboard-profile-wall-time() {
-tensorboard-profile wall "$@"
}
tensorboard-profile-cpu-time() {
-tensorboard-profile cpu "$@"
}