Skip to content

Instantly share code, notes, and snippets.

repository 'http://repo1.maven.org/'
local_repo 'lib/java'
jar 'com.netflix.astyanax:astyanax-core:1.56.48'
jar 'com.netflix.astyanax:astyanax-thrift:1.56.48'
jar 'com.netflix.astyanax:astyanax-cassandra:1.56.48'
@lucasallan
lucasallan / jruby-startup-improvement
Last active August 29, 2015 14:01
Improving JRuby startup time
#JRuby without custom configuration:
>$ time rake -T
36.69s user 1.48s system 282% cpu 13.524 total
# Disable invokedynamic and Tiered compilation (64-bit)
>$ export JAVA_OPTS='-Djruby.compile.mode=OFF -XX:+TieredCompilation -XX:TieredStopAtLevel=1'
>$ export JRUBY_OPTS='-Xcompile.invokedynamic=false'
>$ rake -T
@lucasallan
lucasallan / java_future.rb
Last active August 29, 2015 14:04
Using Java futures with JRuby
require 'java'
java_import 'java.util.concurrent.FutureTask'
java_import 'java.util.concurrent.Executors'
class JavaFuture
class Callable
def initialize(block)
@block = block
end
atomic = Concurrent::AtomicFixnum.new()
# => #<Concurrent::AtomicFixnum:0x007fe4ac1ad220 @value=0, @mutex=#<Mutex:0x007fe4ac1ad1f8>>
atomic.value
# => 0
atomic.up
# => 1
atomic.value
# => 1
atomic.down
# => 0
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
* File Name : ssh.go
* Purpose :
* Creation Date : 11-18-2013
* Last Modified : Thu Dec 5 23:12:09 2013
def basic_auth
r = Nginx::Request.new
realm_name = r.var.realm_name
if r.headers_in["Authorization"].nil?
r.headers_out["WWW-Authenticate"] = %Q(Basic realm="#{realm_name}")
return Nginx::HTTP_UNAUTHORIZED
end
auth = r.headers_in["Authorization"]
@lucasallan
lucasallan / Makefile
Last active August 29, 2015 14:26 — forked from jvns/Makefile
A fun rootkit! See http://jvns.ca/blog/2013/10/08/day-6-i-wrote-a-rootkit/ for the story Most of the code is taken from https://github.com/mfontanini/Programs-Scripts/blob/master/rootkit/rootkit.c, so GPL'd as well
obj-m += rootkit.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
# Removendo porcarias
run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
# Git
git :init
file(".gitignore") do
<<-EOF

Rails 2.3.10 on App Engine (DataMapper)

Do not use rvm (or install and run from JRuby). The google-appengine gem must install into your system MRI. The appengine-sdk gem includes a complete Java app server. We bootstrap Java from MRI, then your app runs inside a servlet container (with access to all the APIs) using the version of JRuby installed into each app.

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.x calls to rubygems, and now we have it working. Rails 2.3.x currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

See the TInyDS version also: gist.github.com/gists/269075

Install the Development Environment

@lucasallan
lucasallan / README.rdoc
Created December 26, 2010 03:21 — forked from woodie/README.rdoc
Rails 2.3.10 on App Engine

Rails 2.3.10 on App Engine

Do not use rvm (or install and run from JRuby). The google-appengine gem must install into your system MRI. The appengine-sdk gem includes a complete Java app server. We bootstrap Java from MRI, then your app runs inside a servlet container (with access to all the APIs) using the version of JRuby installed into each app.

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.x calls to rubygems, and now we have it working. Rails 2.3.x currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

See the DataMapper version also: gist.github.com/671792

Install the Development Environment

One meta-gem provides the development environment