Skip to content

Instantly share code, notes, and snippets.

View probablycorey's full-sized avatar
👯‍♂️
Dancing with my twin

Corey Johnson probablycorey

👯‍♂️
Dancing with my twin
View GitHub Profile
@probablycorey
probablycorey / generate-file
Last active January 5, 2020 15:58
Create large files
#!/usr/bin/env coffee --nodejs --harmony
fs = require 'fs'
MB = 1048576
[ignore, ignore, filePath, megabytes] = process.argv
fileSize = 0
words = fs.readFileSync('/usr/share/dict/words').toString().split("\n")
ws = fs.createWriteStream(filePath)

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 June 11, 2019 22:27 — forked from pifafu/log.txt
Build log
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

wow .

Hello

This is a thing

# 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 November 10, 2016 02:50
Bash function that enhances the `man` command
# 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 September 23, 2016 23:07
Better date parsing
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
#!/bin/sh
set -e
BRANCH=$(git branch | sed -n '/\* /s///p')
git branch --set-upstream-to=origin/$BRANCH $BRANCH
@probablycorey
probablycorey / something.coffee
Last active December 20, 2015 06:08
Simulate keydown,keypress,keyup and textinput in chrome
# Shift still doesn't work
window.keydown = (key, {ctrl, shift, alt, meta}) ->
dispatchKeyboardEvent = (target, eventArgs...) ->
e = document.createEvent("KeyboardEvent")
e.initKeyboardEvent eventArgs...
target.dispatchEvent e
dispatchTextEvent = (target, eventArgs...) ->
e = document.createEvent("TextEvent")
e.initTextEvent eventArgs...
@probablycorey
probablycorey / peer.html
Created July 19, 2013 00:41
A bug in peer js
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>PeerJS Issue</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-us">
<script type="text/javascript" src="http://cdn.peerjs.com/0/peer.js"></script>
<script type="text/javascript" src="http://coffeescript.org/extras/coffee-script.js"></script>
<script type="text/coffeescript">
window.host = ->