Skip to content

Instantly share code, notes, and snippets.

View pije76's full-sized avatar

panjianom pije76

View GitHub Profile
@pije76
pije76 / Gemfile
Created May 23, 2013 15:20 — forked from pilt/Gemfile
source "http://rubygems.org"
gem "jammit"
gem "closure-compiler"
from cStringIO import StringIO
@register.simple_tag
def thumbnail(image_url, width, height, quality=95):
"""
Given the URL to an image, resizes the image using the given width and
height on the first time it is requested, and returns the URL to the new
resized image. if width or height are zero then original ratio is
maintained.
"""
if not image_url:
@pije76
pije76 / admin.py
Created February 19, 2013 03:09 — forked from uhop/admin.py
# Example how to add rich editor capabilities to your models in admin.
from django.contrib.admin import site, ModelAdmin
import models
# we define our resources to add to admin pages
class CommonMedia:
js = (
'https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js',
@pije76
pije76 / scrapy.py
Created February 17, 2013 13:13 — forked from samliu/scrapy.py
# Enable us to call scrapy from manage.py
from __future__ import absolute_import
from django.core.management.base import BaseCommand
class Command(BaseCommand):
def run_from_argv(self, argv):
self._argv = argv
self.execute()
data:text/html, <style type="text/css">.e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div class="e" id="editor"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("editor");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
<!--
For other language: Instead of `ace/mode/ruby`, Use
Python -> `ace/mode/python`
C/C++ -> `ace/mode/c_cpp`
Javscript -> `ace/mode/javascript`
Java -> `ace/mode/java`
from socialregistration.signals import connect as profile_connect
PERMISSIONS = {
'profile': ('view_profile', 'change_profile'),
'user': ('change_user', 'delete_user')
}
def social_connect_callback(sender, user, profile, client, **kwargs):
"""
Create a profile for this user after connecting
# What's this? It's a monster list of Google domain names that have been found to refer
# users to sites that are monitored with Shaun Inman's "Mint" statistics package. http:/haveamint.com/
#
# A huge number of these came from Shawn Blanc's domain list here:
# http://shawnblanc.net/2010/08/cleanup-mint-unique-referrers/
#
# I merged them in to my existing list for this "MONSTAH LIST". Enjoy!
#
# To filter many, many of the Google search results from your "Newest Unique Referrers" results in
# Mint, copy the list below verbatim (don't include these "comment" lines) and paste them into your
@pije76
pije76 / settings.py
Created December 4, 2012 15:48
class2go
TIME_ZONE = 'Asia/Riyadh'
LANGUAGE_CODE = 'ar'
ugettext = lambda s: s
LANGUAGES = (
('ar', ugettext('Arabic')),
('en', ugettext('English')),
)
@pije76
pije76 / feincms_ajax.js
Created October 29, 2012 17:00 — forked from schmidsi/feincms_ajax.js
FeinCMS ajax client side
var ajax_links_selector = 'a.ajax';
var content_selector = '#content';
var first_call = true;
var navilevel_substring = 3; // how many chars from pathname are static (3 for languagecode like /de/)
/* needs jquery address loaded: http://www.asual.com/jquery/address/
*
* needs feincms to be ajax-enabled:
*
* feincms/views/base.py:
@pije76
pije76 / appcontent.py
Created October 29, 2012 16:58 — forked from acdha/appcontent.py
Example of the new richer ApplicationContent type for FeinCMS - see http://github.com/acdha/feincms/tree/rich_appcontent
"""
Support for embedding blogs as FeinCMS ApplicationContent
"""
from django import forms
from .models import Blog
from .views import blog_detail
def get_admin_fields(form, *args, **kwargs):