Skip to content

Instantly share code, notes, and snippets.

View alejandrobernardis's full-sized avatar
🐻

Alejandro M. BERNARDIS alejandrobernardis

🐻
View GitHub Profile
# .bashrc
export LC_CTYPE="en_US.UTF-8"
@alejandrobernardis
alejandrobernardis / pymongo.py
Last active December 21, 2015 09:29
Simple!
_database = dict(
database=options.database_name,
replicaset=options.database_rset,
hosts_or_uri=options.database_huri,
host=options.database_host,
port=options.database_port,
max_pool_size=options.database_conn,
auto_start_request=options.database_areq,
use_greenlets=options.database_ugls,
)
@alejandrobernardis
alejandrobernardis / main.py
Last active December 22, 2015 05:39
Tornado Main App.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2013 Asumi Kamikaze Inc.
# Copyright (c) 2013 The Octopus Apps Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
# Author: Alejandro M. Bernardis
# Email: alejandro.bernardis at gmail.com
# Created: 21/06/2013 09:01
import os
@alejandrobernardis
alejandrobernardis / demo.py
Created September 4, 2013 21:17
Regex UUID
re_uid = re.compile(r'(?i)(?<![a-z0-9])[0-f]{32}(?![a-z0-9])')
re_sid = re.compile(r'(?i)(?<![a-z0-9])[0-f]{8}(?:-[0-f]{4}){3}-[0-f]{12}(?![a-z0-9])')
@alejandrobernardis
alejandrobernardis / mongo.sh
Created October 17, 2013 21:45
Firewall Mongo
SETS=0
MAX_SETS=4
IP_ADDRESS="192.168.0.0"
while [ ${SETS} -lt ${MAX_SETS} ]; do
${iptables} -A INPUT -s ${IP_ADDRESS} -p tcp --destination-port 2700${SETS} -m state --state NEW,ESTABLISHED -j ACCEPT
${iptables} -A OUTPUT -d ${IP_ADDRESS} -p tcp --source-port 2700${SETS} -m state --state ESTABLISHED -j ACCEPT
let SETS+=1;
done
@alejandrobernardis
alejandrobernardis / ssh.sh
Created October 23, 2013 14:53
SSH // With Out Timeout
TCPKeepAlive yes
ClientAliveInterval 30
ClientAliveCountMax 99999
def db(self, database=None):
_ref = None
_settings = self.settings.get('database')
if _settings:
if database:
_databases = _settings.get('databases')
if database not in _databases:
raise KeyError('Database "%s" is not supported.' % database)
database = _databases.get(database)
else:
# Copyright (c) 2010, Philip Plante of EndlessPaths.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@alejandrobernardis
alejandrobernardis / mongo.js
Created January 4, 2014 22:01
Create a new collection with the old indexes
var i, c,
co_name, co_new,
co_old, co_old_i,
_db = db.getSiblingDB('logs'),
_colls = ['activity.games', 'activity.session', 'activity.social', 'activity.store'];
for (i in _colls){
co_name = _colls[i];
co_old = _db[co_name];
co_old_i = co_old.getIndexes();
#!/bin/sh
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT