Skip to content

Instantly share code, notes, and snippets.

View barraponto's full-sized avatar

Capi Etheriel barraponto

View GitHub Profile
@barraponto
barraponto / dabblet.css
Created January 27, 2012 17:19
Nursegroups Framed Block
/* Nursegroups Framed Block */
.-nursegroups-framed-block .block-title, .block .block-title {
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
-o-border-radius: 5px 5px 0 0;
-ms-border-radius: 5px 5px 0 0;
-khtml-border-radius: 5px 5px 0 0;
border-radius: 5px 5px 0 0;
-moz-box-shadow: inset 0 0 2px white;
-webkit-box-shadow: inset 0 0 2px white;
@barraponto
barraponto / dabblet.css
Created February 22, 2012 15:51
Damn the tr box model
/**
* Damn the tr box model
*/
body { font-size: 14px; }
table {
width: 635px;
border-collapse: collapse;
}
@barraponto
barraponto / info.md
Created March 8, 2012 18:49
Drupal Compass Plugin: a Template Approach

Every Drupal website has some telling signs that show it is made with Drupal. That isn't an issue, it's not like we're trying to hide it: we're proud of Drupal. Yet some elements are hardly ever themed, or when they do get styled it is in hindsight, after someone notices the tabs or the grippie doesn't match the whole of the design. Can we do something about it?

The folks at Chapter Three proposed a [template approach][1]: starting from an Adobe Fireworks template, try to get every Drupal element styled (google it). Good for graphic-oriented designers, but we're the next generation: we design in the browser with tools like Compass and Firebug.

So I decided to scratch this itch of mine. Drupal Compass Plugin implements the Template Approach (tm) in SASS files, and through a brief and mostly painless separation of selectors and skin (actual styles) we can even make the styles portable among base themes, core version (in the roadmap) and even different CMSs (dreamland).

It's already there, under active develo

@barraponto
barraponto / gist:2131544
Created March 20, 2012 05:05
D6: How to modify the #theme and #formatter of a field based on build_mode
/**
* Implements hook_nodeapi().
*/
function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'view') {
if ($node->type == 'business' && $node->build_mode == 'mobile') {
// change the field_photos formatter
foreach ($node->content['field_photos']['field']['items'] as $key => $item) {
$node->content['field_photos']['field']['items'][$key]['#formatter'] = 'my_preset_imagelink';
$node->content['field_photos']['field']['items'][$key]['#theme'] = 'imagecache_formatter_my_preset_imagelink';
@barraponto
barraponto / profiletags.py
Created March 23, 2012 15:29
Get most used hashtags from a Twitter profile's last 200 tweets.
import json
from urllib import urlencode
from urllib2 import urlopen
from collections import OrderedDict
profiletags = {}
api = 'https://api.twitter.com/1/statuses/user_timeline.json?'
# TODO: take options from CLIparameters
params = {
from scrapy.spider import BaseSpider
from lxml.html import parse as lxmlparse
class KwnewsSpider(BaseSpider):
name = 'kwnews'
allowed_domains = ['www.independent.co.uk']
start_urls = ['http://www.independent.co.uk/']
def parse(self, response):
doc = lxmlparse(response.body)
print doc
@barraponto
barraponto / dabblet.css
Created April 12, 2012 16:33
pure css accordion
/**
* pure css accordion
*/
body { width: 240px; }
ul { padding: 0; margin: 0; }
h2 { margin-top: 0; margin-bottom: 0.25em; }
h2 a { text-decoration: none; color: #905; }
li p { transition: height 1.5s; height: 0; overflow: hidden; margin: 0; }
li:target p { height: 81px; }
/* unfortunatelly, I can't use height: auto;
@barraponto
barraponto / tweet.php
Created April 16, 2012 21:19
Drupal Form API states example
<?php
$form['settings']['query_mode'] = array(
'#type' => 'select',
'#title' => t('Display type'),
'#options' => array(
'user' => t('User'),
'search' => t('Search'),
),
);
@barraponto
barraponto / git-submodule-rm.sh
Created April 25, 2012 16:36
git submodule-rm
#!/bin/bash
function actual_path() {
if [ [ -z "$1" ] -a [ -d $1 ] ]; then
echo $(cd $1 && test `pwd` = `pwd -P`)
return 0
else
return 1
fi
}
@barraponto
barraponto / dynamicmixin.css
Created May 4, 2012 00:40
Dynamic Mixins in SCSS
.span4 {
width: 400px; }
.span3 {
width: 300px; }
.span2 {
width: 200px; }
.span1 {