This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Fizz buzz in Python: | |
Any number divisible by three print the word fizz and any number divisible by five print the word buzz. | |
Numbers divisible by both three and five become fizz buzz. | |
''' | |
for n in [n + 1 for n in range(100)]: | |
if n % 15 == 0: | |
print("fizz buzz") | |
if n % 3 == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Fizz buzz in JavaScript: | |
Any number divisible by three, print the word "fizz" and any number divisible | |
by five print the word "buzz". | |
Any number divisible by both three and five print "fizz buzz". | |
*/ | |
for (const n of Array.from(Array(100).keys()).map(n => n + 1)) { | |
if (n % 15 === 0) { | |
console.log("fizz buzz"); | |
} else if(n % 3 === 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# General | |
export LC_ALL=en_US.UTF-8 | |
export LANG=en_US.UTF-8 | |
export PATH=$PATH:$HOME/bin | |
# Load version control information | |
autoload -Uz vcs_info | |
precmd() { vcs_info } | |
# Format the vcs_info_msg_0_ variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# A collection of useful functions related to git. This file must | |
# be sourced to bring its functions into the user path. | |
# delete_branches is a function, that once sourced, attempts to delete local | |
# and remote git branches from stdin or a file. The script | |
# prompts the user to delete each branch (local and remote). | |
# | |
# Example: | |
# $ git branch -r --sort=-committerdate | delete_branches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stripe { | |
constructor(baseUrl, token) { | |
this.baseUrl = baseUrl; | |
this.token = token; | |
this.expensiveResult = null; | |
} | |
getCustomers() { | |
console.log(`Getting ${this.baseUrl}/customers with token ${this.token}`); | |
} | |
someExpensiveOperation() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
struct Person { | |
name: String | |
} | |
#[derive(Copy,Clone,Debug)] | |
struct CopyablePerson<'a> { | |
name: &'a str | |
} | |
fn main() { | |
// This is OK because ints are copyable, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An example of how we can do error handling in rust. | |
*/ | |
use std::fmt; | |
use std::fs::File; | |
use std::io; | |
use std::result::Result; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Generate emacs/prelude. | |
(defun nolinum () | |
(global-linum-mode 0) | |
) | |
(add-hook 'org-mode-hook 'nolinum) | |
(menu-bar-mode -1) | |
(global-undo-tree-mode 0) | |
(setq sentence-end-double-space nil) | |
(setq-default abbrev-mode t) | |
(add-hook 'python-mode-hook 'anaconda-mode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Sets version in package.json, commits and pushes change, then tags pushes current branch | |
# This can be called after deploying the actual app. | |
# Args: | |
# - version: The version to deploy | |
# Usage: | |
# $ node_tag 0.1.0 | |
function node_tag { | |
jq ".version=\"$1\"" ./package.json > package.json.tmp && mv package.json.tmp package.json && \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source ~/bash-utils/bu.sh | |
# General unix | |
export BASH_SILENCE_DEPRECATION_WARNING=1 | |
# Remove safe, sends to trash. | |
# Removes items from the trash that are over | |
# 30 days old. | |
function rms { | |
mv "$1" ~/.Trash |