Skip to content

Instantly share code, notes, and snippets.

View seocam's full-sized avatar

Sergio Oliveira seocam

  • Uber
  • Brazil
  • 06:11 (UTC -03:00)
View GitHub Profile
@seocam
seocam / barcode_template.html
Created August 18, 2012 21:36
Generate a interleaved 2 of 5 barcode in pure HTML and CSS (tested only in Firefox and Chrome)
<html>
<head>
<style>
#barcode {height: 60px;}
#barcode span {margin: 0;padding-bottom: 34px;height: 16px;}
.n {padding-right: 1px;}
.w {padding-right: 3px;}
.n, .w {background-color: #000;}
.s {background-color: #fff;}
</style>
@seocam
seocam / gist:3455535
Created August 24, 2012 20:57
Testing

Using a custom template

If you need to use a template different from the Django's default (for example to generate a Google News sitemap) you can extend the you Sitemap class and setting a sitemap_template attribute. For Example:

from django.contrib.sitemaps import GenericSitemap

class GoogleNewsSitemap(GenericSitemap):

sitemap_template = 'sitemap_googlenews.xml'

"""
BOSH Client
-----------
Quite simple BOSH client used by Django-XMPPAuth
For now, it only supports the DIGEST-MD5 authentication method.
"""
import httplib, sys, random
upstream django_app {
server 127.0.0.1:8000;
}
@seocam
seocam / gist:4f25253d8951c3583cdd
Created August 6, 2014 01:06
Scripts para criar/modificar usuários
#! /bin/sh
USER=$1; GROUP=$2; HOME=$3
if [ 0 -ne $(getent passwd $USER > /dev/null)$? ]
then useradd $USER --home $HOME --gid $GROUP -n; fi
OLDGID=`getent passwd $USER | awk -F: '{print $4}'`
OLDGROUP=`getent group $OLDGID | awk -F: '{print $1}'`
OLDHOME=`getent passwd $USER | awk -F: '{print $6}'`
if [ "$GROUP" != "$OLDGID" ] && [ "$GROUP" != "$OLDGROUP" ]
then usermod --gid $GROUP $USER; fi
if [ "$HOME" != "$OLDHOME" ]
@seocam
seocam / cifras.py
Created October 4, 2014 00:11
Cifras em Python
# -*- coding: utf-8 -*-
# Header ^^^ por causa de acento no código fonte
import string
from random import shuffle
@seocam
seocam / gist:c35a59b4112ed246a73e
Created October 28, 2014 17:17
Tor Relay Nodes by Country [2014-10-28]
1673 us
1332 de
568 fr
445 nl
305 ru
287 gb
220 se
203 ca
120 ch
113 cz
@seocam
seocam / headermap.py
Last active August 29, 2015 14:16 — forked from Lukasa/headermap.py
import collections
class HTTPHeaderMap(collections.MutableMapping):
"""
A structure that contains HTTP headers.
HTTP headers are a curious beast. At the surface level they look roughly
like a name-value set, but in practice they have many variations that
make them tricky:
@seocam
seocam / colab_paste.rst
Last active August 29, 2015 14:16 — forked from anonymous/colab_paste

Backup e Restauração Colab/Gitlab

Estes passos assumem que o Colab e o Gitlab já estão instalados e funcionando com seus bancos default (sem dados).

Backup

Todos os passos a seguir devem ser executados no beta.softwarepublico.gov.br:

# encoding: utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
import operator
import warnings
from django.utils import six
from haystack import connection_router, connections