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 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 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 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
# !/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 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 = {} |