Skip to content

Instantly share code, notes, and snippets.

@dusual
dusual / future
Last active August 29, 2015 14:07 — forked from meson10/future
function abc() {
var deferred = $.Deferred();
(function() {
var a = 1;
deferred.resolve(a);
})();
return deferred.promise();
}
United States
Albania
American Samoa
Armenia
Australia
Austria
Azerbaijan
Belarus
Belgium
Bosnia and Herzegovina
def make_pool(settings, InnerPool):
conn = mongomock.Connection()
db = conn.db["partyPool"]
return db
def mock_get_user(user_id):
from data import user
return user
function buildmessage(params){
var boundary = 'sAxIqse3tPlHqUIUI9ofVlHvtdt3tpaG'
//
// var body = [
// "Content-Type: multipart/form-data;boundary="+boundary ,
// "Content-Length:" +params.content.length,
// "--"+boundary,
// "Content-Disposition: form-data, file=" + params.file,
@dusual
dusual / __init__.py
Created September 20, 2011 14:07
The main file of my new Siesta fork that uses httplib2 and handles different auth methods
# Python Siesta
#
# Copyright (c) 2008 Rafael Xavier de Souza
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
function escapePath(p) {
return encodeURIComponent(p)
.replace(/%2F/g, '/')
.replace(/\)/g, '%29')
.replace(/\(/g, '%28');
}
// test for jsonp callback functionality
function escapePath(p) {
return encodeURIComponent(p)
.replace(/%2F/g, '/')
.replace(/\)/g, '%29')
.replace(/\(/g, '%28');
}
// test for jsonp callback functionality
{
"_id" : "144466671082296759844952",
"is_listed" : true,
"is_catalog" : false,
"subtitle" : null,
"marketing_facilitator" : 1,
"promotional_video_asset_id" : null,
"show_outline" : true,
"topics" : [ ],
"plan_type" : "retail",
@dusual
dusual / rsvp.py
Last active December 15, 2015 19:09
#Email Decode imports
from email import Encoders
import random
import imaplib,rfc822, re, StringIO, time, os, sys
from time import strftime
from datetime import datetime, timedelta
import email, email.Errors, email.Header, email.Message, email.Utils
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
@dusual
dusual / schema.py
Created September 18, 2013 11:56
A basic pony test
from datetime import datetime
from datetime import timedelta
from pony.orm import *
db = Database("sqlite", "data.sqlite", create_db=True)
class User(db.Entity):
#Answer 3 : Correcting User db
domain = Optional('Domain')