Skip to content

Instantly share code, notes, and snippets.

View chrismanderson's full-sized avatar

Chris Anderson chrismanderson

View GitHub Profile
@kyanny
kyanny / gist:1668822
Created January 24, 2012 08:22
bashrc prompt git && rbenv
# rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
source ~/.rbenv/completions/rbenv.bash
# prompt with ruby version
# rbenv version | sed -e 's/ .*//'
__rbenv_ps1 ()
{
rbenv_ruby_version=`rbenv version | sed -e 's/ .*//'`
http {
upstream app_server {
# for UNIX domain socket setups:
server unix:/tmp/app.sock fail_timeout=0;
# for TCP setups, point these to your backend servers
# server 127.0.0.1:8081 fail_timeout=0;
# server 127.0.0.1:8082 fail_timeout=0;
# server 127.0.0.1:8083 fail_timeout=0;
}
// Stolen from Tumblr
#define PTH_INVALID_INITIALIZER(initDeclaration) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wobjc-designated-initializers\"") \
- (instancetype)initDeclaration { \
@throw [[NSException alloc] initWithName:@"Invalid initializer" reason:[NSString stringWithFormat:@"The initializer %s is not available.", __PRETTY_FUNCTION__] userInfo:nil]; \
return nil; \
} \
_Pragma("clang diagnostic pop")
@dannymcc
dannymcc / install_ruby_rpi.sh
Created March 14, 2017 16:06 — forked from blacktm/install_ruby_rpi.sh
A Bash script to install Ruby 2.4 on the Raspberry Pi (Raspbian)
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Installs Ruby 2.4 using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh)
# --------------------------------------------------------------------------------------------
# Welcome message

Snow in canvas land

Other people's code is awful, and your own code from months previous counts as someone else's. With this and the festive spirit in mind, I dug up a canvas snow demo I made two years ago to see how bad my code really was.

Turns out the performance landscape has changed quite a bit, but after applying a couple of workarounds, best practices, and memory management, I got the demo running smoother than it ever did.

Ugh, I can't believe I just wrote "performance landscape". Anyway...

How does the demo work?

//
// UIView+RSKeyboardLayoutGuide.swift
// RSTouchUIKit
//
// Created by Daniel Jalkut on 12/23/18.
//
import UIKit
// Extends UIView to expose a keyboardLayoutGuide property that can be used to tie a view controller's content
@koop
koop / ensure-cert-macos.sh
Created November 28, 2017 20:27
Ensures a certificate is in the macOS system keychain.
#!/bin/bash
# Usage
# $ ./install-cert-macos.sh "/path/to/cert"
CERT_PATH="$1"
# First, grab the SHA-1 from the provided SSL cert.
CERT_SHA1=$(openssl x509 -in "$CERT_PATH" -sha1 -noout -fingerprint | cut -d "=" -f2 | sed "s/://g")
# Next, grab the SHA-1s of any standard.dev certs in the keychain.
# Don't return an error code if nothing is found.
@siemensikkema
siemensikkema / objcio S01E06 Multiple Cell Types.swift
Last active April 21, 2023 17:13
Multiple Cell Types example based on episode 6 of talk.objc.io in response to question in episode 9
import UIKit
import XCPlayground
struct Episode {
var title: String
}
struct Season {
var number: Int
@gvaughn
gvaughn / copr.md
Last active January 30, 2024 16:11
git copr alias

I'd like to share some git aliases that you might find useful if you handle pull requests from others.

Add these to your ~/.gitconfig in the [alias] section:

copr = "!f() { git fetch -fu origin refs/pull/$1/head:pr-$1; git checkout pr-$1; } ; f"
prunepr = "!git for-each-ref refs/heads/pr-* --format='%(refname:short)' | while read ref ; do git branch -D $ref ; done"

Now you can "git copr #{pr_number}" (check out pull request is the mnemonic) and it will pull down the PR in a local branch of pr-#{pr_number} and check it out for you. To do it right, you must pronounce it "Copper" with a James Cagney gangster accent.

@sebboh
sebboh / gist:f1dfe4f096746c45f3e9ea06a09743a0
Last active February 27, 2024 17:10 — forked from masonforest/gist:4048732
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

This method does not add your OAuth token to Gemfile.lock. It uses bundle config to store your credentials, and allows you to configure Heroku to use environment variables when deploying.

  1. Generate an OAuth token from GitHub