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
test "Stale objects are expired, but served from cache for a grace period" | |
shell "/Users/pivotal/workspace/freshyfresh/target/memset version:test 2" | |
server s { | |
rxreq | |
expect req.url == "/" | |
txresp -status 200 -hdr "ETag: 1" -hdr "X-Generation-Key: version:test" | |
} -start | |
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
namespace :britt do | |
desc 'Removes trailing whitespace' | |
task :space do | |
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;} | |
end | |
end |
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
module ActsAsCached | |
class LocalCache | |
delegate :respond_to?, :to => :@remote_cache | |
def initialize(remote_cache) | |
@remote_cache = remote_cache | |
end | |
def cache_locally | |
@remote_cache = LocalCacheBuffer.new(original_cache = @remote_cache) |
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
package com.twitter.service.cachet.test.unit | |
import com.twitter.service.cachet._ | |
import org.joda.time.DateTime | |
import javax.servlet.http._ | |
import org.specs._ | |
import org.specs.mock._ | |
import org.specs.mock.JMocker._ | |
import com.twitter.service.cachet.test.mock._ |
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
module Cash | |
class Lock | |
def self.synchronize(*args, &block) | |
$lock.synchronize(*args, &block) | |
end | |
end | |
module Accessor | |
module ClassMethods | |
alias_method :expire_cache, :expire |
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 RequestWrapper(request: HttpServletRequest) extends javax.servlet.http.HttpServletRequestWrapper(request) { | |
override def getHeaders(name: String): java.util.Enumeration[_] = { | |
if (!ForwardRequest.hopByHopHeaders.contains(name)) | |
super.getHeaders(name) | |
else | |
java.util.Collections.enumeration(new ArrayList) | |
} | |
} |
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
package com.twitter.service.flock.edges.check | |
import scala.collection.immutable.HashMap | |
import org.scalacheck._ | |
import net.lag.configgy.{Config, Configgy} | |
import org.specs.{ScalaCheck, Specification} | |
object EdgesSpec extends Specification with ScalaCheck with Waiter { | |
Configgy.configure(System.getProperty("basedir") + "/config/test.conf") | |
val username = System.getProperty("db.test.user") |
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
# This comes from GenericWebLibrary | |
class BaseComponent | |
end | |
# This comes from RestExtensionLibrary | |
class RestComponent < BaseComponent | |
end | |
# In a language with mixins you could do | |
class SomeFilterStuff |
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
/* This is when a refactoring really pays off. | |
* | |
* In order to make your code more modular, avoid hard-coding assumptions (or refactor them away). | |
* The most fundamental, anti-modular assumption in Object-Oriented software is the concrete type of objects. | |
* Any time you write "new MyClass" in your code (or in Ruby MyClass.new) you've hardcoded | |
* an assumption about the concrete class of the object you're allocating. These makes it impossible, for example, | |
* for someone to later add logging around method invocations of that object, or timeouts, or whatever. | |
* | |
* In a very dynamic language like Ruby, open classes and method aliasing mitigate this problem, but | |
* they don't solve it. If you manipulate a class to add logging, all instances of that class will have |
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
nkallen_: nkallen_: anyway, i want to stress that we basically agree about things so i want to be sure that the tone of the blog post is such | |
[7:25pm] nkallen_: [7:17pm] nkallen_: i would argue that what you do in rails 3 (according to these tweets I've read) | |
[7:25pm] nkallen_: [7:17pm] nkallen_: is exactly what I propose... this is just how one might do it in Ruby | |
[7:25pm] nkallen_: [7:18pm] nkallen_: but my point is conceptual and not about ruby | |
[7:25pm] nkallen_: [7:18pm] nkallen_: it applies to every oo language and also I might argue to functional languages | |
[7:25pm] nkallen_: [7:18pm] nkallen_: which is to structure a program around the ability to layer on enhanced functionality and ensure that no assumptions are hardcoded by abstracting over the manufacture of objects | |
[7:25pm] nkallen_: [7:19pm] nkallen_: in the literature, these techniques are called DI, decorators, and factories. | |
[7:25pm] nkallen_: [7:20pm] nkallen_: i like these terms because they reflect the concepts that are at work. because ruby m |