Skip to content

Instantly share code, notes, and snippets.

@lucasallan
lucasallan / xml_rpc.rb
Created August 2, 2013 19:54
Debugging XML-RPC responses
require 'pp'
class XMLRPC::Client
def set_debug
@http.set_debug_output($stderr);
end
end
# StringSanitizer
#
# All the methods are recursive, which means that it will visit all the nodes of your data structure
# and converts all no-valid utf-8 strings to valid utf-8.
# It will also remove leading whitespace from the given string.
#
# This class currently supports recursive UTF-8 conversion in the following types: String, Array and Hash.
#
class StringSanitizer
# encoding: UTF-8
require 'open-uri'
class GenderReportPdf < Prawn::Document
def initialize(mens, womans)
super(top_margin: 70)
add_title
@mens = mens
@womans = womans
add_count
require 'spec_helper'
include Warden::Test::Helpers
describe "UserDashboards" do
before(:each) do
@user = Factory.create(:user)
login_as @user, :scope => :user
end
@lucasallan
lucasallan / syn_spoo_flood.pl
Created November 2, 2013 22:54
Simple perl script developed as proof of concept in the Security System class in my Bachelor degree.
#!/usr/bin/perl
# synSpoofFlood
# Author: Lucas Allan
#
# Based on Simple SYN Flooder by iphelix
# Requires perl, Net::RawIP module, and root privileges
#
# www.lucasallan.com
#
@lucasallan
lucasallan / first_list_books_2014
Last active January 2, 2016 21:39
Books list for Jan 1th to April 30th
- Ruby under a microcospe
- Programming Elixir
- Deploying JRuby (Done)
- The Joy of Clojure
@lucasallan
lucasallan / actors.rb
Created January 17, 2014 03:04
Using DRb to allow concurrent-ruby Actors to be distributed across systems.
class BryanCranston < Concurrent::Actor
end
class Bryan < Concurrent::Actor
end
# EXAMPLE 01
### server
server = Concurrent::ActorServer.new([BryanCranston.new, Bryan.new], 'localhost', 8888)
server.run!
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