Skip to content

Instantly share code, notes, and snippets.

@b1
b1 / translit.py
Created March 31, 2011 09:21 — forked from naspeh/translit.py
# -*- coding: utf-8 -*-
import re
RU = (
u'ёыъэ',
u'а,a;б,b;в,v;г,g;д,d;е,e;ё,yo;ж,zh;з,z;и,i;'
u'й,y;к,k;л,l;м,m;н,n;о,o;п,p;р,r;с,s;т,t;'
u'у,u;ф,f;х,h;ц,c;ч,ch;ш,sh;щ,shh;ъ,\";ы,y;ь,\';'
u'э,e;ю,yu;я,ya'
#!/bin/bash
#
# Dropbox Uploader Script v0.7
#
# Copyright (C) 2010-2011 Andrea Fabrizi <andrea.fabrizi@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@b1
b1 / web_encode_data_uri.py
Created September 14, 2011 11:06
data uri image to base64
data_uri = open("sample.png", "rb").read().encode("base64").replace("\n", "")
img_tag = '<img alt="sample" src="data:image/png;base64,{0}">'.format(data_uri)
print img_tag
@b1
b1 / pars.js
Created February 28, 2012 21:28
vk.com music parser from browser console
clear();
var t = $x('//*[@class="play_btn"]/input');
// var t = $$('div#post-23141788_12015 input[type=hidden]');
var ec='';
for(var i=0;i<t.length;i++)
{
var str=t[i].value;
ec+=' '+str.substring(0,str.length-4);
}
console.log(ec);
@b1
b1 / gist:2328748
Created April 7, 2012 13:07
manual deleting history in chrome
var w=$$('input[type=checkbox]');
for(var i=0;i<w.length;i++){w[i].checked=true};
$$('#remove-selected')[0].disabled=false;$$('#remove-selected')[0].click();
@b1
b1 / gist:3032843
Created July 2, 2012 11:46
javascript transliteration
String.prototype.translit = (function(){
var L = {
'А':'A','а':'a','Б':'B','б':'b','В':'V','в':'v','Г':'G','г':'g',
'Д':'D','д':'d','Е':'E','е':'e','Ё':'Yo','ё':'yo','Ж':'Zh','ж':'zh',
'З':'Z','з':'z','И':'I','и':'i','Й':'Y','й':'y','К':'K','к':'k',
'Л':'L','л':'l','М':'M','м':'m','Н':'N','н':'n','О':'O','о':'o',
'П':'P','п':'p','Р':'R','р':'r','С':'S','с':'s','Т':'T','т':'t',
'У':'U','у':'u','Ф':'F','ф':'f','Х':'Kh','х':'kh','Ц':'Ts','ц':'ts',
'Ч':'Ch','ч':'ch','Ш':'Sh','ш':'sh','Щ':'Sch','щ':'sch','Ъ':'"','ъ':'"',
'Ы':'Y','ы':'y','Ь':"'",'ь':"'",'Э':'E','э':'e','Ю':'Yu','ю':'yu',
@b1
b1 / core_utils.middleware.py
Created July 21, 2012 11:02
Django middleware spaceless
# coding=utf-8
#!/usr/bin/env python
""" spaceless middleware
MIDDLEWARE_CLASSES += ('core_utils.middleware.SpacelessMiddleware',)
"""
from django.conf import settings
from django.utils.html import strip_spaces_between_tags
import re
@b1
b1 / .gitignore
Last active October 8, 2015 14:07
.gitignore for all kind of progects
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.zip
*.vi
@b1
b1 / .hgignore
Last active October 12, 2015 10:17
For all shit .hgignore
# use glob syntax.
syntax: glob
# use glob syntax.
syntax: glob
# Numerous always-ignore extensions
*.diff
*.err
*.orig
//You should use the [XHR Object][1], aka the "AJAX" method.
//[Here's an overview][2] as to how to start using it.
//Here's an excerpt:
// [1]: https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest
// [2]: https://developer.mozilla.org/en/docs/AJAX
function makeRequest(url, callback) {
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();