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 os | |
>>> programa = r'C:\Program Files (x86)\mongoDB\bin\mongod.exe' | |
>>> parametros = r'--logpath "C:\Foo\Bar\Base\install.log" --dbpath "C:\Foo\Bar\Base\data\db" --port 1124' | |
>>> os.path.dirname(programa) | |
'C:\\Program Files (x86)\\mongoDB\\bin' | |
>>> os.path.basename(programa) | |
'mongod.exe' | |
>>> os.spawnl(os.P_WAIT, os.path.dirname(programa), os.path.basename(programa), parametros) | |
Traceback (most recent call last): | |
File "<pyshell#20>", line 1, in <module> |
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 os | |
import platform | |
import ctypes | |
def pid_ativo(pid): | |
if platform.system() == "Windows": | |
return _pid_ativo_windows(pid) | |
else: | |
return _pid_ativo_unix(pid) |
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
# !/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
__author__ = 'Diego Garcia' | |
import tornado.ioloop | |
import tornado.web | |
from bson.json_util import dumps | |
from pymongo import Connection | |
from bson.objectid import ObjectId | |
from gridfs import GridFS |
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 delete_module(modname, paranoid=None): | |
from sys import modules | |
try: | |
thismod = modules[modname] | |
except KeyError: | |
raise ValueError(modname) | |
these_symbols = dir(thismod) | |
if paranoid: | |
try: | |
paranoid[:] # sequence support |
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 pymongo import MongoClient | |
>>> c = MongoClient('localhost', 27017) | |
>>> c.database_names() |
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 redis | |
>>> import pickle | |
>>> rserver = redis.Redis(host='localhost', port=6379) | |
>>> rserver.set('foo', 'bar') | |
True | |
>>> rserver.get('foo') | |
b'bar' | |
>>> rserver.set('foo', pickle.dumps({'foo': 'bar'})) | |
True | |
>>> pickle.loads(rserver.get('foo')) |
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
# !/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
__author__ = 'Diego Garcia' | |
import tornado.web | |
import tornado.ioloop | |
import oauth2.tokengenerator | |
import oauth2.grant | |
import oauth2.store.redisdb | |
import oauth2.store.mongodb |
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 logging | |
import json | |
import urllib3 | |
import sys | |
class Liker(): | |
__URL_API = 'https://graph.facebook.com/v2.2' | |
__URL_ME = '/me?fields=id' | |
__URL_HOME = '/me/home?fields=from,likes' |
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 Git script for PS1 | |
source /etc/bash_completion.d/git-prompt | |
# Color definition for PS1 | |
txtred='\e[0;31m' | |
txtwhite='\e[0;37m' | |
txtyellow='\e[0;33m' | |
# Defnite PS1 in this format: | |
# user:dir (git branch)$: |
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
# -*- coding: utf-8 -*- | |
from bottle import route, run | |
@route('/') | |
def index(): | |
return '<h1>Hello World/h1>' | |
run(host='localhost', port=8000) |