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 | |
| ''' | |
| Mocking Httpclient and AsyncHttpclient in Tornado Server | |
| ''' | |
| import unittest | |
| import urllib | |
| import tornado.gen | |
| import tornado.ioloop | |
| import tornado.web |
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 time import sleep | |
| from tornado.httpserver import HTTPServer | |
| from tornado.ioloop import IOLoop | |
| from tornado.web import Application, asynchronous, RequestHandler | |
| from multiprocessing.pool import ThreadPool | |
| _workers = ThreadPool(10) | |
| def run_background(func, callback, args=(), kwds={}): | |
| def _callback(result): |
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
| camera = {} | |
| camera._x = 0 | |
| camera._y = 0 | |
| camera.scaleX = 1 | |
| camera.scaleY = 1 | |
| camera.rotation = 0 | |
| function camera:set() | |
| love.graphics.push() | |
| love.graphics.rotate(-self.rotation) |
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 celery.task import task | |
| from my_app.models import FailedTask | |
| from django.db import models | |
| @task(base=LogErrorsTask) | |
| def some task(): | |
| return result | |
| class LogErrorsTask(Task): | |
| def on_failure(self, exc, task_id, args, kwargs, einfo): |
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 requests_oauthlib import OAuth2Session | |
| from flask import Flask, request, redirect, session, url_for | |
| from flask.json import jsonify | |
| import os | |
| app = Flask(__name__) | |
| # This information is obtained upon registration of a new GitHub | |
| client_id = "<your client key>" |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| /* | |
| * MCrypt API available online: | |
| * http://linux.die.net/man/3/mcrypt | |
| */ | |
| #include <mcrypt.h> |
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 | |
| import sys, os, time, atexit | |
| from signal import SIGTERM | |
| class Daemon: | |
| """ | |
| A generic daemon class. | |
| Usage: subclass the Daemon class and override the run() method |
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 datetime import datetime | |
| from sqlalchemy import Column, Integer, DateTime, ForeignKey | |
| from sqlalchemy.orm import relationship | |
| from sqlalchemy.ext.declarative import declared_attr | |
| from flask_security import current_user | |
| class AuditMixin(object): | |
| created_at = Column(DateTime, default=datetime.now) | |
| updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now) |
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
| # Get Root | |
| sudo su | |
| # Download NMON archive | |
| cd /tmp | |
| wget http://nmon.sourceforge.net/docs/MPG_nmon_for_Linux_14a_binaries.zip | |
| # Install unzip if you don't have | |
| yum install unzip |
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
| # How to echobot with XMPP, BOSH, and Strophe | |
| 1. Setup ejabberd(http://www.ejabberd.im/) server and setup account [email protected] | |
| NOTE: localhost should be enough. If you setup something else, make sure you add it at /etc/hosts like this | |
| #/etc/hosts | |
| 127.0.0.1 localhost.local | |
| NOTE: Also download Psi(http://psi-im.org/), and make sure you can connect to your ejabberd server. | |
| 2. Download strophe(http://code.stanziq.com/strophe/) and place it (eg: /Users/makoto/work/sample/strophejs-1.0) |