Skip to content

Instantly share code, notes, and snippets.

View tit's full-sized avatar

TIT tit

  • Russia, Rostov-on-Don
View GitHub Profile
@tit
tit / typograf.rb
Last active August 29, 2015 14:16
Typograf
# encoding: utf-8
require 'unirest'
class String
def typograf
api_uri = 'http://www.typograf.ru/webservice/'
begin
response = Unirest.post api_uri, parameters: {text: self}
response.body
@tit
tit / randomizer.bash
Last active December 19, 2015 16:19
Rename images with random name
for i in *.jpg; do mv $i `uuidgen`.jpg; done
@tit
tit / status.bash
Last active December 19, 2015 16:18
A quick way to get HTTP status
curl -I http://example.com 2> /dev/null | grep HTTP | egrep -o [0-9]{3}
curl -w "%{http_code}" http://example.com 2> /dev/null
@tit
tit / realWidthHeight.js
Created June 15, 2013 21:39
Real Width/Height of webpage
Math.max(document.body.clientWidth, document.body.offsetWidth, document.body.scrollWidth);
Math.max(document.body.clientHeight, document.body.offsetHeight, document.body.scrollHeight);
bool x = true;
x = x == false; // or x = !x
@tit
tit / getelementbyxpath.js
Last active December 27, 2021 10:45
Javascript => getElementByXPath
document.getElementByXPath = function(sValue) { var a = this.evaluate(sValue, this, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); if (a.snapshotLength > 0) { return a.snapshotItem(0); } };
document.getElementsByXPath = function(sValue){ var aResult = new Array();var a = this.evaluate(sValue, this, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);for ( var i = 0 ; i < a.snapshotLength ; i++ ){aResult.push(a.snapshotItem(i));}return aResult;};
document.removeElementsByXPath = function(sValue) { var a = this.evaluate(sValue, this, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for ( var i = 0 ; i < a.snapshotLength ; i++ ) { a.snapshotItem(i).parentNode.removeChild(a.snapshotItem(i)); } };