Skip to content

Instantly share code, notes, and snippets.

Avatar
🇰🇷

CHANN channprj

🇰🇷
View GitHub Profile
@mnot
mnot / urlnorm.py
Created Dec 1, 2009
urlnorm.py: URL normalisation
View urlnorm.py
#!/usr/bin/env python
"""
urlnorm.py - URL normalisation routines
urlnorm normalises a URL by;
* lowercasing the scheme and hostname
* taking out default port if present (e.g., http://www.foo.com:80/)
* collapsing the path (./, ../, etc)
* removing the last character in the hostname if it is '.'
@mhulse
mhulse / models.py
Created Jun 17, 2011
Django basic/simple category/sub-category model.
View models.py
# ...
class Category(Base):
slug = models.SlugField(_(u'slug'), max_length=100, unique=True)
title = models.CharField(_(u'title'), max_length=250)
parent = models.ForeignKey('self', blank=True, null=True, related_name='child')
class Meta:
verbose_name_plural = 'Categories'
@kylebarrow
kylebarrow / example.html
Created Jun 23, 2011
Prevent links in standalone web apps opening Mobile Safari
View example.html
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
@irae
irae / _Stay_standalone.md
Last active Sep 17, 2021 — forked from kylebarrow/example.html
Stay Standalone: Prevent links in standalone web apps opening Mobile Safari
View _Stay_standalone.md

#Stay Standalone

A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.

@timmyomahony
timmyomahony / nginx.conf
Created Jun 26, 2011
Python, UWSGI, Supervisor & Nginx
View nginx.conf
upstream uwsgi {
ip_hash;
server 127.0.0.1:40000;
}
server {
listen 80;
server_name www.domain.com;
root /sites/mysite/;
access_log /sites/mysite/log/nginx/access.log;
@starenka
starenka / .gitignore
Created Sep 18, 2011
fabfile to deploy flask app to nginx/supervisor/uwsgi stack
View .gitignore
.idea/*
*.pyc
@eigenein
eigenein / pyDes.py
Created Oct 10, 2011
A pure python implementation of the DES and TRIPLE DES encryption algorithms
View pyDes.py
#############################################################################
# Documentation #
#############################################################################
# Author: Todd Whiteman
# Date: 16th March, 2009
# Verion: 2.0.0
# License: Public Domain - free to do as you wish
# Homepage: http://twhiteman.netfirms.com/des.html
#
@ibeex
ibeex / auth.py
Created Oct 14, 2011
Python LDAP (ActiveDirectory) authentication
View auth.py
import ldap
def check_credentials(username, password):
"""Verifies credentials for username and password.
Returns None on success or a string describing the error on failure
# Adapt to your needs
"""
LDAP_SERVER = 'ldap://xxx'
# fully qualified AD user name
LDAP_USERNAME = '%s@xxx.xx' % username
@jeetsukumaran
jeetsukumaran / rijndael.py
Created Oct 17, 2011
Pure-Python implementation of Rijndael (AES) cipher.
View rijndael.py
#############################################################################
# Original code ported from the Java reference code by Bram Cohen, April 2001,
# with the following statement:
#
# this code is public domain, unless someone makes
# an intellectual property claim against the reference
# code, in which case it can be made public domain by
# deleting all the comments and renaming all the variables
#
class Rijndael(object):
@Gunio
Gunio / Parsing JSON in python
Created Oct 18, 2011
Parsing JSON in python
View Parsing JSON in python
import requests
import simplejson
r = requests.get('https://github.com/timeline.json')
c = r.content
j = simplejson.loads(c)
for item in j:
print item['repository']['name']