Skip to content

Instantly share code, notes, and snippets.

Darren Jensen jensendarren

Block or report user

Report or block jensendarren

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am jensendarren on github.
  • I am jensendarren (https://keybase.io/jensendarren) on keybase.
  • I have a public key ASCUxtscnfGIjSlMCwIboYoEa2sGTmteWlwklL9PgF72xAo

To claim this, I am signing this object:

@jensendarren
jensendarren / bashrc
Created Jul 27, 2015
Add git alias to your terminal command set
View bashrc
# Add this to your ~/.bashrc file then run `source ~/.bashrc`
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias gg='git grep -i'
alias go='git checkout '
@jensendarren
jensendarren / gist:e5614e19db0dcf96fa44
Created Jul 9, 2015
Git diff which includes new files
View gist:e5614e19db0dcf96fa44
if test "$#" = 0; then
(
git diff
git ls-files --others --exclude-standard |
while read -r i; do git diff -- /dev/null "$i"; done
)
else
git diff "$@"
fi
@jensendarren
jensendarren / uri_example.rb
Created Jan 8, 2015
An example of using URI in Ruby
View uri_example.rb
require 'uri'
require 'open-uri'
google_url = "http://google.com/"
url = URI.parse(google_url)
# Get the hostname
puts "The hostname is #{url.hostname}"
@jensendarren
jensendarren / optparse_example.rb
Created Jan 8, 2015
An example of using OptionParser in Ruby
View optparse_example.rb
# Restrict arguments to a specified class.
require 'optparse'
class HelloParser
def self.parse(args)
options = {}
opts = OptionParser.new do |opts|
opts.banner = "Usage: name"
opts.on('-n', '--name NAME', 'The name of the person to say hello to') do |name|
@jensendarren
jensendarren / logger_example_stdout.rb
Created Jan 8, 2015
An example of using STDOUT Logger in Ruby
View logger_example_stdout.rb
# http://www.ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html
require 'logger'
class CoffeeShop
attr_reader :logger
def initialize(name)
@name = name
@menu = []
@logger = Logger.new(STDOUT)
@jensendarren
jensendarren / logger_file_example.rb
Created Jan 8, 2015
An example of using a file Logger in Ruby
View logger_file_example.rb
require 'logger'
class CoffeeShop
attr_reader :std_logger, :file_logger
def initialize(name)
@name = name
@menu = []
@std_logger = Logger.new(STDOUT)
@file_logger = Logger.new('./coffee_shop.log')
@jensendarren
jensendarren / fileutils_example.rb
Created Jan 8, 2015
An example of using FileUtils in Ruby
View fileutils_example.rb
require 'fileutils'
# __FILE__ keyword in ruby
puts "The current ruby file being executed is #{__FILE__}"
# Gets the directory name of the file being executed
current_directory = File.dirname(__FILE__)
puts "The current directory is #{current_directory}"
# expands to reveal the pwd (Present working directory)
@jensendarren
jensendarren / benchmark_example.rb
Last active Aug 29, 2015
An example of using Benchmark lib in Ruby
View benchmark_example.rb
require 'benchmark'
# Compare sorting a Hash with an Array
arr = []
hash = {}
10_000.times.with_index do |i|
ascii_code = rand(255)
random_char = ascii_code.chr
arr << random_char
@jensendarren
jensendarren / obervable_example.rb
Last active Jun 27, 2018
Example of using Observable in Ruby
View obervable_example.rb
require 'observer'
class CoffeeShop
include Observable
attr_reader :customers
def initialize(name, capacity)
@name = name
@capacity = capacity
@customers = []
You can’t perform that action at this time.