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
# via @avdi's RubyTapas Episode 170: http://www.rubytapas.com/episodes/170-Hash-Merge | |
headers = <<END | |
Accept: */* | |
Set-Cookie: foo=42 | |
Set-Cookie: bar=23 | |
END | |
def parse_headers(headers) | |
headers.lines.reduce({}) { |result, line| |
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 | |
brew_install_if_needed() { | |
package=$1 | |
brew info $package | grep "Not installed" > /dev/null 2>&1 | |
if [[ "$?" -eq "0" ]]; then | |
brew install $package | |
fi | |
} |
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
class Nerd < ActiveRecord::Base | |
belongs_to :team, inverse_of: :nerds | |
def team | |
super || NullTeam.new | |
end | |
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
☺ $ dig rustbyexample.com +nostats +nocomments +nocmd | |
; <<>> DiG 9.8.3-P1 <<>> rustbyexample.com +nostats +nocomments +nocmd | |
;; global options: +cmd | |
;rustbyexample.com. IN A | |
rustbyexample.com. 3142 IN A 103.245.222.133 |
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
# Back story: I uploaded a dozen or so HD (1080p) movies to my Synology while across the country. | |
# Now I want to make sure the uploads all came through without corruption. | |
for video in *.mp4; do | |
cmp "./${video}" "/Volumes/video/Movies/${video}" | |
done |
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.Reflection; | |
using FluentNHibernate.AutoMap; | |
using FluentNHibernate.Framework; | |
using MyApplication.Core.Domain; | |
namespace MyApplication.Core.Persistence | |
{ | |
public class MyCustomPersistenceModel : AutoPersistenceModel | |
{ | |
public MyCustomPersistenceModel() |
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.Reflection; | |
using FluentNHibernate.AutoMap; | |
using FluentNHibernate.Framework; | |
using MyApplication.Core.Domain; | |
namespace MyApplication.Core.Persistence | |
{ | |
public class MyCustomPersistenceModel : AutoPersistenceModel | |
{ | |
public MyCustomPersistenceModel() |
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.Reflection; | |
using FluentNHibernate.AutoMap; | |
using FluentNHibernate.Framework; | |
using MyApplication.Core.Domain; | |
namespace MyApplication.Core.Persistence | |
{ | |
public class MyApplicationPersistenceModel : AutoPersistenceModel | |
{ |
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
namespace MyApplication.UnitTests.Core.Persistence | |
{ | |
[Category("MyApplicationPersistenceModel")] | |
public class when_using_the_plan_my_night_persistence_model | |
: Specification, with_auto_persistence_model | |
{ | |
private MyApplicationPersistenceModel _model; | |
public override void establish_context() | |
{ |
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 FindGoodStuffQuery : INamedQuery<Idea> | |
{ | |
public IQueryable<Stuff> Apply(IQueryable<Stuff> queryable) | |
{ | |
return queryable | |
.OrderByDescending(s => s.Widgets.Count()) | |
.ThenByDescending(s => s.CreatedAt); | |
} | |
} |
OlderNewer