This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); } }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool x = true; | |
x = x == false; // or x = !x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Math.max(document.body.clientWidth, document.body.offsetWidth, document.body.scrollWidth); | |
Math.max(document.body.clientHeight, document.body.offsetHeight, document.body.scrollHeight); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in *.jpg; do mv $i `uuidgen`.jpg; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.times = function (cb) { for (var i = 0; i < +this; i++) {cb(i)} } | |
function sleep(ms) {var date = Date.now(); while (Date.now() - date < 1000*ms) {} } | |
/* example use/* | |
10..times(function(i){sleep(1); console.log(i);}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# execute yield or not | |
# @return [Mixed] | |
# @example coin { Hamlet.new.to_be } | |
def coin | |
yield if [true, false].sample | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http-cookie need for Max-Age | |
# @see https://github.com/nahi/httpclient/issues/242#issuecomment-69020815 | |
require 'http-cookie' | |
require 'httpclient' | |
require 'json' | |
require 'symbolize_keys_recursively' | |
# CallTools | |
module CallTools | |
# CallTools API Client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Numeric | |
class Numeric | |
# convert numeric (integer or float) | |
# to formatted string with cash unit | |
# | |
# @example | |
# 42_000.to_cash '$', ',', '.', '%<unit>s%<amount>.2f' # => $42.000,00 | |
# 42_000.42.to_cash 'RUB', ',', ' ', '%<amount>.2f %<unit>s' # => 42 000,42 RUB |
OlderNewer