Skip to content

Instantly share code, notes, and snippets.

@tazjel
tazjel / gist:997786
Created May 29, 2011 13:38 — forked from mattgorecki/gist:974920
web2py mobile browser detection
# Detect mobile device. Set to mobile view if available
from mobile.sniffer.detect import detect_mobile_browser
if detect_mobile_browser(request.env.http_user_agent):
mobile_view = '%s.mobile.%s' % (request.function, request.extension)
if os.path.exists(os.path.join(request.folder, 'views',request.controller, mobile_view)):
response.view = '%s/%s' % (request.controller, mobile_view)
@tazjel
tazjel / gist:1542217
Created December 31, 2011 00:36 — forked from miceno/gist:1542202
How to create a project in GitHub
Global setup:
Set up git
git config --global user.name "Orestes Sanchez"
git config --global user.email orestes@acm.org
Next steps:
mkdir Drupal7-for-Arxiu-Hist-ric-del-Poblenou
cd Drupal7-for-Arxiu-Hist-ric-del-Poblenou
git init
touch README
@tazjel
tazjel / gist:1542218
Created December 31, 2011 00:36 — forked from miceno/gist:1542202
How to create a project in GitHub
Global setup:
Set up git
git config --global user.name "Orestes Sanchez"
git config --global user.email orestes@acm.org
Next steps:
mkdir Drupal7-for-Arxiu-Hist-ric-del-Poblenou
cd Drupal7-for-Arxiu-Hist-ric-del-Poblenou
git init
touch README
@tazjel
tazjel / new_user.py
Created December 31, 2011 01:12 — forked from rochacbruno/new_user.py
create new web2py users
def new_user(first_name, last_name, email, passw):
users = db(db.auth_user.email==email).select()
if users:
return users[0].id
else:
my_crypt = CRYPT(key=auth.settings.hmac_key)
crypt_pass = my_crypt(passw)[0]
id_user= db.auth_user.insert(
first_name=first_name,
last_name=last_name,
@tazjel
tazjel / users.py
Created January 15, 2012 05:22
Create users Web2py
# coding: utf8
"""
Perseus users module
Author : Alvaro Lizama Molina <me@alvarolizama.net>
Copyright (c) 2011, Alvaro Lizama Molina.
"""
##################################################
### Users
@tazjel
tazjel / new_user.py
Created January 15, 2012 05:54 — forked from rochacbruno/new_user.py
create new web2py users
def new_user(first_name, last_name, email, passw):
users = db(db.auth_user.email==email).select()
if users:
return users[0].id
else:
my_crypt = CRYPT(key=auth.settings.hmac_key)
crypt_pass = my_crypt(passw)[0]
id_user= db.auth_user.insert(
first_name=first_name,
last_name=last_name,
@tazjel
tazjel / ai-class.py
Created January 15, 2012 06:01
Download lecture videos of ai-class (with Subtitles) (Stanford)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Deepak.G.R."
__license__ = 'Public Domain'
"""
usage:
Go to command line and type
python ai-class.py "topic-name"
@tazjel
tazjel / sparks.py
Created January 15, 2012 06:04 — forked from stefanv/sparks.py
Command line sparks in Python
#!/usr/bin/python
# coding=utf-8
# Python version of Zach Holman's "spark"
# https://github.com/holman/spark
# by Stefan van der Walt <stefan@sun.ac.za>
"""
USAGE:
@tazjel
tazjel / bezier_coil.py
Created May 12, 2012 03:31 — forked from pcote/bezier_coil.py
Blender addon that generates coiled bezier curves.
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@tazjel
tazjel / blend.py
Created May 12, 2012 03:32 — forked from kyl191/blend.py
Image Blender
# Take r, g and b channels from separate images. Python randomises the list for extra fun.
from PIL import Image
import os, math, sys, random
os.chdir(sys.argv[1])
fileList = os.listdir(".")
random.shuffle(fileList)
(width, height) = Image.open(fileList[0]).size
nPhotos = len(fileList)
dst = Image.new("RGB", (width, height))
fileNum = 0