This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Set up a fresh MacBook for software development with my personal preferences. | |
# | |
# Inspiration taken from the following: | |
# - Mathias Bynen's popular config: https://github.com/mathiasbynens/dotfiles | |
# - Thoughtbot's dev-centric script: https://github.com/thoughtbot/laptop | |
# - The legendary Jessie Frazelle: https://github.com/jessfraz | |
# - Defaults-Write: https://www.defaults-write.com/ | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'state_machine' | |
module Sandpit | |
class Foo | |
state_machine :state, initial: :created do | |
event :start do | |
transition created: :running | |
transition running: same | |
end | |
event :stop do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
class Foo | |
def self.bar(first, second, third) | |
err_msg = '%s cannot be nil' | |
raise ArgumentError, err_msg % 'first' unless first | |
raise ArgumentError, err_msg % 'second' unless second | |
raise ArgumentError, err_msg % 'third' unless third | |
"#{first} #{second} #{third}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
evens, odds = (1..10).partition(&:even?) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{evens, odds} = (1..10) |> Enum.partition(fn(x) -> Integer.is_even(x) end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# receive an array of ints, compact it, order the elements, and group them into ranges | |
# original: | |
def get_ranges_in(values_array) | |
return [] if values_array.nil? | |
values_array.compact.sort.uniq.inject([]) do |r,x| | |
r.empty? || r.last.last.succ != x ? r << (x..x) : r[0..-2] << (r.last.first..x) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using FizzBuzzMap = System.Func<int, string>; | |
namespace FizzBuzz | |
{ | |
public class Program | |
{ | |
public static void Main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ActiveDirectoryService | |
{ | |
private const string GroupNotFoundMessage = "The directory group, '{0}', could not be found."; | |
private const string UserNotFoundMessage = "The user account, '{0}', could not be found "; | |
private readonly string _adDomain; | |
public ActiveDirectoryService(string domain) | |
{ | |
_adDomain = domain; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ActiveDirectoryService | |
{ | |
private const string GroupNotFoundMessage = "The directory group, '{0}', could not be found."; | |
private const string UserNotFoundMessage = "The user account, '{0}', could not be found "; | |
private readonly string _adDomain; | |
public ActiveDirectoryService(string domain) | |
{ | |
_adDomain = domain; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
namespace FizzBuzzCollapsedStringArray | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
Enumerable.Range(1, 100).Select(i => string.Join(string.Empty, new[] |
NewerOlder