Skip to content

Instantly share code, notes, and snippets.

View seocam's full-sized avatar

Sergio Oliveira seocam

  • Uber
  • Brazil
  • 05:55 (UTC -03:00)
View GitHub Profile
@seocam
seocam / setup.js
Created March 13, 2017 21:50
Failing tests when React Warnings are raised
const ERROR_MESSAGES = [
'Warning: React.createElement',
'Failed propType:'
];
/* Turn console.error messages into failing tests */
console.error = (logger => (...options) => {
const [message, ..._rest] = options;
ERROR_MESSAGES.forEach(error_message => {
<svg xmlns=”http://www.w3.org/2000/svg" pointer-events=”none” width=”{width}”
height=”{height}” style=”{style}”>
<text text-anchor=”middle” y=”50%” x=”50%” dy=”0.35em”
pointer-events=”auto” fill=”#ffffff” font-family=”{font-family}”
style=”{text-style}”>{text}</text>
</svg>
import avinit
avinit.get_svg_avatar('Douglas Adams')
# Returns:
# '<svg xmlns="http://www.w3.org/2000/svg" pointer-events="none" width="46" height="46" style="width: 46px; border-radius: 0px; -moz-border-radius: 0px; background-color: #34495e; height: 46px"> <text text-anchor="middle" y="50%" x="50%" dy="0.35em" pointer-events="auto" fill="#ffffff" font-family="HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif" style="font-size: 20px; font-weight: 400">DA</text> </svg>'
avinit.get_avatar_data_url('Douglas Adams')
# Returns:
# 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHBvaW50ZXItZXZlbnRzPSJub25lIiB3aWR0aD0iNDYiIGhlaWdodD0iNDYiIHN0eWxlPSJ3aWR0aDogNDZweDsgYm9yZGVyLXJhZGl1czogMHB4OyAtbW96LWJvcmRlci1yYWRpdXM6IDBweDsgYmFja2dyb3VuZC1jb2xvcjogIzM0NDk1ZTsgaGVpZ2h0OiA0NnB4Ij4gPHRleHQgdGV4dC1hbmNob3I9Im1pZGRsZSIgeT0iNTAlIiB4PSI1MCUiIGR5PSIwLjM1ZW0iIHBvaW50ZXItZXZlbnRzPSJhdXRvIiBmaWxsPSIjZmZmZmZmIiBmb250LWZhbWlseT0iSGVsdmV0aWNhTmV1ZS1M
#!/bin/bash
REPOS="repo1 repo2 repo3"
BASE_DIR="/Users/user/repo_home" # Where you repos are
OUTPUT_FILE="/Users/user/Documents/git-stats.html"
for repo in $REPOS; do
cd "$BASE_DIR/$repo"
echo "Updating repo $repo"
git fetch
# 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
@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:

@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 / 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 / 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: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" ]