Skip to content

Instantly share code, notes, and snippets.

Chris Dillon squarism

Block or report user

Report or block squarism

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
@squarism
squarism / python_generators.py
Created Oct 5, 2018
Python Generator Cheatsheet
View python_generators.py
# A personal cheatsheet for the confusing (to me) python feature: generators
# Done in ipython
[n*2 for n in [1,2,3]]
# Out[8]: [2, 4, 6]
{n*2 for n in [1,2,3] if n > 1}
# Out[9]: {4, 6}
for n in (x for x in [1,2,3] if x > 1):
@squarism
squarism / multiline.exs
Last active Apr 7, 2019
Multiline Anonymous Functions in Elixir
View multiline.exs
# Examples of Different Styles and Syntax
# legal / positive case / you can do these stuffs
# ---------------------------------------------------------------------------
# single line, nothing special
Enum.map(0...2, fn i -> IO.puts i end)
"""
0
1
@squarism
squarism / system_replacements.md
Created Apr 24, 2018
Modern system utility replacements (Go / Rust or even just something new)
View system_replacements.md

List of interesting CLI projects that replace system utilities

The absolute requirement is that these must be binaries that could go into /usr/bin one day. No python, ruby or js stuff. Not that these languages are terrible, I just think it's interesting that people are writing replacements in Go / Rust that rethink some historical utilities. Replacement doesn't mean better in all cases. I just think it's an interesting time but also a good yardstick of what these languages can handle.

  • exa - ls replacement
  • caddy - HTTP server (better than python -m SimpleHTTPServer)
  • fzf - Grep replacement, can integrate with vim
@squarism
squarism / java_upgrades_homebrew_jenv.md
Last active Oct 22, 2018
Automating Java Upgrades with Homebrew and Jenv
View java_upgrades_homebrew_jenv.md

Goals:

  • never upgrade Java with the GUI pkg installer again.
  • never try to remember that /Library/Java is where JDKs go.
  • Just keep JDK8 and JDK9 up-to-date. Java is so stable, maybe these two major versions is all we need?

Note the assumptions in these goals. Making this a bit more generic would be nice.

I'm on a mac and I use the fish shell which I know is squarely in the edge case camp but I hope this is inspiring or useful to someone else because there's not much shell specific stuff here. I found jenv which is going to help.

First, upgrading java with homebrew is pretty easy. The assumption is that java8 is stable and java (9) is still emerging. This assumption would likely change so it'd be nice to have this scripted out of this assumption. For now, I'm just trying to avoid graphical Oracle installers.

@squarism
squarism / fish_shell_switch.txt
Last active Jan 9, 2018
Fish Shell Awesomeness
View fish_shell_switch.txt
Early days of fish shell impressions.
This is like honeymoon time but I really like it so far.
1. iTerm
alt+command goes back in history. Weird. Thought this was tab-navigation in iTerm.
2. Editing past commmands!
up & down to go through history (as usual) but then left-right take you into edit mode!
But how would you add a newline? Fish doesn't like `;` as much as zsh for newlines.
Well ... you can hit alt+enter and it will do a soft return!
@squarism
squarism / favorite_packages.txt
Created Nov 2, 2017
Favorite VSCode Packages
View favorite_packages.txt
- Auto Close Tag
- Babel ES6/ES7
- Color Highlight
- elm
- ESLint
- Go
- indent-rainbow
- Nord
- Prettier
- vscode-icons
@squarism
squarism / calculator.rb
Created Sep 25, 2017
Calculator with paper tape side effects
View calculator.rb
class Calculator
# add two numbers with side effects to tape
def add(number1, number2)
sum = number1 + number2
tape("#{number1} + #{number2}")
tape("=\n#{sum}")
sum
end
@squarism
squarism / create_a_class_the_hard_way.rb
Last active Apr 11, 2018
create_a_class_the_hard_way.rb
View create_a_class_the_hard_way.rb
require "rspec/autorun"
Car = Class.new
Car.class_exec {
define_method :start, Proc.new { @started = true }
define_method :started, Proc.new { @started }
}
RSpec.describe Car do
it "starts" do
@squarism
squarism / perl_bloat.md
Created Dec 17, 2016
The problem with perl pie
View perl_bloat.md

Perl One Liners Bring Way Too Much To the Table

I've always used perl -pie for inline text replacement. Because I got used to it, I used it a lot. Because I used it a lot, I used it a lot. Because I used it a lot, a lot I love it. I shun sed. But what is this bringing with it? An entire language?

Get:4 http://ftp.us.debian.org/debian/ jessie/main powerline armhf 1.2-2 [36.9 kB]
Fetched 259 kB in 1s (250 kB/s)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
@squarism
squarism / databases_filesystems.md
Last active Apr 7, 2017
File Systems are Databases
View databases_filesystems.md

THIS IS A MAJOR WIP - SKIP TO TRUSTY SECTION, ARCH DID NOT WORK WITH THE MYSQL VERSIONS. I WILL BE CLEANING THIS UP AS I DEVELOP THE TALK / BLOG POST.

Install OS

Install Arch (this doesn't matter, just get a Linux box) https://wiki.archlinux.org/index.php/Installation_guide

If you are in a VM, add a 4gb disk.

You can’t perform that action at this time.