Skip to content

Instantly share code, notes, and snippets.

View jorilallo's full-sized avatar

Jori Lallo jorilallo

View GitHub Profile
@jorilallo
jorilallo / gist:871362
Created March 15, 2011 20:12
Destination of short url
# Source: http://stackoverflow.com/questions/2454149/python-detect-destination-of-shortened-or-tiny-url
import urllib2
response = urllib2.urlopen("http://bit.ly/AoifeMcL_ID3") # Some shortened url
url_destination = response.url
@jorilallo
jorilallo / Import Delicious bookmarks in Python
Created March 17, 2011 19:11
Use export file as source
from BeautifulSoup import BeautifulSoup
from datetime import datetime
def import_bookmarks(data):
'''
Get bookmarks from Delicious' export file format
'''
soup = BeautifulSoup(data)
deli_bookmarks = soup.findAll('dt')
@jorilallo
jorilallo / gist:898526
Created April 1, 2011 17:33
Boring Convore
p.follow-us {
display: none !important;
}
p.hosted a {
display: none !important;
}
div.box {
box-shadow: none !important;
//this is a generic function which should be moved to a Baseclass of Backbone or a Backbone extension
autoBind =
{
autoBind: function () {
var self = this;
var funcs = _.functions(this.constructor.prototype);
var protoFuncs = ['autoBind', 'constructor'].concat(
_.functions(Backbone.Collection.prototype),
_.functions(Backbone.Model.prototype),
_.functions(Backbone.View.prototype));
>>> 'NICK = jori'
>>> 'USER jorilallo jorilallo localhost :Jori Lallo'
<<< ':localhost 375 = :Welcome to new IRC! -- leah ()'
<<< ':localhost 376 = :End of /MOTD command.'
<<< ':localhost 001 = :Welcome to localhost'
<<< ':localhost 002 = :Your host is localhost, running version 0.0.1'
<<< ':localhost 003 = :This server was created 2011-07-10 06:43:35.799950'
<<< ':localhost 004 = localhost :0.0.1 w n'
>>> 'MODE = +i'
<<< ':localhost 472 = :Unknown MODE flag.'
@jorilallo
jorilallo / hr.less
Created July 11, 2011 18:51 — forked from maccman/hr.less
HR CSS3 Tapering
/* See http://cl.ly/8KmQ for an example */
hr {
margin: 15px 0;
position: relative;
border: 1px solid transparent;
.box-shadow(0, 1px, 2px, rgba(0,0,0,0.3));
&:before, &:after {
content: "";
Not synced (use migrations):
- channels
- accounts
- orgs
(use ./manage.py migrate to migrate these)
Running migrations for channels:
- Migrating forwards to 0001_initial.
> channels:0001_initial
Traceback (most recent call last):
@jorilallo
jorilallo / grove.io.js
Created August 25, 2011 17:37 — forked from defunkt/grove.io.js
grove.io dotjs script for inlining images
setInterval(function(){
$('.content a').each(function() {
if (/\.(gif|jpe?g|png)/i.test($(this).text()))
$(this).html('<img src="'+$(this).text()+'"/>')
})
}, 1000)
class EnvironmentResource(ModelResource):
class Meta:
queryset = Environment.objects.all()
resource_name = 'environment'
list_allowed_methods = ['get', 'post']
authentication = ApiKeyAuthentication()
authorization = Authorization()
def obj_create(self, bundle, request=None, **kwargs):
return super(EnvironmentResource, self).obj_create(bundle, request, user=request.user)
r = ListResource()
lists = r.obj_get_list(request)
lists_json = []
for list in lists:
bundle = r.build_bundle(obj=list, request=request)
lists_json.append(r.serialize(None, r.full_dehydrate(bundle), 'application/json'))