Skip to content

Instantly share code, notes, and snippets.

View revolunet's full-sized avatar
🐫
Killing bugz

Julien Bouquillon revolunet

🐫
Killing bugz
View GitHub Profile
<body>
<div id="dropzone">
<h1>Drop files here 2</h1>
<p>To add them as attachments</p>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
@revolunet
revolunet / views.py
Created February 3, 2011 17:04
add context to your django error pages
#
# by default, django 404 and 500 pages dont pass context to templates.
# as you almost *always* need context variables in your custom
# 404/500 templates, you might need MEDIA_URL for example
#
# you need to create a custom view for errors and register it in your urls.py
#
# in urls.py add :
#
# handler500 = handler404 = views.server_error
@revolunet
revolunet / inject.js
Created February 7, 2011 08:28
simplest test on earth
alert("Hello, world");
@revolunet
revolunet / rsnapshot-graphs.py
Created February 23, 2011 16:22
output some graphs from rsnapreport.pl output (google charts)
#!/usr/bin/python
#
#
# use pygooglecharts from http://pygooglechart.slowchop.com/
#
# just pipe rsnapreport.pl to this python script to get beautiful graphs with rsnapshot statistics
# send the email report as HTML to get your graphs embedded
#
# example crontab :
# 0 23 * * * root /usr/bin/rsnapshot daily 2>&1 | /home/juju/scripts/rsnapreport.pl | python /home/juju/scripts/rsnapshot-graphs.py | sendmail -t
@revolunet
revolunet / jQuery-live-edit.js
Created February 24, 2011 16:11
inject jQuery code from GET parameters
//
// when this script is inserted in your pages (with jQuery)
// you can send a initPage querystring parameter to control the page display
// what you send in initPage is executed with jQuery
//
// eg : send a link to this page, but with some dynamic modifications to someone (form filled...)
//
// example send :
// // this fill an input and check a box on the page
// initPage=[{selector:'input#testinput', method:'val',value:'Hello, World'}, {selector:'form[name=form1] input[name=check1]', method:'attr',value:['checked', true]}
@revolunet
revolunet / loadFromGET.js
Created February 25, 2011 10:47
include remote JS from querystring
/*
1) include this script in your page <script language="javascript" src="https://gist.github.com/raw/843632/loadFromGET.js"></script>
2) send a ?jsinit=http://domain/path/to/file.js
=> JS will be executed onload
*/
// querystring parser
function gup(name)
{name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(window.location.href);if(results==null)
@revolunet
revolunet / lzw_encoder.js
Created February 25, 2011 14:55
LZW javascript compress/decompress
// LZW-compress a string
function lzw_encode(s) {
var dict = {};
var data = (s + "").split("");
var out = [];
var currChar;
var phrase = data[0];
var code = 256;
for (var i=1; i<data.length; i++) {
currChar=data[i];
@revolunet
revolunet / compressed.js
Created February 25, 2011 20:05
send data with POST without physical form (no dependency)
function buildForm(a,e,c,d){if(!d){d=""}var b="<form id='form-"+d+"' method='"+e+"' action='"+a+"' target='"+d+"'>";b+='<input type="hidden" name="cb" value="alert"/>';for(i in c){if(c.hasOwnProperty(i)){b+='<input type="hidden" name="'+i+'" value="'+c[i]+'"/>'}}b+="</form>";return b}function createIframe(b){var a="<iframe id='"+b+"' name='"+b+"' width=1000 height=400 src='about:blank'></iframe>";document.body.innerHTML+=a}function postForm(a,e,b,c){var d="postForm";if(!c){c="iframe-"+d}if(!document.getElementById(c)){createIframe(c)}f=buildForm(a,e,b,c);if(!document.getElementById("postForm-container")){document.body.innerHTML+="<div id='postForm-container'></div>"}document.getElementById("postForm-container").innerHTML=f;document.getElementById("form-"+c).submit()};
@revolunet
revolunet / extractGifs.py
Created March 1, 2011 09:48
extract frames from animated gif using python+PIL
import os
from PIL import Image
def extractFrames(inGif, outFolder):
frame = Image.open(inGif)
nframes = 0
while frame:
frame.save( '%s/%s-%s.gif' % (outFolder, os.path.basename(inGif), nframes ) , 'GIF')
nframes += 1
@revolunet
revolunet / munin-django-models.py
Created March 2, 2011 12:36
graphs your django model instances with munin
#!/usr/bin/python
#
# Author : Julien Bouquillon (julien@bouquillon.com) - revolunet team
#
# this munin plugin generate graphs with evolution of all registered django models
# install : copy, chmod +x then ln -s in /etc/munin/plugins
#
# project root
import sys