Skip to content

Instantly share code, notes, and snippets.

@bmarini
bmarini / redis_store.rb
Created July 21, 2010 15:11
ActiveSupport::Cache::RedisStore, a drop in replacement for MemCacheStore
require 'redis'
# This is a direct port of ActiveSupport::Cache::MemCacheStore
# Drop this file in lib/active_support/cache/redis_store and in your env files
# add:
#
# config.cache_store = :redis_store
module ActiveSupport
module Cache
// Service Definition
ServiceDefinition serviceDefinition = injector.getInstance(ServiceDefinition.class);
serviceDefinition
.producing(ServiceDefinition.Media.JSON)
.producing(ServiceDefinition.Media.XML)
.consuming(ServiceDefinition.Media.JSON)
.consuming(ServiceDefinition.Media.XML)
.withHandler(new ServiceHandler(ServiceDefinition.HttpMethod.PUT, "id", "createAddressBook"))
.withHandler(new ServiceHandler(ServiceDefinition.HttpMethod.GET, "id", "getAddressBook"))
Client: Mac Pro OS X, 2.8Ghz Quad-Core Intel Xeon, 8 GB 1066 Mhz DDR3
Server: lighttpd/1.4.26 -> Ubuntu, 2.8Ghz Duo-Core Intel Xeon, 6 1066 Mhz DDR3
50 threads that does 50 requests, done 50 times.
Async Http Client 1.5.0 (Config http://is.gd/7rGGWU)
=============================================================
BenchmarkResult{requestsPerSecond=1578.96, threads=50, batches=50, targetRequests=125000, successfulRequests=125000, failedRequests=0, averageRequestTime=0.63ms, averageBatchTime=1583.32ms, totalBenchmarkTime=79166.03ms}
(last 5 runs)
java.lang.Thread.State: RUNNABLE
at java.util.Arrays.copyOf(Arrays.java:2734)
at java.util.PriorityQueue.toArray(PriorityQueue.java:357)
at java.util.concurrent.DelayQueue.toArray(DelayQueue.java:360)
at java.util.concurrent.DelayQueue.iterator(DelayQueue.java:439)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue$1.<init>(ScheduledThreadPoolExecutor.java:644)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.iterator(ScheduledThreadPoolExecutor.java:643)
at java.util.concurrent.ThreadPoolExecutor.drainQueue(ThreadPoolExecutor.java:1198)
at java.util.concurrent.ThreadPoolExecutor.shutdownNow(ThreadPoolExecutor.java:1175)
at java.util.concurrent.ScheduledThreadPoolExecutor.shutdownNow(ScheduledThreadPoolExecutor.java:580)
@eculver
eculver / Projects with beautiful websites
Created February 10, 2011 18:54
Projects with beautiful websites
Vows: http://vowsjs.org/
SASS: http://sass-lang.com/
SSHGuard (pretty decent layout): http://www.sshguard.net/
Django Haystack: http://haystacksearch.org/
twelvesouth (products not project, but still): http://www.twelvesouth.com/
@superchink
superchink / show
Created April 20, 2011 22:42 — forked from tekacs/show
This does something essentially equivalent to showoff.io if you have a publicly facing server...
# Usage: show <local-port> <subdomain>
function show() {
DOMAIN=".webhostology.com"
REMOTE="$2$DOMAIN"
ssh -tR 8080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:8080 localhost"
}
@lfborjas
lfborjas / show.py
Created April 28, 2011 02:40
Tunnel a local port to a remote host (like showoff.io does)
#!/usr/bin/python
#usage python show.py <local_port>
'''
Taken from: https://gist.github.com/932137 (found in http://news.ycombinator.com/item?id=2467107 )
Let's say you have a webapp running in localhost (with `manage.py runserver` in django or `ruby script.rb` in sinatra or `rails server` or whatever) and you want others to be able to see it with a public url without deploying remotely.
ssh provides a neat facility for that: tunneling. You set up a "tunnel" from the remote host to yours and vice-versa and then you give the remote host's url and it will send all of its requests to your local daemon.
package io.tesla.issues.jira;
import java.nio.charset.Charset;
import com.google.common.io.BaseEncoding;
import retrofit.RequestInterceptor;
import retrofit.RestAdapter;
public class JiraService {
@rstacruz
rstacruz / 1.haml
Created October 22, 2010 13:52
3.rb
-# Super cheapo minification!
-# Here's how it works:
-#
-# * The HAML below points to the minified version on production,
-# or prints <script> tags if not.
-#
-# * We define the route to /js/script.js ourselves.
-#
-# * Some silly caching will ensure that the minification only happens once.
@acreeger
acreeger / gist:1027916
Created June 15, 2011 19:42
ElasticSearch: query_string vs text queries
curl -XDELETE http://localhost:9200/ac-test
curl -XPUT http://localhost:9200/ac-test
curl -XPUT http://localhost:9200/ac-test/people/1 -d '
{
"firstNames" : "James Earl",
"lastName" : "Jones",
"location" : "Hollywood, CA"
}'
curl -XPUT http://localhost:9200/ac-test/people/2 -d '