Skip to content

Instantly share code, notes, and snippets.

@fabrizioc1
fabrizioc1 / tcpdump_memcached.sh
Created February 26, 2013 06:30
Using TCPDUMP to capture Memcached packets
sudo tcpdump -w /tmp/memcached.pcap -i any -A -vv 'port 11211'
@fabrizioc1
fabrizioc1 / akamai_debug_headers.txt
Last active May 24, 2023 08:23
Akamai debug headers
Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-nonces, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no
@fabrizioc1
fabrizioc1 / sanitize.rb
Created October 6, 2011 05:53
Sanitizing UTF8 or ISO8859-1 strings in Ruby 1.8.7
require 'cgi'
require 'active_support/all'
WHITELIST_CHAR_FRENCH_UTF8 =
["\xC3\x80", "\xC3\x84", "\xC3\x88", "\xC3\x89", "\xC3\x8A", "\xC3\x8B", "\xC3\x8E", "\xC3\x8F", "\xC3\x94", "\xC3\x99", "\xC3\x9B",
"\xC3\x9C", "\xC3\x87", "\xC3\xA0", "\xC3\xA2", "\xC3\xA4", "\xC3\xA8", "\xC3\xA9", "\xC3\xAA", "\xC3\xAB", "\xC3\xAE", "\xC3\xAF",
"\xC3\xB4", "\xC3\xB9", "\xC3\xBB", "\xC3\xBC", "\xC3\xBF", "\xC3\xA7"].join
WHITELIST_CHAR_FRENCH_ISO8859_1 =
"\300\304\310\311\312\313\316\317\324\331\333\334\307\340\342\344\350\351\352\353\356\357\364\371\373\374\377\347"+
@fabrizioc1
fabrizioc1 / install-sqlite.sh
Created July 14, 2011 18:34
Installing sqlite3 in CentOS for use with ruby-sqlite3
# The YUM package is too old for use with ruby-sqlite3, use the autoconf package from www.sqlite.org
cd /opt
wget http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz
tar xvzf sqlite-autoconf-3070701.tar.gz
ln -s /opt/sqlite-autoconf-3070701 /opt/sqlite3
cd /opt/sqlite3
./configure --prefix=/opt/sqlite3
make
make install
# Shared library will be installed in /usr/local/lib.
@fabrizioc1
fabrizioc1 / get_top_n_elements.rb
Created June 19, 2012 18:14
Get top n elements from ruby array of hash values
# I have an array where each element is a hash containing a few values and a count.
result = [
{"count" => 3,"name" => "user1"},
{"count" => 10,"name" => "user2"},
{"count" => 10, "user3"},
{"count" => 2, "user4"}
]
# I can sort the array by count as follows:
@fabrizioc1
fabrizioc1 / http-proxy.go
Last active October 27, 2020 12:32
Http proxy server in Go
package main
import (
"fmt"
"io"
"log"
"net/http"
)
type HttpConnection struct {
@fabrizioc1
fabrizioc1 / calico.yaml
Last active May 23, 2020 11:50
kubernetes calico network config
# Calico Version v3.4.4
# https://docs.projectcalico.org/v3.4/releases#v3.4.4
# This manifest includes the following component versions:
# calico/node:v3.4.4
# calico/cni:v3.4.4
# calico/kube-controllers:v3.4.4
# This ConfigMap is used to configure a self-hosted Calico installation.
kind: ConfigMap
apiVersion: v1
@fabrizioc1
fabrizioc1 / n_armed_bandit.py
Created June 3, 2019 06:34
Reinforcement Learning: N-Armed Bandit
from __future__ import division
import random
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
# epsilon values
EPSILON_VALUES = [0.0, 0.01, 0.1]
@fabrizioc1
fabrizioc1 / sql_profiler_wcde7.md
Created September 18, 2012 18:58
Installing RAD SQL Profiler in WebSphere Commerce Developer 7
@fabrizioc1
fabrizioc1 / Stemmer.py
Created February 12, 2019 00:01
Example of scala Spark transformer with python wrapper
from pyspark import since, keyword_only
from pyspark.ml.param.shared import HasInputCol, HasOutputCol, Param
from pyspark.ml.util import JavaMLReadable, JavaMLWritable
from pyspark.ml.wrapper import JavaTransformer
class Stemmer(JavaTransformer, HasInputCol, HasOutputCol, JavaMLReadable, JavaMLWritable):
@keyword_only
def __init__(self, inputCol=None, outputCol=None):
super(Stemmer, self).__init__()