Quick Code Clips

Ok so this is going to be a place for my brain to spill over to. In turn helpful code clippings that I always seam to be googling

Go Scripts

Converting byte data to string (I use this a lot when debugging Json in byte format)

log.Printf("%v", string(data[:]))


Terminal Short Cuts

Have you ever typed a long command into terminal then try to find it in your history by holding the up key. Well this is the short cut for you.

ctrl r

This uses reg expressions and searches your history for you. Start typing and see the whole command appear. To cycle through responses just click ctrl r to iterate.

Rake Short Cuts

rake -W

This shows a possible list of all tasks that can be run from that rake file.

note: rake files are amazing. Like Nutella on a crumpet.

Git Commands

git is fun when you do it right (HELL when you do it wrong).

git add --all

The benefit of this over git add * or git add is it will handle all your deletes and renames of files. Goodbye git rm -rf

git remote prune origin

This removes all deleted branches from the remote repo, if there are no changes on your local branch

Ruby

Have been doing some cucumber tests for IOS. This is a nice way of getting into an interactive irb session from a step.

https://github.com/pry/pry

When(/^I debug$/) do
  require "pry"; binding.pry
end

This will pause your cucumber but enables you interact with ruby.

Calabash

calabash-ios console

Get an interactive terminal session with the running calabash.

Cocoapods

cocoapods (pod) is an ios dependancy manager.
It is a ruby gem you can install, then using a pod file you are able to add pod dependancies to your ios application.

When you get problems with your pod on 'pod install' use
 $ sudo rm -fr ~/.cocoapods/repos/master
 $ pod setup

No comments:

Post a Comment