Skip to content

Instantly share code, notes, and snippets.

View FZambia's full-sized avatar

Alexander Emelin FZambia

View GitHub Profile
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
// Example
package main;
import (
"jsonhelper"
"fmt"
)
func main(){
jsonValue := []interface {}{
@FZambia
FZambia / main.go
Last active August 29, 2015 13:57
Example how to override Martini logger using Martini fork
package main
import (
"log"
"os"
"github.com/FZambia/martini"
)
func main() {
@FZambia
FZambia / web.py
Created April 18, 2014 13:24
minimal django
# to run:
# python web.py runserver
from django.conf import settings
from django.conf.urls import patterns
from django.http import HttpResponse
if not settings.configured:
settings.configure(
DEBUG=True,
ROOT_URLCONF='web',
@FZambia
FZambia / admin.py
Last active August 29, 2015 14:00
django custom user
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.utils.translation import ugettext_lazy as _
from users.forms import UserChangeForm, UserCreationForm
from users.models import User
class UserAdmin(BaseUserAdmin):
fieldsets = (
@FZambia
FZambia / storage.py
Created April 28, 2014 09:04
webdav storage backend for django
# coding: utf-8
from urlparse import urljoin
from django.conf import settings
from django.core.files.storage import Storage
import logging
from urlparse import urlparse
import requests
# Copyright (c) 2014 Andrey Vlasovskikh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@FZambia
FZambia / spider.py
Last active August 29, 2015 14:04
Web spider to check site URL consistency built on top of Tornado and Toro
# coding: utf-8
import HTMLParser
import time
import urlparse
from datetime import timedelta
from tornado import httpclient, gen, ioloop
import tornado.options
from tornado.options import define, options
from tornado.httpclient import HTTPError
@FZambia
FZambia / curve_fit.py
Last active August 29, 2015 14:04
scipy curve fit ipython notebook
{
"metadata": {
"name": "",
"signature": "sha256:afb8fe099dd7002cd0ade007e898b737fa62de1797f3754a2e9fe7df02a1fded"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@FZambia
FZambia / ipython_reddit.py
Last active August 29, 2015 14:05
reddit ipython nb
{
"metadata": {
"name": "",
"signature": "sha256:a8ab547d1c9943ab14fb4b4be340842f1d13a10781f05859c3649d085fdb4212"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [