Joined July 2012
·
D21ebccf20562e370eb0a8cf170a0580

Jason Rogers

Samasource
Samasource
·
Saline, MI, USA
·
·
·

Posted to Git: switch between last two branches over 1 year ago

Ales, check out my easy aliases (recent branches and select a branch)to quickly switch between any number of branches.

Posted to Mac OS X & Oh My ZSH Theme on iTerm2 over 1 year ago

I really like it. Makes me want to go back to ZSH. I'd also appreciate it if you shared any functions/scripts that aid you in your Ruby-specific project development. One thing I miss in ZSH is deep command completion for things like bundle, rake, guard.

Thanks for sharing.

@johnantoni -- also see this follow-up where I use this alias to implement a branch switching functionality between these branches.

@johnantoni -- what does that buy you? Doesn't that launch another git process?

Posted to jQuery ain't jQuery no more... over 1 year ago

Major version changes are typically used for these cases. It's a good decision. Folks should always read the release notes before upgrading anyway.

Your title is misleading. It's still jQuery -- it's just not applicable to what-should-be-dead-versions-of-inferior browsers.

Posted to `cat` syntax highlighting over 1 year ago

Thanks. I'd been using code-less (using the Vim trick). Now I have code-cat for quick dumps.

Posted to WTF did I do?! over 1 year ago

I updated this slightly, based on @jensnilsson's latest comments:

#!/bin/bash

function usage() {
  echo 'Usage: what-did-i-do {options}'
  echo
  echo 'OPTIONS:'
  echo '    -a   author/committer        (defaults to Jason Rogers)'
  echo '    -s   since such date         (defaults to 7.days.ago)'
  echo '    -u   until such date         (defaults to today)'
  echo '    -o   author output format    (one of short, full, initials -- defaults to initials)'
  echo
  echo '-s and -u accepts any Git date: 2013-03-01, 7.days.ago, today, yesterday'
  exit 0
}

SINCE='7.days.ago'
UNTIL='today'
AUTHOR='<put your author name here>'
AUTHOR_OUTPUT='initials'

while getopts “ha:s:o:u:” OPTION
do
  case $OPTION in
    h)
      usage
      exit 1
        ;;
    a)
      AUTHOR=$OPTARG
      ;;
    o)
      AUTHOR_OUTPUT=$OPTARG
      ;;
    s)
      SINCE=$OPTARG
      ;;
    u)
      UNTIL=$OPTARG
      ;;
    ?)
      usage
      exit
      ;;
  esac
done

function initials() {
  echo $AUTHOR | ruby -e'print $stdin.read.split(" ").map{|e| e[0]}.join("")'
}
function shortname() {
  echo $AUTHOR | ruby -e'words = $stdin.read.split(" "); print words[0]; print words[1][0]'
}

case $AUTHOR_OUTPUT in
  full)
    AUTHOR_OUTPUT=$AUTHOR
    ;;
  initials)
    AUTHOR_OUTPUT=$(initials)
    ;;
  short)
    AUTHOR_OUTPUT=$(shortname)
    ;;
  *?)
    echo "unrecognized author output ('$AUTHOR_OUTPUT'); using 'initials'"
    AUTHOR_OUTPUT=$(initials)
    ;;
esac

git log --no-merges --pretty=format:"$AUTHOR_OUTPUT - %ad -> %s" --date-order --date=short --since=$SINCE --until=$UNTIL --author="$AUTHOR"
Posted to Rails - Internal Requests over 1 year ago

What you describe here makes me think your controller is doing too much.

As was said earlier, just abstract the behavior into another class and send it the appropriate message(s). That abstraction shouldn't tell you whether or not you need to redirect anywhere, or replace DIVs, or anything of that nature. All of that logic still belongs in the controller, but the abstraction should give you enough information to be able to make that determination.

The same can be said in regard to @ctide's response.

Posted to Responsive vertical Timeline with CSS over 1 year ago

Nice

Posted to Random Encouragement over 1 year ago

play was included in my list of Linux alternatives. However, I'm not sure that it's available on all distributions, by default. What distro are you running?

@projectcleverweb, true -- those are some advantages of self-hosting. I'll also mention that from a security standpoint, GH and BB both offer firewall installations (for a fee of course). As far as customizations, you are again correct, but the ability to customize can hurt you too (time, effort, etc.).

In short, not disagreeing at all, just offering more options. :)

BitBucket also allows for an unlimited number of private repos (and I suspect unlimited public repos, but they don't really say that). They support Git or Mercurial (just in case you are curious about that other one). They have an import function which works nicely with GitHub, which I've used to move all of my private repos from GH to BB. The free plan only allows for a max of 5 users.

Posted to Quickly navigating branches in Git over 1 year ago

@sheerun Thanks. I'm aware of that. This alias allows you to jump back and forth between the last 10 branches you've been active on. git checkout -, as you pointed out, only allows you to go back to the branch you were on previously.

Honestly 10 is a high number of branches to be doing context switching. This alias could be tweaked to take a different count and pass that to the for-each-ref alias. However, 10 seemed like a nice round number and fits on the screen nicely.

@drabiter are you able to run the full command?

git for-each-ref --sort=-committerdate --count=10 --format='%(refname:short)' refs/heads/

I would assume you're not able to.

@hauleth right you are again.

@hauleth thanks, updated the post. I didn't see the --count param.

However, if I wanted to be able to pass the count in the future, the function version would come in handy.

@vetal4eg Thanks! Definitely will check this out.

I'm a Vim user, have been for many years. It's my go-to editor for most things. However, I spend most of my day in ST2 now. The one key feature that ST2 has that keeps me from going back to Vim on a regular basis is the multiple cursor. I don't know a good way of accomplishing this Vim. I can use CTRL+SHIFT+V to get a column based cursor, but it's somewhat rare that I need column-based editing. It's more likely that I want to use the multiple cursor feature for pattern-based editing.

Posted to tidied HTML in vi/vim over 1 year ago

Thanks @petdance, but Tidy does much more than just fix indentation.

Posted to Search text in directory over 1 year ago

I use this alias:

alias rgrep='grep -rnH'

and use it like this:

$> rgrep 'TODO' spec lib
Posted to programming with purpose. over 1 year ago

That's one reason why I work for @Samasource. We're working to impact women and youth in poverty, to teach them the skills they need to gain access to dignified work. The work they do for us enables them to support themselves and their families in ways they could have never imagined.

Posted to pbcopy & pbpaste over 1 year ago

xclip is certainly an alternative, Looking at the popularity contest statistics for the two, about 29% still use xsel though. I'll update my post to include xclip information.

Posted to commandline output for coderwall.com over 1 year ago

This is meant for CL output, not code in an editor.

1) Your command echos files, as well as directories.
2) Your command doesn't deal with recursive subdirectories.

Perhaps you didn't intend for #2 above. If that's the case just add a -maxdepth argument to the find command:

for dir in `find . -type d -maxdepth 1`; do echo $dir ; done;

That doesn't get all subdirectories. I assume you mean for the '*' to be replaced with something else.

If you really want all subdirectories replace the '*' with a call to 'find':

for dir in `find . -type d`; do echo $dir ; done;

I use a gem called grb (https://rubygems.org/gems/grb) to do most of my branch maintenance. It adds 2 steps to the process of creating and tracking a new branch: pushing a ref head and then fetching the branch you're branching off of. It's a more complete algorithm, I think. It also has commands for adding remotes, deleting branches (locally and remotely), renaming branches, etc.

! grb new foo --explain
git push origin my_current_branch:refs/heads/foo
git fetch origin
git branch --track foo origin/foo
git checkout foo

If you have Tidy installed on your machine, it gets even easier. http://coderwall.com/p/lb-obq

Posted to git diff in your editor over 1 year ago

Thanks, @lokiastari. That's even better!

Achievements
806 Karma
35,302 Total ProTip Views