Skip to content

Instantly share code, notes, and snippets.

View miceno's full-sized avatar

Orestes Sanchez miceno

  • Barcelona, Spain
View GitHub Profile
@geon
geon / ellipsis.htm
Created November 20, 2010 21:07
Textshortening and ellipsis with only CSS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Textshortening and ellipsis with only CSS</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<style type="text/css">
p {
width: 220px;
line-height: 18px;
@jpertino
jpertino / gist:731105
Created December 6, 2010 22:30
groovy xml string generation
def referenceClosure = {
html {
body {
h1 "hello"
}
}
}
def markupBuilder(closure) {
@tjarratt
tjarratt / ie8-leaflet-projection-bug
Created August 10, 2011 23:23
standalone leaflet projection image overlay IE8
<html>
<head>
<script src="./leaflet.js"></script>
<script>
window.onload = function() {
var myCrs = L.Util.extend({}, L.CRS, {
projection: L.Projection.LonLat,
transformation: new L.Transformation(1, 0, 1, 0)
});
@raul
raul / mediahint.js
Last active January 29, 2016 20:12
I like mediahint.com's extension but it relies on this external pac file hosted at https://mediahint.com/default.pac If mediahint.com gets compromised my whole navigation could get proxied without noticing. I'll modify the installed extension (under `~/Library/Application Support/Google/Chrome/Default/Extensions/...` in my Mac) to use a local ve…
function FindProxyForURL(url, host){
var myip = myIpAddress();
var ipbits = myip.split(".");
var myseg = parseInt(ipbits[3]);
if(myseg == Math.floor(myseg/2)*2){
proxy = 'PROXY 165.225.131.153:80; PROXY 165.225.130.193:80';
} else {
proxy = 'PROXY 165.225.130.193:80; PROXY 165.225.131.153:80';
}
if((host == 'localhost')||(shExpMatch(host, 'localhost.*'))||(shExpMatch(host, '*.local'))||(host == '127.0.0.1')){
@akprasad
akprasad / flask_admin_enum.py
Last active June 12, 2018 23:30
Adds flask-admin support for the SQLAlchemy "Enum Recipe" on zzzeek's blog (http://techspot.zzzeek.org/2011/01/14/the-enum-recipe/).
# -*- coding: utf-8 -*-
"""
flask-admin and "The Enum Recipe"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Adds flask-admin support for the enum recipe on zzzeek's blog_.
This code is specific to SQLAlchemy.
.. _blog http://techspot.zzzeek.org/2011/01/14/the-enum-recipe/
@MarkMenard
MarkMenard / gist:340526
Created March 22, 2010 21:05
Example Groovy JPA
package models
import javax.persistence.*
@Entity (name="Agreement")
@Table (name="agreement")
@EntityListeners ([QIdSetter.class])
class AgreementJpaImpl extends QIdEntityImpl implements Agreement {
@ManyToOne (targetEntity=PartyJpaImpl.class)
@bmihelac
bmihelac / import.py
Created September 30, 2015 08:34
Import management command for django-import-export
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import mimetypes
from optparse import make_option
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _
from django.core.management.base import BaseCommand
@antfu
antfu / sqlchemy_declarative_base_mixin.py
Created September 2, 2016 10:08
[Python|SqlAlchemy] as_dict for SqlAlchemy declarative base
from sqlalchemy.ext.declarative import declarative_base
class Mixin:
def as_dict(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
def as_clear_dict(self):
_dict = {}
for c in self.__table__.columns:
if c.foreign_keys:
continue
@shazow
shazow / mytypes.py
Created September 24, 2010 04:13
SQLAlchemy Enum type based on Integer indices, for better storage efficiency over the default Enum type.
"""
SQLAlchemy Enum type based on Integer indices.
"""
from sqlalchemy import types
class Enum(types.TypeDecorator):
impl = types.Integer
def __init__(self, value_map, strict=True, *args, **kw):
"""Emulate Enum type with integer-based indexing.
@oryon-dominik
oryon-dominik / decorators_debug_db_queries.py
Last active November 14, 2023 08:35
Decorator for debugging Django database queries
import time
import functools
import logging
from django.db import connection, reset_queries
log = logging.getLogger("django")