Skip to content

Instantly share code, notes, and snippets.

View joechrysler's full-sized avatar

Joe Chrysler joechrysler

  • Atomic Object
  • Grand Rapids, Michigan
View GitHub Profile
@joechrysler
joechrysler / atomic_lines
Created January 11, 2012 15:26
Move lines of code around using vim's directional keys
" Pop the following into your .vimrc
" Move a line of text using CTRL+[arrows]
nmap <C-down> mz:m+<cr>`z
nmap <C-up> mz:m-2<cr>`z
nmap <C-left> <<
nmap <C-right> >>
vmap <C-down> :m'>+<cr>`<my`>mzgv`yo`z
vmap <C-right> :m'<-2<cr>`>my`<mzgv`yo`z
"" Move around split windows with CTRL+[jkhl]
@joechrysler
joechrysler / gist:2580265
Created May 2, 2012 20:37
Pushing mercurial repositories to github

Pushing mercurial into github

a guide for sceptic's

It's easy they said. Distributed SCMs are all basically the same they said, so transitioning from one to the other is super easy. So easy that in the time it's taken to write this sentence, you should have already installed a plugin and pushed your mercurial repo up to github right?

Lies. Horrible horrible lies.

The mercurial to git conversion is nothing short of a pain. Documentation is spotty and full of that peculiarly glib variety of optimism found most often at fast food eateries and VC-funded startups. But you know that already. That's why you're here after all.

Is all lost?

no. you can escape the plastic land of hg and enter the land of gritty git goodness.

@joechrysler
joechrysler / ping-pong.rb
Created May 16, 2012 20:25
Playing with redis migrations
require "rubygems"
require "redis"
origin = Redis.new(host: '127.0.0.1', port: 6379)
destination = Redis.new(host: '127.0.0.1', port: 6380)
500.times do |i|
origin.set(i, "value#{i}")
end
@joechrysler
joechrysler / who_is_my_mummy.sh
Last active April 8, 2024 13:36
Find the nearest parent branch of the current git branch
#!/usr/bin/env zsh
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
# How it works:
@joechrysler
joechrysler / pep8-break.py
Created July 30, 2013 18:33
PEP8 Line Breaks
# In our codebase, we do a lot of this:
if some_really_long_boolean
and another_really_long_boolean
and a_third_really_long_boolean:
print "Yehaw!"
# PEP8 says we should probably be writing thusly
if some_really_long_boolean and
another_really_long_boolean and
a_third_really_long_boolean:
<script>
window.onload = function (e) {
var my_image = document.getElementById("image_id"); // Get a reference to the image tag
var d = new Date(); // Instantiate a new date object
if (d.getDay() == 3) { // Sunday = 0, Monday = 1, etc... // If today is Wednesday
my_image.src = "path/to/other/image.png"; // Change the image's src attribute
}
}
</script>
@joechrysler
joechrysler / weirdness.sh
Last active January 3, 2016 04:19
A test...
#!/usr/bin/env bash
mkdir weirdness
cd weirdness
git init
echo "hello" > file
git add file
git commit -m "add file"
echo ''
git checkout -b new_branch # make the new branch so you don't lose commits
git push origin new_branch:new_branch # push your new branch to github so github doesn't lose commits
git checkout master # switch to master so that you're resetting master, not your new branch
git reset --hard cbedd62 # move master back to the last commit it should be on
git checkout master # you should be at the old commit.
git push -f origin master:master
@joechrysler
joechrysler / move_completed_reminders_to_dayone
Last active December 27, 2015 05:24
SCRIPT to move completed reminders into a DayOne journal
on run {input, parameters}
tell application "Reminders"
if (count of (reminders whose completed is true)) > 0 then
set todoList to reminders whose completed is true
repeat with itemNum from 1 to (count of (reminders whose completed is true))
set reminderObj to item itemNum of todoList
set nameObj to name of reminderObj
set compDateObj to completion date of reminderObj
if (body of reminderObj) is not "" and (body of reminderObj) is not missing value then
set bodyObj to " Notes: " & body of reminderObj

Keybase proof

I hereby claim:

  • I am joechrysler on github.
  • I am joechrysler (https://keybase.io/joechrysler) on keybase.
  • I have a public key whose fingerprint is 71C8 5928 84FB 0525 82DB 61EA 5741 DED0 F064 E9A9

To claim this, I am signing this object: