View HelloWorld.java
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
View SICP_Scheme_sucks.py
""" SICP section 2.2.3, page 160.
We can rearrange the pieces and use them in computing the product of the squares of the odd integers in a sequence:
(define (product-of-squares-of-odd-elements sequence) (accumulate * 1 (map square (filter odd? sequence))))
(product-of-squares-of-odd-elements (list 1 2 3 4 5))
225
2017-09-13 v1.0 Translated & benchmarked by Cees Timmerman
"""
from __future__ import print_function # For Python 2.
View game-of-life.py
import itertools
# Conway's Really Simple Game of Life based on "Stop Writing Classes" PyCon 2012
def neighbors(point):
x,y = point
yield x + 1, y
yield x - 1, y
yield x, y + 1
yield x, y - 1
View Smooth_72_percent_off.log
ct@MBA45:code$ python test_progress.py
('A', 0.9180472184659397, 0.0, ZeroDivisionError('float division by zero',))
('B', 0.9180472184659397, 0.0, ZeroDivisionError('float division by zero',))
0% @ 0.92s: -1.00s vs -1.00s
1% @ 1.45s: 143.46s vs 143.46s
2% @ 2.31s: 113.04s vs 128.25s
3% @ 2.75s: 88.78s vs 115.09s
4% @ 2.75s: 65.92s vs 102.80s
5% @ 3.29s: 62.56s vs 94.75s
6% @ 3.78s: 59.21s vs 88.83s
View cleancode.sh
# entire file, CLI code, inplace
perl -0777pe "
# whitespace
s/ /\t/g; # Tabs indent at a uniform and viewer-custom size.
s/\t +/\t\t/g; # Do not mix tabs and spaces.
s/ / /g;
s/\r\n/\n/g; # Nor line endings.
s/(catch|for|foreach|function|if|switch|while)\s+\(/\1\(/g; # Compact flow.
s/\}\s+el(if|se)/\}el\1/g;
s/\s+\{/\{/g; # Useless when indenting.
View .profile
# .profile is used by both Bash and Zsh, .bash_profile only by Bash, and .bashrc by Bash but not on MacOS (no colors, for one).
export PATH="$(brew --prefix homebrew/php/php71)/bin:$PATH"
export CLICOLOR=1
export GREP_OPTIONS='--color=auto'
# Zsh doesn't see these in MacOS Sierra
alias g='pcregrep -MHrn --color=auto'
alias d='diff -Bwurx ".*"'
# Inherit prompt user@host:yellow path$
export PROMPT=$'%n@%m:\e[33m%c\e[0m%# ' # Zsh
export PS1='\u@\h:\[\e[33m\]\W\[\e[m\]\$ ' # Bash
View MacOS_sucks.md

Windows shortcut equivalents:

  • PageUp/Down = Fn+Up/Down
  • Home/End = Cmd+Left/Right
  • Delete = Fn+Backspace
  • Alt+Tab = triple swipe down (per app) or triple swipe up (all apps not minimized windows), or install HyperDock (only that doesn't do minimized windows).
  • Ctrl+Alt+Del = Cmd+Alt+Esc (only to kill apps)
  • Cmd+L = Ctrl+Shift+Power (Ctrl+Shift+Eject if possible, and require a password after sleep/screensaver)
  • PrintScreen = Cmd+Shift+3 (also saves to desktop)
  • Ctrl+C/V/X = Cmd+C/V/X
View commit_all.sh
#!/bin/bash
# https://stackoverflow.com/a/7841728/819417
for DIR in `ls`;
do
if [ -d $DIR/.git ];
then
echo "********"
echo "Updating location: " $DIR;
cd $DIR
View LISP_sucks.py
"""
Casting SPELs with LISP demo code ported to Python
By Cees Timmerman
2017-07-04 v1.0
"""
from __future__ import print_function
'''
(setf *objects* '(whiskey-bottle bucket frog chain))
View simple_git_workflow.md

Master is the (preferably working) development branch in most git branching models. (GitHub Flow, GitLab Flow, etc.; not Git Flow.) If you want to stabilize for a release, create a release branch and only merge bug fixes from master to it. When a branch works in your local environment (e.g. VirtualBox), push it to the remote. Ideally, merge requests should get reviewed and the remote production branch should get tested and deployed after it passes.