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 Test::Unit::TestCase | |
def paginate(collection) | |
WillPaginate::Collection.create(1, 10) do |pager| | |
pager.replace(collection) | |
pager.total_entries = 25 | |
end | |
end | |
# Example: |
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
# | |
### Cookbook Name:: haproxy | |
### Recipe:: default | |
### Author:: Joe Williams <joe@joetify.com> | |
### | |
### Copyright 2008, Joe Williams | |
### | |
### Licensed under the Apache License, Version 2.0 (the "License"); | |
### you may not use this file except in compliance with the License. | |
### You may obtain a copy of the License at |
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
(ns fsm | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic])) | |
;; Encoding a Finite State Machine and recognizing strings in its language in Clojure core.logic | |
;; We will encode the following FSM: | |
;; | |
;; (ok) --+---b---> (fail) | |
;; ^ | |
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
package org.specs2 | |
package mutable | |
import org.specs2.execute.StandardResults | |
import org.specs2.main.ArgumentsShortcuts | |
import org.specs2.matcher.MustThrownMatchers | |
import org.specs2.specification.AutoExamples | |
import org.specs2.specification.FormattingFragments | |
import org.specs2.matcher.ShouldThrownMatchers | |
import org.specs2.specification.SpecificationStructure |
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
app = node[:rails][:app] | |
rails_base app[:name] do | |
ruby_ver app[:ruby_ver] | |
gemset app[:gemset] | |
end | |
%w{config log pids cached-copy bundle system}.each do |dir| | |
directory "#{app[:app_root]}/shared/#{dir}" do | |
owner app[:deploy_user] |
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
import subprocess | |
import sys, re | |
MERC = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs' | |
infile = sys.argv[1] | |
info_output = subprocess.Popen(['gdalinfo', infile], stdout=subprocess.PIPE).communicate()[0] | |
size_is_re = re.compile('Size is (?P<width>\d+), (?P<height>\d+)') | |
size_is = filter(lambda x: x, map(lambda x: size_is_re.match(x), info_output.split('\n'))) |
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
case class Reader[T, +A](run: T ⇒ A) { | |
def map[B](f: A ⇒ B): Reader[T, B] = | |
Reader((r: T) ⇒ f(run(r))) | |
def flatMap[B](f: A ⇒ Reader[T, B]): Reader[T, B] = | |
Reader((r: T) ⇒ f(run(r)).run(r)) | |
def &&&[B](x: Reader[T, B]): Reader[T, (A, B)] = | |
for { | |
a ← this |
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
package example | |
import java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.ConcurrentLinkedQueue | |
import com.typesafe.config.Config | |
import com.typesafe.config.ConfigFactory | |
import akka.actor.Actor | |
import akka.actor.ActorContext | |
import akka.actor.ActorRef | |
import akka.actor.ActorSystem |
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
object NettyFutureBridge { | |
import scala.concurrent.{ Promise, Future } | |
import scala.util.Try | |
import java.util.concurrent.CancellationException | |
import org.jboss.netty.channel.{ Channel, ChannelFuture, ChannelFutureListener } | |
def apply(nettyFuture: ChannelFuture): Future[Channel] = { | |
val p = Promise[Channel]() | |
nettyFuture.addListener(new ChannelFutureListener { | |
def operationComplete(future: ChannelFuture): Unit = p complete Try( |
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/bash | |
# | |
# Setup VPN between Debian Linux and VPC G/W. | |
# How to use : ./this_script.sh Generic.txt | |
# | |
# For connecting IPsec VPN, you need to allow these connections. | |
# If VPN has global address, you change FORWARD to OUTPUT. | |
# | |
# ex) iptables -A FORWARD -p udp --dport 500 -j ACCEPT | |
# iptables -A FORWARD -p tcp --dport 500 -j ACCEPT |
OlderNewer