- Add into
/etc/ssh/sshd_config
on remote machine (remote.example.com):
GatewayPorts yes
- Restart sshd:
/etc/init.d/sshd restart
""" | |
usage: | |
Event.objects.create(type=Event.TYPES.CHAT_ADDED) | |
""" | |
def enum(*sequential, **named): | |
enums = dict(zip(sequential, range(len(sequential))), **named) | |
reverse = dict((value, key) for key, value in enums.iteritems()) | |
enums['reverse_mapping'] = reverse |
# | |
# 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 {}{ |
package main | |
import ( | |
"log" | |
"os" | |
"github.com/FZambia/martini" | |
) | |
func main() { |
# 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', |
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 = ( |
# 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 | |
/etc/ssh/sshd_config
on remote machine (remote.example.com):GatewayPorts yes
/etc/init.d/sshd restart
# 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 |
import logging | |
import requests | |
from PIL import Image | |
import requests.exceptions | |
from StringIO import StringIO | |
from django.core.files.base import ContentFile | |
from django.core.files.storage import FileSystemStorage | |
logger = logging.getLogger('uploads') |