Skip to content

Instantly share code, notes, and snippets.

View gladson's full-sized avatar
😎
Vá lutar pelo que você acredita.

Gladson gladson

😎
Vá lutar pelo que você acredita.
View GitHub Profile
@doobeh
doobeh / gist:3188318
Created July 27, 2012 14:27
Installing WeasyPrint on Windows

Installing WeasyPrint on Windows

WeasyPrint converts HTML including images to PDF, it's cross platform but Windows requires a decent amount of massaging to persuade it to work.

To install Pango and Cairo download the [all in one bundle][GTK] of the GTK+ stack and extract the archive to C:\GTK.

You'll need to add the GTK bin folder to your system path so the various

@sepehr
sepehr / jquery.mobile_detect.js
Created August 16, 2012 15:54
JS: jQuery Mobile Browser Detection
/**
* Mobile Browser Detection for jQuery
*
* jQuery.browser.mobile will be true if the browser is a mobile device.
*/
(function(a){jQuery.browser.mobile=/android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|meego.+mobile|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(2
@HondoOhnaka
HondoOhnaka / ajax_submit.py
Created August 20, 2012 16:17
Simple ajax submit for Django form (specifically admin save and continue editing), reference for handling CSRF Middleware
#via http://ankursethi.in/journal/2012/Aug/19/a-django-admin-wishlist/
# In ajax_submit.js.
# NOTE: I'm not very good at writing idiomatic JavaScript.
# If you think this snippet can be improved, do
# let me know.
# WARNING: this code is meant for demonstration purposes.
# Do not use it in production. It fails on several edge cases
@hersonls
hersonls / settings.py
Last active March 15, 2022 16:11
Django Settings
import os
# Project information
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
PROJECT_NAME = os.path.basename(PROJECT_PATH)
# Helpers
path = lambda *p: os.path.join(PROJECT_PATH, *p)
# Debug
@hersonls
hersonls / urls.py
Created August 27, 2012 03:01
Django Urls
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
@carlosrberto
carlosrberto / ready.js
Created August 31, 2012 18:34
Background Resize
$(function(){
var image = $('.background');
function resize(){
resizeBackground(image, 640, 480);
}
$(window).resize(resize);
});
@hersonls
hersonls / gist:3695466
Created September 11, 2012 02:22
Nginx and Apache configuration for sub-domains
# Nginx
server {
# [...]
server_name *.yourdomain.com;
# [...]
}
@hersonls
hersonls / middleware.py
Created September 11, 2012 02:35
Middleware for django-subdomains
class SubdomainURLRoutingMiddleware(SubdomainMiddleware):
def process_request(self, request):
super(SubdomainURLRoutingMiddleware, self).process_request(request)
subdomain = getattr(request, 'subdomain', False)
if subdomain is not False and subdomain not in settings.SUBDOMAIN_BLACKLIST:
# Here is the trick. I will put at the first rule the users url
# set at the settings, this way, the first page will be the
# user page matched with subdomain.
@phloe
phloe / combine-layout.md
Last active July 27, 2020 07:23
combine-layout - float/inline-block layout technique

combine-layout

The following outlines a technique combining floating blocks and inline-blocks allowing for fairly interesting layouts without the need to use nested rows and avoids some problems when using pure floats.

The technique itself only uses three classnames:

  • combine-layout - defines the containing element.
  • break - starts a new row when in floating block context.
  • divide - starts off the inline-block context.
@macndesign
macndesign / gerador.py
Created November 7, 2012 19:46
Redimensiona imagens em vários tamanhos e guarda em um arquivo zip com argparse para passar algumas opções via linha de comando.
# coding: utf-8
import os, re, zipfile, argparse
try:
from PIL import Image
except ImportError:
import Image
def normalizar(valor):
"""