This file contains hidden or 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
source "http://rubygems.org" | |
gem "sinatra" |
This file contains hidden or 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
<h1>{{ site.title }}</h1> | |
<nav> | |
<ul> | |
{% for link in site.menu %} | |
<li>{{ link }}</li> | |
{% endfor %} | |
</ul> | |
</nav> |
This file contains hidden or 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
/ Template markup: | |
/ Points to the "application.js.coffee" Sprockets manifest. | |
= javascript_include_tag "application" |
This file contains hidden or 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
PCRE (required by Nginx) not installed, downloading it... | |
# wget -O /tmp/ubuntu-passenger-7717/pcre.tar.gz ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz | |
--2011-12-15 18:38:20-- ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz | |
=> `/tmp/ubuntu-passenger-7717/pcre.tar.gz' | |
Resolving ftp.csx.cam.ac.uk... 131.111.8.80 | |
Connecting to ftp.csx.cam.ac.uk|131.111.8.80|:21... connected. | |
Logging in as anonymous ... Logged in! | |
==> SYST ... done. ==> PWD ... done. | |
==> TYPE I ... done. ==> CWD (1) /pub/software/programming/pcre ... done. | |
==> SIZE pcre-8.12.tar.gz ... done. |
This file contains hidden or 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 'dalli' | |
module Carbonmade | |
module Cache | |
class MembaseBackend | |
DEFAULT_SETTINGS = { | |
:host => '127.0.0.1:11211', | |
:expires_in => (60 * 60 * 2) # 2 hours | |
} |
This file contains hidden or 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
# Things work great at this point. | |
cache = Dalli::Client.new('127.0.0.1:11211') | |
cache.get('test') # => nil (it's working!) | |
# Now shutdown membase completely... | |
cache.get('test') # => Dalli::RingError | |
# Now what? Ideally `cache.get` (and other cache functions) would | |
# fail silently until a connection can be re-established. |
This file contains hidden or 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
def user_status(self, user): | |
# If the user has no blog (for some reason) they are inactive. | |
if user.owned_blogs.count() == 0: | |
return 'Inactive' | |
# If they only have one blog, their status is that blog's status. | |
if user.owned_blogs.count() == 1: | |
blog = user.owned_blogs.all()[1] | |
status = blog.status | |
if status == Blog.UNCONFIRMED: |
This file contains hidden or 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
# Python is too stupid to know that you want list items coerced to strings when joining them. | |
# Instead you must manually cast items to strings -- in this case, integers. | |
# Strings join fine! | |
>>> ",".join(['a','b']) | |
'a,b' | |
# But not integers! | |
>>> ",".join([1,2]) | |
Traceback (most recent call last): |
This file contains hidden or 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
# Install the pre-release of Bundler: | |
gem install bundler --pre | |
# Run from within your project directory | |
bundle outdated |
This file contains hidden or 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 SpecialThing(Thing): | |
def save(self, *args, **kwargs): | |
# If only I could `my_kwarg = kwargs.delete('my_kwarg') | |
my_kwarg = 'my_kwarg' in kwargs | |
if my_kwarg: | |
kwargs.pop('my_kwarg') | |
result = super(SpecialThing, self).save(*args, **kwargs) | |
if my_kwarg: | |
self.do_more_stuff() |