Skip to content

Instantly share code, notes, and snippets.

View senko's full-sized avatar

Senko Rašić senko

View GitHub Profile
@senko
senko / locals-fix.diff
Created August 6, 2012 19:26
locals() fix for SublimeLinter
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index fa2494e..f1eff00 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -131,6 +131,7 @@ def names(self):
class Scope(dict):
importStarred = False # set to True when import * is found
+ usesLocals = False
@senko
senko / placeholder.js
Created February 16, 2012 13:31
HTML input field placeholder handling
/* Hide/show placeholder text in an input field while it's empty
* To use, add data-placheholder="placeholder text" to your fields
* Eg: <input type="text" id="email" value="" data-placeholder="Enter your e-mail">
*/
$('input[data-placeholder]').each(function(){
$(this)
.bind('focus', function() {
if ($(this).val() == $(this).data('placeholder'))
$(this).val('');
})
@senko
senko / renderlocals.py
Created November 26, 2011 10:03
Render a Django template passing all local variables to the RequestContext automatically.
import django.shortcuts
import inspect
def renderlocals(template):
"""
Renders the template in a RequestContext, passing all local
variables to the request context, and returns the resulting
HttpResponse.
Example usage:
@senko
senko / gist:1143824
Created August 13, 2011 12:55
GitHub repository archive link finder
#!/usr/bin/env python
# A script to find recent download links for a GitHub
# repository.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Released to Public Domain. Use it as you like.
import urllib
@senko
senko / gist:1112574
Created July 28, 2011 21:14
DOM text search/replace plugin for jQuery.
(function($){
$.fn.textReplace = function(map, patterns) {
map = map || {};
patterns = patterns || [];
$('*', this).contents().filter(function() {
return ((this.nodeType == 3));
}).each(function() {
var old_text = $.trim(this.nodeValue);
var new_text;
@senko
senko / which.py
Created May 4, 2011 19:01
A Python implementation of the 'which' shell command.
#!/usr/bin/env python
#
# A Python implementation of the handy `which' shell command, showing
# the full path to a command that's in your path.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Released to Public Domain. Use it as you like.
import sys