Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Corey Johnson probablycorey

🏠
Working from home
View GitHub Profile
View mayby.md

hello..

Tables Are Cool
col 1 is left-aligned $1600
col 2 is centered $12
col 3 is right-aligned $1
@probablycorey
probablycorey / log.txt
Created Jun 11, 2019 — forked from pifafu/log.txt
Build log
View log.txt
carthage update --no-use-binaries --no-build
*** Fetching PINOperation
*** Checking out PINCache at "3.0.1-beta.8"
*** Checking out PINOperation at "1.1.2"
carthage build --no-skip-current
*** xcodebuild output can be found in /var/folders/6h/ql1brcjx3936vr5vwgblbnc80000rm/T/carthage-xcodebuild.tCygxC.log
*** Downloading PINOperation.framework binary at "Modernize PINOperation"
*** Downloading PINCache.framework binary at "Modernization"
*** Building scheme "PINRemoteImage-tvOS" in PINRemoteImage.xcodeproj
*** Building scheme "PINRemoteImage" in PINRemoteImage.xcodeproj
View story_bike_share_analyze_3.py
# Extract the unique routes from the data with their start and end coordinates
maps = df[['Route Id', 'Station Id From', 'Lat From', 'Lon From', 'Station Id To', 'Lat To', 'Lon To']].drop_duplicates()
maps['Distance'] = maps.apply(lambda x: distance.distance((x['Lat From'], x['Lon From']), (x['Lat To'], x['Lon To'])).km * 1000, axis=1)
# Merge the distance calculation with the main DataFrame
df = df.merge(maps[['Route Id', 'Distance']], how='left', on='Route Id')
df = df[[x for x in df.columns if not 'From' in x and not 'To' in x and x != 'Route Id']]
@probablycorey
probablycorey / woman.sh
Last active Nov 10, 2016
Bash function that enhances the `man` command
View woman.sh
# Add this to your .bashrc or .zshrc file for a modern and sophisticated
# alternative to `man`.
function woman() {
man -t $1 | open -f -a /Applications/Preview.app
}
@probablycorey
probablycorey / wow.rb
Created Sep 23, 2016
Better date parsing
View wow.rb
def parse_date_range(options)
from = Time.zone.parse(options[:from]) rescue ArgumentError
to = Time.zone.parse(options[:to]) rescue ArgumentError
to ||= from.try?(:next_day) || Date.current
from ||= to.begining_of_month
time_range = from..to
days_in_range = (to - from).to_i
to = from + MAX_DAY_RANGE.days if days_in_range > MAX_DAY_RANGE
View set-origin-branch
#!/bin/sh
set -e
BRANCH=$(git branch | sed -n '/\* /s///p')
git branch --set-upstream-to=origin/$BRANCH $BRANCH
View dmg.sh
#!/bin/bash
set -e
cd "$(dirname $0)/.."
DIST_PATH=dist
APP_NAME=Toolbelt
APP_PATH="$DIST_PATH/$APP_NAME.app"
BACKGROUND_PNG=app/assets/install.tiff
@probablycorey
probablycorey / i-do-not-know.rb
Created Jan 9, 2015
How do I unstage a staged deletion?
View i-do-not-know.rb
# Assume my-file.txt has been commited previously
repo = Rugged::Repository.discover(some_dir)
File.delete("my-file.txt")
# This will stage the file deletion
repo.index.remove("my-file.txt") # This doesn't work
repo.index.write
# How do I "unstage" this deletion?
repo.index.add("my-file.txt") # This doesn't work... what will?
View nodegit-bug.js
var git = require('nodegit');
var repo = null;
var repoPath = process.argv[2]
if(!repoPath) {
console.log("Usage: node nodegit-bug.js PATH_GIT_REPO")
process.exit(1)
}
git.Repository.open(repoPath)
You can’t perform that action at this time.