Skip to content

Instantly share code, notes, and snippets.

View creotiv's full-sized avatar

Andrey Nikishaev creotiv

View GitHub Profile
@creotiv
creotiv / ajax_intercepter
Created July 9, 2010 19:43
Ajax Intercepter
<html>
<body>
<script>
var xml_type;
// branch for native XMLHttpRequest object
if(window.XMLHttpRequest && !(window.ActiveXObject)) {
@creotiv
creotiv / gist:1217855
Created September 14, 2011 21:34
Multicore gevent wsgi server
import sys
from gevent import server
from gevent.baseserver import _tcp_listener
from gevent import pywsgi
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def hello_world(env, start_response):
if env['PATH_INFO'] == '/':
start_response('200 OK', [('Content-Type', 'text/html')])
@creotiv
creotiv / gist:1245443
Created September 27, 2011 15:51
JPEG encoder ported to JavaScript and optimized by Andreas Ritter
(function(){function h(a){throw a;}var j=void 0,k=true,l=null,t=false,u;function aa(a){this.t={};this.tick=function(a,c,d){this.t[a]=[d!=j?d:(new Date).getTime(),c]};this.tick("start",l,a)}var ba=new aa;window.jstiming={Timer:aa,load:ba};try{var ca=l;window.chrome&&window.chrome.csi&&(ca=Math.floor(window.chrome.csi().pageT));ca==l&&window.gtbExternal&&(ca=window.gtbExternal.pageT());ca==l&&window.external&&(ca=window.external.pageT);ca&&(window.jstiming.pt=ca)}catch(da){};if(window.jstiming){window.jstiming.lb={};window.jstiming.Wb=1;var ea=function(a,b,c){var d=a.t[b],e=a.t.start;if(d&&(e||c))return d=a.t[b][0],c!=j?e=c:e=e[0],d-e},fa=function(a,b,c){var d="";window.jstiming.pt&&(d+="&srt="+window.jstiming.pt,delete window.jstiming.pt);try{window.external&&window.external.tran?d+="&tran="+window.external.tran:window.gtbExternal&&window.gtbExternal.tran?d+="&tran="+window.gtbExternal.tran():window.chrome&&window.chrome.csi&&(d+="&tran="+window.chrome.csi().tran)}catch(e){}var f=
window.chrome;if(f&&(f=f.load
@creotiv
creotiv / gist:1245476
Created September 27, 2011 16:01
JavaScript JPEG encoder
/**
http://closure-library.googlecode.com/svn-history/r440/trunk/third_party/closure/goog/jpeg_encoder/jpeg_encoder_basic.js
* @license
Copyright (c) 2008, Adobe Systems Incorporated
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
@creotiv
creotiv / gist:1583550
Created January 9, 2012 15:56
Script for Git that generates changelog by tags
#!/bin/bash
# Author:Andrey Nikishaev, Gunnar Lindholm
echo "CHANGELOG"
echo ----------------------
git for-each-ref --sort='*authordate' --format='%(tag)' refs/tags |tac |grep -v '^$' | while read TAG ; do
echo
if [ $NEXT ];then
echo [$NEXT]
else
echo "[Current]"
@creotiv
creotiv / wkhtml2pdf.py
Created January 9, 2012 22:36
WebKit(PyQt4) PDF Printer example
#!/usr/bin/env python
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
app = QApplication(sys.argv)
@creotiv
creotiv / pyperclip.py
Created April 22, 2012 19:09 — forked from rafacv/pyperclip.py
Unified interface to access clipboard across major OSes
# Source: http://coffeeghost.net/2010/10/09/pyperclip-a-cross-platform-clipboard-module-for-python/
# Pyperclip v1.3
# A cross-platform clipboard module for Python. (only handles plain text for now)
# By Al Sweigart al@coffeeghost.net
# Usage:
# import pyperclip
# pyperclip.copy('The text to be copied to the clipboard.')
# spam = pyperclip.paste()
@creotiv
creotiv / gist:3048324
Created July 4, 2012 16:57
Facebook friend adder
var addFriend = function() {var link = document.getElementsByClassName('uiIconText')[0];link.click();setTimeout(addFriend,2000);}
addFriend();
@creotiv
creotiv / gist:3048328
Created July 4, 2012 16:58
Facebook friend adder
HTMLElement.prototype.click = function() {
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}
var addFriendSuggest = function() {
var link = document.getElementsByClassName('uiIconText')[0];
if(link.getAttribute('ajaxify')) {
link.click();
setTimeout(addFriendSuggest,2000);
@creotiv
creotiv / extjs-example-architecture.js
Created September 10, 2012 09:39
ExtJs Example Architecture
//App abstract class:
App = function(cfg){
Ext.apply(this, cfg);
this.addEvents({
'ready' : true,
'beforeunload' : true
});
Ext.onReady(this.initApp, this);
};