This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
phpinfo(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: GAE_APP_IDENTIFIER | |
version: 1 | |
runtime: python27 | |
api_version: 1 | |
threadsafe: yes | |
handlers: | |
- url: .* | |
script: main.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import argparse | |
import csv | |
import sys | |
_EPILOG = """ | |
""" | |
if __name__ == '__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import argparse | |
import csv | |
import requests | |
import sys | |
_EPILOG = """ | |
Script takes a list of .csv files, tries to guess their format (seperator), | |
then checks for a field called 'URL', tries to fetch that url and prints |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flask | |
import flask.views | |
import logging | |
logging.basicConfig(level=logging.DEBUG) | |
class MyFlaskExt(object): | |
def __init__(self, app=None): | |
if app is not None: | |
self.init_app(app) |