Skip to content

Instantly share code, notes, and snippets.

Code Review

A consolidation of advice and stuff from the internet

What is code review?

Code review one person reading over another's code and offering comments, suggestions, and feedback about how it could be improved. Often this is done at companies or in open source projects as a required step before proposed changes can be merged into a

@porterjamesj
porterjamesj / fix-venv.sh
Created October 2, 2016 22:10 — forked from pv8/fix-venv.sh
Fix virtualenv symlinks after upgrading python with Homebrew and running brew cleanup
#!/usr/bin/env bash
#
# Fix virtualenv symlinks after upgrading python with Homebrew and then running
# `cleanup`.
#
# After upgrading Python using Homebrew and then running `brew cleanup` one can
# get this message while trying to run python:
# dyld: Library not loaded: @executable_path/../.Python
# Referenced from: /Users/pablo/.venv/my-app/bin/python
# Reason: image not found
@porterjamesj
porterjamesj / timelens.rb
Created August 14, 2019 04:02
Homebrew formula for timelens (timelens.io)
class Timelens < Formula
desc "Timelens command-line client"
homepage "https://timelens.io"
url "https://github.com/timelens/timelens/archive/0.1.1.tar.gz"
sha256 "b7777d655945c3ee52909efcc6d38029a6db12438ae2aa4616291f04f1f776b1"
depends_on "rust" => :build
depends_on "gstreamer"
depends_on "gst-plugins-base"
depends_on "gst-plugins-good"
@porterjamesj
porterjamesj / three.jl
Last active December 15, 2018 12:48
Advent of Code day 3 (https://adventofcode.com/2018/day/3) solution in Julia (https://julialang.org/)
function count_overclaims(claims)
fabric = zeros(1000, 1000)
for claim in claims
claimed_area = view(
fabric,
claim[:x]+1:claim[:x]+claim[:width],
claim[:y]+1:claim[:y]+claim[:height],
)
claimed_area .+= 1
end
@porterjamesj
porterjamesj / hello_mesos.py
Last active March 6, 2018 20:43
the tiniest mesos scheduler
import logging
import uuid
import time
from mesos.interface import Scheduler
from mesos.native import MesosSchedulerDriver
from mesos.interface import mesos_pb2
logging.basicConfig(level=logging.INFO)
-----------------------------------------------------
2017/09/25 03:15:10.559235 s3.DEBUG {
Bucket: "locker",
Key: "playlist_test/【Silent Siren】「八月の夜」MUSIC VIDEO full ver.【サイレントサイレン】-TuRm1JzAsVg.mp4.part",
UploadId: "2~g-5U_pGnYJrH_6i6AQZKJDgFxoQ9ZBa"
}
2017/09/25 03:15:10.559409 s3.DEBUG {
Body: buffer(0xc42120b0c0),
Bucket: "locker",
Key: "playlist_test/【Silent Siren】「八月の夜」MUSIC VIDEO full ver.【サイレントサイレン】-TuRm1JzAsVg.mp4.part",
@porterjamesj
porterjamesj / gumbo_example.c
Created May 3, 2014 01:52
just a small example of using google's gumbo for html parsing
#include <stdio.h>
#include "gumbo.h"
int main() {
GumboOutput* output = gumbo_parse("<h1>Hello, World!</h1>");
// Gumbo inserts all the html, body, etc.
GumboNode *html = output->root;
GumboNode *body = (GumboNode *) html->v.element.children.data[1];
GumboNode *header = (GumboNode *) body->v.element.children.data[0];
GumboNode *text = (GumboNode *) header->v.element.children.data[0];
@porterjamesj
porterjamesj / how_to_learn_git.md
Last active April 6, 2017 17:34
How to learn Git

Before doing any of this, remember that no learning method is perscriptive and will work for all people. This approach was very effective for me, it might not work as well for you! Modify or use parts of it as you see fit. I recommend spending several days going through the steps outlined below. It might seem like a large amount of time to spend not making progress on anything else, but you will have a much better understanding of git afterwards, and this will pay huge dividends in time.

  1. Start reading the Pro Git Book (https://git-scm.com/book/en/v2).
  • If you've never used version control, there will be some stuff at the beginning about comparisons between git and other version control systems that might not make sense to you. Feel free to just ignore this, it's not important.
  1. After you have git installed and have learned about git init, make a practice repository with a bit of content you wouldn't actually mind losing (e.g. a few small text files you just type something silly into). For example,
@porterjamesj
porterjamesj / sqlalchemy_test.py
Last active January 22, 2017 17:29
Demonstration that SQLAlchemy doesn't facilitate the first bug described in http://kevinmahoney.co.uk/articles/django-orm-mistakes/
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy import Column, Integer, create_engine
Base = declarative_base()
class Thing(Base):
__tablename__ = "thing"
@porterjamesj
porterjamesj / .emacs.min
Created February 6, 2014 01:07
the minimal configuration I need to be able to use emacs effectively
(setq inhibit-startup-message t)
(global-set-key (kbd "M-n") 'forward-paragraph)
(global-set-key (kbd "M-p") 'backward-paragraph)
(setq backup-inhibited t)
(setq auto-save-default nil)
(setq create-lockfiles nil)
(defalias 'yes-or-no-p 'y-or-n-p)