Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# encoding: utf-8
require 'amqp'
require 'json'
require 'securerandom'
# Example HTTP response, for AMPQ we need to use single even in outgoing
# {
# "events":[{
@JakubOboza
JakubOboza / gist:6909175
Created October 9, 2013 21:56
scala AMQP
val params = new ConnectionParameters
params.setUsername("guest")
params.setPassword("guest")
params.setVirtualHost("/")
params.setRequestedHeartbeat(0)
val factory = new ConnectionFactory(params)
// Create a new instance of the string sender.
// This sender will send messages to the "mult" exchange with a
// routing key of "routeroute"
val amqp = new StringAMQPSender(
package main
import (
"flag"
"html/template"
"log"
"net/http"
)
var addr = flag.String("addr", ":1718", "http service address") // Q=17, R=18
package main
import(
"fmt"
"github.com/hoisie/mustache"
"bytes"
)
func main(){
{-# LANGUAGE OverloadedStrings #-}
import Database.Redis
import Network.CGI
import qualified Data.ByteString.Char8 as BL
setKey conn key value = do
runRedis conn $ do
set key value
@JakubOboza
JakubOboza / gist:5822497
Created June 20, 2013 13:08
git blame screwup
{
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
"font_size": 12.0,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
}
module ThreeUkEncryption
include OpenSSL::Cipher
extend self
@JakubOboza
JakubOboza / gist:5780560
Created June 14, 2013 09:14
List Comperhansions
-- ghci example
let infinite_list = [1..n]
take 50 infinite_list
-- works fine and its great :)
let triangles = [(a,b,c) | a <-[1..], b<-[1..], c<-[1..], c^2 == a^2 + b^2]
take 50 triangles
defmodule Hello do
def world do
IO.puts "Hello World"
end
end

replays last FIN-ACK in order to check if the other side correctly implements TIMED-WAIT. other side should be first to close the connection. with http this can be done in curl by forcing http/1.0 mode.

curl -0 -d 'lolol=lololol' http://TARGET/wtwtwt
tcpdump -S 'tcp port 80' -l | ./replayer.rb TARGET 80 YOUR_HOST_AS_APPEARS_IN_TCPDUMP

Example of it working and showing the other side correctly handling TIMED-WAIT:

root@midway:~# tcpdump -S 'tcp port 80' -l | ./replayer.rb 173.194.41.67 80 ip-10-250-157-181.eu-west-1.compute.internal
OMG IM RUNNING

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode