Skip to content

Instantly share code, notes, and snippets.

View nirnaeth's full-sized avatar
🦖

Monica Giambitto nirnaeth

🦖
View GitHub Profile

General

  1. Unit tests: Review unit tests first. Unit tests are a fantastic way to grasp how code is meant to be used by others and to learn what the expected behavior is. Are there any test gaps that should be there?
  2. Method arguments" Make sure arguments to methods make sense and are validated.
  3. Null References" (Yah yah, we know. Use F# and this goes away. We get it already.) Null references are a bitch and it’s worth looking out for them specifically.
  4. Conventions Consistency" Make sure naming, formatting, etc. follow our conventions and are consistent. I like a codebase that’s fairly consistent so you know what to expect.
  5. Disposables: Make sure disposable things are disposed. Look for usages of resources that should be disposed but are not.
  6. Security: There is a whole threat and mitigation review process that falls under this bucket.

WPF + ReactiveUI

# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];$ITERM_PROFILE - ${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html
@nirnaeth
nirnaeth / mit_scheme_bindings.txt
Last active August 29, 2015 14:25 — forked from bobbyno/mit_scheme_bindings.txt
MIT Scheme bindings suitable for rlwrap completion
#
#!optional
#!rest
#(
#\
#\altmode
#\backnext
#\backspace
#\call
#\linefeed
@nirnaeth
nirnaeth / gist:04c0888f7430d5be6b85d608a980f1d1
Created May 21, 2016 10:01 — forked from mattyoho/gist:1036397
Ryan Davis' book recommendations
My annual reread book is The School of Niklaus Wirth: The Art of Simplicity
Others I love:
Compiler Construction, Wirth
Effective TCP/IP Programming: 44 Tips to Improve Your Network Programs
C Programming Language
The Annotated C++ Reference Manual (first and last good book on C++, besides meyers)
Structure and Interpretation of Computer Programs
The Little Schemer, The Seasoned Schemer, (and probably Reasoned Schemer, but I haven't gotten through that yet).
Run tests:
mix test
Run single test file:
mix test path/to/file
Run single test:
@nirnaeth
nirnaeth / gist:c65d664b4ed8771ebbde0935c7844599
Created June 17, 2016 15:54 — forked from luopio/gist:f5a58f1dacf94d6094ad
Generating a Paymill token to test without the Javascript Bridge
module PaymillSupport
def get_payment_token
# Simulate the JavaScript bridge we would use in production
params = {
'transaction.mode' => 'CONNECTOR_TEST',
'channel.id' => Rails.configuration.paymill_public_key,
'jsonPFunction' => 'function',
'account.number' => '4111111111111111',
'account.expiry.month' => 1.year.from_now.month,
@nirnaeth
nirnaeth / gist:df5780be14225a28e2935bcf3223dace
Created July 25, 2016 12:30 — forked from joho/gist:3735740
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

@nirnaeth
nirnaeth / _upgrade-pg9.4-to-pg9.5.md
Created December 6, 2016 15:37 — forked from chbrown/_upgrade-pg9.4-to-pg9.5.md
Upgrade PostgreSQL 9.4 to 9.5 on Mac OS X with Homebrew

First, check your current config (example output in homebrew.mxcl.postgresql.plist.xml lower down in this gist):

cat ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Most importantly, note the -D /usr/local/var/postgres argument.

Second, shut down your current PostgreSQL.

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
@nirnaeth
nirnaeth / automated_class_instance_collaboration.rb
Created May 12, 2017 15:49 — forked from rklemme/automated_class_instance_collaboration.rb
Example for adding functionality to instances of a class which needs help from class methods of the same class. Use two modules - one for instance methods and one for class methods.
#!/usr/bin/ruby -w
module Foo
module Foo4Class
def reset_instance_count
@instance_count = 0
end
def new(*a, &b)
super.tap { @instance_count += 1 }