Skip to content

Instantly share code, notes, and snippets.

🔛

James J Porter porterjamesj

🔛
Block or report user

Report or block porterjamesj

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
@porterjamesj
porterjamesj / fix-venv.sh
Created Oct 2, 2016 — forked from pv8/fix-venv.sh
Fix virtualenv symlinks after upgrading python with Homebrew and running brew cleanup
View fix-venv.sh
#!/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 Aug 14, 2019
Homebrew formula for timelens (timelens.io)
View timelens.rb
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"
View three.jl
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 Mar 6, 2018
the tiniest mesos scheduler
View hello_mesos.py
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)
View goofys-panic.log
-----------------------------------------------------
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
just a small example of using google's gumbo for html parsing
View gumbo_example.c
#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];
View how_to_learn_git.md

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,
View how_to_code_review.md

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 / sqlalchemy_test.py
Last active Jan 22, 2017
Demonstration that SQLAlchemy doesn't facilitate the first bug described in http://kevinmahoney.co.uk/articles/django-orm-mistakes/
View sqlalchemy_test.py
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 Feb 6, 2014
the minimal configuration I need to be able to use emacs effectively
View .emacs.min
(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)
You can’t perform that action at this time.