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
'use strict'; | |
const path = require('path') | |
const redirect = new_url => { | |
return { | |
status: '301', | |
statusDescription: 'Moved Permanently', | |
headers: { | |
location: [{ |
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
function getType (value) { | |
let type = typeof value; | |
if (type === 'object') { | |
return value ? Object.prototype.toString.call(value).slice(8, -1) : 'null'; | |
} | |
return type; | |
} | |
[NaN, 0, 1, Infinity, // numbers | |
null, undefined, false, 'str', // other primitives |
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 sys | |
import re | |
import dns.resolver # Requires dnspython | |
email_host_regex = re.compile(".*@(.*)$") | |
gmail_servers_regex = re.compile("(.google.com.|.googlemail.com.)$", re.IGNORECASE) | |
def is_gmail(email): | |
""" Returns True if the supplied Email address is a @gmail.com Email or is a Google Apps for your domain - hosted Gmail address | |
Checks are performed by checking the DNS MX records """ |
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 | |
import MySQLdb | |
host = "localhost" | |
passwd = "" | |
user = "root" | |
dbname = "mydbname" | |
db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=dbname) | |
cursor = db.cursor() |
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 sandbox import models | |
from tastypie import fields | |
from apibase.resources import CamayakModelResource | |
from django.conf.urls.defaults import url | |
class ModelResource(CamayakModelResource): | |
def override_urls(self): | |
urls = [] | |
for name, field in self.fields.items(): |