This file contains 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 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 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 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 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 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
String.prototype.format = function() { | |
var formatted = this; | |
for (var i = 0; i < arguments.length; i++) { | |
var regexp = new RegExp('\\{'+i+'\\}', 'gi'); | |
formatted = formatted.replace(regexp, arguments[i]); | |
} | |
return formatted; | |
}; | |
var txt = "Nome: {0} | Sobrenome: {1}".format("Diego", "Garcia"); |
This file contains 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 -*- | |
from flask import Flask, redirect, abort, jsonify, url_for, request | |
import string | |
import random | |
app = Flask("encolinks") | |
links = {} |
This file contains 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/python | |
__author__ = 'Diego Garcia' | |
from threading import Thread | |
from time import sleep | |
from random import randint | |
class MinhaThread(Thread): | |
def __init__(self, identificador, vezes): |
This file contains 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
net use \\%Machine% [PasswordOfRemoteMachine] /USER:[UserOfRemoteMachine] | |
sc \\%Machine% %Action% %Service% |
This file contains 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
#based on: https://github.com/sixohsix/twitter | |
__author__ = 'Diego Garcia' | |
from twitter import * | |
from my_twitter_tokens import * # TOKENS CONSTS | |
t = Twitter( | |
auth=OAuth(ACCESS_TOKEN, | |
ACCESS_TOKEN_SECRET, | |
API_KEY, |