Skip to content

Instantly share code, notes, and snippets.

Avatar

Senko Rašić senko

View GitHub Profile
@senko
senko / gist:3505177
Created Aug 28, 2012
Grab a screenshot and paste it to the Web
View gist:3505177
#!/bin/bash
#
# screen-paste - Paste a screenshot to the Web
#
# Written by Senko Rasic <senko.rasic@goodcode.io>
# Released into Public Domain. Use it as you like.
#
# The tool allows the user to select a portion of the screen, then copies it
# to S3, and stores the resulting URL in clipboard.
#
@senko
senko / locals-fix.diff
Created Aug 6, 2012
locals() fix for SublimeLinter
View locals-fix.diff
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 / gist:2988592
Created Jun 25, 2012
Easy VirtualBox VM handling for the command line
View gist:2988592
#!/bin/bash -e
#
# Easy VirtualBox VM handling from the command line
BASE_TEMPLATE="<uid-of-template-vm>"
function show_help() {
echo "Usage: $0 [cmd]"
echo "Valid commands:"
echo " list List available virtual machines"
@senko
senko / vcf2csv.py
Created May 14, 2012
Simple vCard to CSV converter (only uses name, phone, email info)
View vcf2csv.py
#!/usr/bin/env python
"""
Parse phone and email records out of vCard file and store them in a CSV.
Copyright (C) 2012 Senko Rasic <senko.rasic@dobarkod.hr>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
@senko
senko / placeholder.js
Created Feb 16, 2012
HTML input field placeholder handling
View placeholder.js
/* 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 Nov 26, 2011
Render a Django template passing all local variables to the RequestContext automatically.
View renderlocals.py
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 / onchange.sh
Created Aug 18, 2011
Watch current directory and execute a command if anything in it changes
View onchange.sh
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@senko
senko / gist:1143824
Created Aug 13, 2011
GitHub repository archive link finder
View gist:1143824
#!/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 Jul 28, 2011
DOM text search/replace plugin for jQuery.
View gist:1112574
(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
A Python implementation of the 'which' shell command.
View which.py
#!/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