Skip to content

Instantly share code, notes, and snippets.

@dryan
dryan / pngoptimizer.py
Created September 21, 2009 20:36
Python script for batch running optipng
#!/usr/bin/env python
# requires optipng library
import os,optparse
parser = optparse.OptionParser()
parser.add_option('--file', '-f', default=False, help="The file to optimize. Omit to optimize all pngs in the current directory.")
parser.add_option('--optimization', '-o', default=7, help="The optimatization level to run. Defaults to 7.")
options,args = parser.parse_args()
@takinbo
takinbo / paginated_collection.js
Created July 25, 2011 21:57 — forked from io41/paginated_collection.js
Pagination with Backbone.js & django-tastypie
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage', 'filtrate', 'sort_by');
typeof(options) != 'undefined' || (options = {});
typeof(this.limit) != 'undefined' || (this.limit = 20);
typeof(this.offset) != 'undefined' || (this.offset = 0);
typeof(this.filter_options) != 'undefined' || (this.filter_options = {});
typeof(this.sort_field) != 'undefined' || (this.sort_field = '');
@troolee
troolee / gist:1140516
Created August 11, 2011 19:23
Automatically creates user's profile in django
from django.contrib.auth.models import User, SiteProfileNotAvailable
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.db.models.signals import post_init
from django.dispatch.dispatcher import receiver
@receiver(post_init, sender=User)
def user_post_init(sender, instance, **kwargs):
def get_profile():
@tehbeard
tehbeard / gist:1292348
Created October 17, 2011 10:24
MC RCON (1.9pr4)
<?php
/*
RCON remote console class, modified for minecraft compability by Tehbeard.
!!!YOU MUST CONFIGURE RCON ON YOUR MINECRAFT SERVER FOR THIS TO WORK
AT TIME OF WRITING ONLY 1.9pr4+ HAVE BUILTIN RCON SUPPORT!!!
Example Code:
============
include_once("rcon.class.php"); //Include this file
@bohde
bohde / tags.py
Created January 30, 2012 03:25
Using django-taggit with django-tastypie
from tastypie.fields import ListField
class TaggedResource(ModelResource):
tags = ListField()
class Meta:
queryset = Model.objects.all()
def build_filters(self, filters=None):
if filters is None:
@dsheiko
dsheiko / strtr.js
Last active July 9, 2023 18:18
Java-script strtr — translate characters or replace substrings
/**
* strtr() for JavaScript
* Translate characters or replace substrings
*
* @author Dmitry Sheiko
* @version strtr.js, v 1.0.2
* @license MIT
* @copyright (c) Dmitry Sheiko http://dsheiko.com
**/
@vojtajina
vojtajina / all-templates.html
Created August 15, 2012 00:00
AngularJS: load all templates in one file
<script type="text/ng-template" id="one.html">
<div>This is first template</div>
</script>
<script type="text/ng-template" id="two.html">
<div>This is second template</div>
</script>
package main
import (
"fmt"
"github.com/moovweb/gokogiri"
"io/ioutil"
"net/http"
"net/url"
"time"
)
@Ocramius
Ocramius / .gitignore
Last active January 10, 2023 16:34
`Zend\EventManager` examples
vendor
composer.lock