Skip to content

Instantly share code, notes, and snippets.

@solso
solso / gist:1901280
Created February 24, 2012 14:36
Example of varnish configuration for 3scale, proxy only
# This is a the VCL configuration file for 3scale's varnish plugin.
#
# Default backend definition. Set this to point to the 3scale's
# backend.
#
# set the beresp.ttl in vcl_fetch to have a default global TTL
# you can define custom TTL via regular expresions
#
## the backend of your API
@solso
solso / sentiment_api.rb
Created May 9, 2012 15:09
Active Docs for the Sentiment API (based on the Swagger specification)
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'sinatra'
require './analyzer.rb'
class SentimentApi < Sinatra::Base
disable :logging
disable :raise_errors
disable :show_exceptions
@solso
solso / autossh.sh
Created July 26, 2012 13:56
Support material for blog post of redis replication
#!/bin/sh
## --- tunnel_to_master_redis
REDIS_MASTER=XYZ
REDIS_SLAVE_PORT=6280
AUTOSSH_POLL=300
AUTOSSH_PORT=20000
AUTOSSH_GATETIME=10
AUTOSSH_LOGFILE=/var/log/autossh/autossh.log
def api_call_account_read(domain, provider_key, account_id)
url = "https://#{domain}/admin/api/accounts/#{account_id}.xml?provider_key=#{provider_key}"
response = RestClient.get url
raise Exception.new("Wrong response code (#{response.code}) in request #{url}") if response.code!=200
document = Nokogiri::XML(response.to_str)
account = Hash.new
account["email"] = document.xpath("//users/user/email").text
@solso
solso / get_query_args_extended.lua
Created April 11, 2013 16:57
extract nested params on query_string
function get_query_args_extended()
args = ngx.req.get_query_args()
for k, v in pairs(args) do
t = {}
for k2 in string.gmatch(k, "%b[]") do
table.insert(t,string.sub(k2,2,string.len(k2)-1))
end
if #t > 0 then
-- it has nested params, needs to be transformed
first = string.sub(k,1,string.find(k,"%[")-1)
--[[
User script that returns the word with highest positive emotional value.
It runs against the SentimentAPI REST AP. See blog entry for the full details.
]]--
return function()
local max_sentiment = 5
local params = ngx.req.get_query_args()
@solso
solso / router.lua
Created June 12, 2013 20:57
router in lua
inspect = require "inspect"
MYROUTES = {
services = {
list = {
leaf = true,
callback = function(params) for k, v in pairs(params) do print("key: " .. k .. " value: " .. v) end end
},
@solso
solso / human-web-overview.md
Last active December 6, 2019 12:36
Human Web Overview

Human Web Overview

Konark Modi, Alex Catarineu, Philipp Claßen and Josep M. Pujol at Cliqz *München, October 2016

[edited on October 2017]*

[edited on September 2019 to fix broken links and add reference to HPN paper]*

We recommend to read the article on Cliqz Tech blog, the content is more up to date there. Not removing this gist for historical reasons. December 2019.

@solso
solso / potential_improvement_bluetooth_contact_tracing.md
Last active April 1, 2020 17:19
Potential Improvements of Bluetooth Contact Tracing

Potential Improvements of Bluetooth Contact Tracing

Motivation

Contact tracing is a key factor for containment on epidemics. Multiple apps are attempting to do this via storing bluetooth proximity contacts on the device. For instance,