Skip to content

Instantly share code, notes, and snippets.

class MessagesHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(self):
db = self.settings['db']
self._response_buffer = []
db.messages.find().sort([('_id', -1)]).each(self._found_callback)
def _found_callback(self, message, error):
if error:
raise tornado.web.HTTPError(500, error)
class MessagesHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@tornado.gen.engine
def get(self):
db = self.settings['db']
rb = []
cursor = db.messages.find().sort([('_id', -1)])
while (yield cursor.fetch_next)
message = cursor.next_object()
rb.append({
class MessagesHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@tornado.gen.engine
def get(self):
db = self.settings['db']
rb = []
cursor = db.messages.find().sort([('_id', -1)])
messages = yield motor.Op(cursor.to_list, length=50)
while messages:
[rb.append({'id': m['_id'], 'msg': m['msg']}) for m in messages]
class MessagesHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
db = self.settings['db']
rb = []
cursor = db.messages.find().sort([('_id', -1)])
messages = yield cursor.to_list(length=50)
while messages:
[rb.append({'id': m['_id'], 'msg': m['msg']}) for m in messages]
messages = yield cursor.to_list(length=50)
require 'Unirest'
require 'json'
puts "testing"
begin
url = "http://stage.maasive.net/v2.4/5379f153b2c4271b06d88351/plays/"
parameters = {
:user_score=>5,
:alien_score=>1,
@ntrepid8
ntrepid8 / md2html.js
Last active December 23, 2015 00:18
A function to pull markdown documents down (from Dropbox in my case) and convert them to HTML and return the HTML text. It requires the excellent markdown.converter.js (https://code.google.com/p/pagedown/) library.
/**
* Created with PyCharm.
* User: ntrepid8
* Date: 9/9/13
* Time: 4:55 PM
*/
// Markdown Converter get it at https://code.google.com/p/pagedown/
var converter = new Markdown.Converter();
@ntrepid8
ntrepid8 / gist:6552311
Created September 13, 2013 15:37
Use this to make interaction with your MaaSive.net API easier.
/**
* MaaSive.net JavaScript SDK.
* User: ntrepid8
* Date: 8/17/13
* Time: 8:03 PM
*/
var maasive = (function(){
var m = {
host: null
@ntrepid8
ntrepid8 / md2html-helper.js
Created October 6, 2013 02:01
A Handlebars Helper for use with my md2hhtml.js gist. This one is written for Ember.js for use in a template like this: {{md2html id="your-id" url="url-to-a-markdown-document"}}
Em.Handlebars.helper('md2html', function(options){
console.log(options.hash.url);
var loading = '<i class="icon-refresh icon-spin icon-4x"></i> Loading...';
var containerHtml = '<div id="'+options.hash.id+'">'+loading+'</div>';
var errorHtml = '<i class="icon-frown icon-4x"></i> There has been an error...';
md2html.get(options.hash.url, function(html){
$('#'+options.hash.id).html(html);
}, function(){
$('#'+options.hash.id).html(errorHtml);
});
@ntrepid8
ntrepid8 / .screenrc-main-example
Created July 13, 2016 16:22 — forked from ChrisWills/.screenrc-main-example
A nice default screenrc
# GNU Screen - main configuration file
# All other .screenrc files will source this file to inherit settings.
# Author: Christian Wills - cwills.sys@gmail.com
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
@ntrepid8
ntrepid8 / bash-prompt.md
Created July 25, 2016 14:05
A bash prompt example

To get a bash promp that looks like this:

bash-prompt-example

Use this code in your .bashrc file:

source /etc/bash_completion.d/git-prompt
if [ "$color_prompt" = yes ]; then
 #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '