Skip to content

Instantly share code, notes, and snippets.

Andrea de Marco z4r

Block or report user

Report or block z4r

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile


  • 2 Flesh Golems (Block, Mighty Blow, Guard, Break Tackle)
  • 2 Wights
  • 1 Werewolf
  • 1 Ghoul
  • 5 Zombies
  • 3 RR -> Werewolf -> Ghoul


View TeamStats.swift
import Foundation
struct TeamStats {
let elements: [TeamStat]
extension TeamStats: Decodable {
enum CodingKeys: String, CodingKey {
case overallteamstandings
z4r / zrangebyscorestore.lua
Last active Oct 30, 2017
View zrangebyscorestore.lua'ZUNIONSTORE', KEYS[1], 1, KEYS[2])
local lbound, ubound = ARGV[1], ARGV[2]
if lbound ~= '-inf' then
lbound = lbound:sub(1, 1) == '(' and lbound:sub(2) or '('..lbound'ZREMRANGEBYSCORE', KEYS[1], '-inf', lbound)
if ubound ~= '+inf' then
ubound = ubound:sub(1, 1) == '(' and ubound:sub(2) or '('..ubound'ZREMRANGEBYSCORE', KEYS[1], ubound, '+inf')
z4r / csrfToken.js
Created Jun 21, 2013
ajax csrf for django
View csrfToken.js
//require jquery.cookie.js
var csrftoken = $.cookie('csrftoken');
function csrfSafeMethod(method) {
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
crossDomain: false,
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type)) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
z4r /
Last active Dec 15, 2015
stopwatch core
from time import time
from django.conf import settings
from statsd import Connection, Timer
class StatsDStopWatchMiddleware(object):
def __init__(self):
connection = Connection(
host=getattr(settings, 'STATSD_HOST', None),
port=getattr(settings, 'STATSD_PORT', None)
z4r / palindrome.markdown
Last active Dec 12, 2015
Doctest isn't palindrome
View palindrome.markdown

#Doctest isn't palindrome# A brief introduction about [Test-driven development][1] using [doctest][2] @ [Mobile World Congress 2013][3] in Barcelona.

##Abstract## Talking about Web development, requirements are fickle and ever-changing. The most trivial request could be the straw that breaks the camel's back. [Test-driven development][1] ( TDD ) is the best weapon in our hands; the [doctest][2] is the simplest tool to explore its efficiency. And let's face it, palindromes fascinate everyone.

###Issue != Requirements### Everyday a developer has to face the problem to understand his/her requestors (employers, line managers, collegues). Unfortunately the request isn't usually clear and comprehensive, because sometimes the problem is not clear to those who ask us to solve it. Language barriers can make the problem worse. However, an example is more enlightening than thousand words. And what if we could write these examples in a language more related to us?

z4r /
Created Dec 3, 2012
Cross Middleware
from django import http
from django.conf import settings
XS_SHARING_ALLOWED_HEADERS = getattr(settings, 'XS_SHARING_ALLOWED_HEADERS', ['Content-Type', 'Date', 'Location', 'Server', 'Vary'])
class XsSharing(object):
def process_request(self, request):
z4r / DatePattern.markdown
Last active Oct 11, 2015
TDD and Unittest
View DatePattern.markdown

#TDD and Unittest#

Ispirato al tutorial di Jason Diamond:

  • [Test-Driven Development in Python - Parte 1][1]
  • [Test-Driven Development in Python - Parte 2][2]


z4r /
Created Jul 10, 2012
Testing clients with Flask
from multiprocessing import Process
from flask import Flask
import requests
import unittest2 as unittest
app = Flask(__name__)
z4r /
Created Apr 18, 2012
Cache for urllib2 [Redis, FileSystem]
import hashlib
import StringIO
import httplib
import urllib2
import os
import errno
import time
from threading import RLock
cache_lock = RLock()
You can’t perform that action at this time.