Skip to content

Instantly share code, notes, and snippets.

View kahunacohen's full-sized avatar

Aaron Cohen kahunacohen

View GitHub Profile
'''
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:
/**
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) {
# 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
@kahunacohen
kahunacohen / git.sh
Last active August 15, 2021 14:53
A collection of useful git bash functions
#!/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
@kahunacohen
kahunacohen / class_vs_fn.js
Created August 3, 2021 13:40
Shows how ES "classes" are really just functions
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() {
#[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,
/**
* 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;
; 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)
#!/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 && \
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