Skip to content

Instantly share code, notes, and snippets.

View tinnet's full-sized avatar
🐼

Martin Contento tinnet

🐼
View GitHub Profile
from __future__ import print_function
import argparse
import csv
import sys
_EPILOG = """
"""
if __name__ == '__main__':
def wrap_list_in_result_dict(entities, page=1, total_pages=1, num_results=None):
return dict(
entities=entities,
page=page,
total_pages=total_pages,
num_results=num_results or len(entities))
# this is the entire list
print wrap_list_in_result_dict([1,2,3,4])
@tinnet
tinnet / app.yaml
Last active December 13, 2015 17:59
application: GAE_APP_IDENTIFIER
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: .*
script: main.app
<?php
phpinfo();
-- query existing row with int (gets worse with amount of rows)
CREATE TABLE `identity` (
`provider_name` varchar(256) NOT NULL,
`provider_user_id` varchar(256) NOT NULL,
`uuid` char(32) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`provider_name`,`provider_user_id`),
KEY `uuid` (`uuid`),
CONSTRAINT `identity_ibfk_1` FOREIGN KEY (`uuid`) REFERENCES `global_user` (`uuid`)
# download GeoIPCity.dat from http://dev.maxmind.com/geoip/geolite
# pip install pygeoip
# get ip list eg. from sshguard logs:
# zgrep Blocking /var/log/auth.log* | cut -d ' ' -f 7 | cut -d ':' -f 1 | sort -u > ips.txt
# python geoiplookup.py ips.txt (or directly cat)
import fileinput
import sys
import pygeoip
cursor = db.connection.cursor()
# borrowed from http://goo.gl/BWxNj
seq_fix_sql = """SELECT setval('django_messages_message_id_seq', coalesce((select max(id)+1 from django_messages_message), 1), true)"""
cursor.execute(seq_fix_sql)
@tinnet
tinnet / Vagrantfile
Created June 19, 2013 22:16
'basic' Vagrantfile
# -*- mode: ruby -*-
# # vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.ssh.forward_agent = true
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", 512]
@tinnet
tinnet / hosts
Last active August 29, 2015 13:56 — forked from michaelcontento/gasmask.txt
distraction blocking with https://github.com/2ndalpha/gasmask
127.0.0.1 bitcointalk.org
127.0.0.1 plus.google.com
127.0.0.1 thechive.com
127.0.0.1 www.9gag.com 9gag.com
127.0.0.1 www.amazon.de amazon.de
127.0.0.1 www.bitcoinity.org bitcoinity.org
127.0.0.1 www.eatliver.com
127.0.0.1 www.facebook.com facebook.com
127.0.0.1 www.geizhals.at geizhals.at
127.0.0.1 www.geizhals.de geizhals.de
### Keybase proof
I hereby claim:
* I am tinnet on github.
* I am tinnet (https://keybase.io/tinnet) on keybase.
* I have a public key whose fingerprint is 4171 0F75 4E9F 2AA6 8AEE FAF8 8B4F 1E7F BAF4 AB2F
To claim this, I am signing this object: