Skip to content

Instantly share code, notes, and snippets.

@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 / ddns_provider.conf
Created September 21, 2013 19:07
This is the /etc.defaults/ddns_provider.conf file for Synology DiskStation NAS devices with a provider added for DNSMadeEasy.com DynamicDNS service.
# Input:
# 1. DynDNS style request:
# Input:
# Input:
# 1. DynDNS style request:
# modulepath = DynDNS
# queryurl = [Update URL]?[Query Parameters]
#
# 2. Self-defined module:
# modulepath = /sbin/xxxddns
@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);
});
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)
@ntrepid8
ntrepid8 / fit_bit_oauth.py
Created March 24, 2014 15:54
FitBit OAuth
import requests
import time
import random
from hashlib import sha1
import hmac
import binascii
from getpass import getpass
from urllib import urlencode, quote, quote_plus
from urlparse import parse_qs
from pprint import pprint, pformat
require 'Unirest'
require 'json'
puts "testing"
begin
url = "http://stage.maasive.net/v2.4/5379f153b2c4271b06d88351/plays/"
parameters = {
:user_score=>5,
:alien_score=>1,