This file contains 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
-- Yandex ClickHouse could give you unexpected results if you try to cast string to float | |
-- and then convert it to integer to do arithmetics or just to store it as int. | |
-- Because of IEEE 754, string casted to float and back will not resemble original string (depending on value). | |
-- Example: | |
SELECT toString(toFloat64('1.07787')) AS result | |
-- 1.0778699999999999 | |
-- This will lead to loss of precision in some arithmetic operations: | |
SELECT toUInt64( toFloat64('1.07787') * exp10(5) ) AS result |
This file contains 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
#!/usr/bin/env bash | |
# https://gist.github.com/siberex/d1c07389333d9cdb1c9e6853ec70c98b | |
# Wait for file to become readable | |
# Similar to https://github.com/vishnubob/wait-for-it | |
# Usage: | |
# wait-for-file.sh -t 10 -p /tmp/something -- echo "ok" | |
WAITFORIT_cmdname=${0##*/} |
This file contains 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
#!/usr/bin/env bash | |
for port in $(seq 80 90) | |
do | |
#bash -c "</dev/tcp/localhost/${port}" &> /dev/null | |
nc -w 0 -v localhost ${port} </dev/null &> /dev/null | |
ret=$? | |
if [ $ret != 0 ]; then | |
printf "Port %d is available\n" $port | |
else |
This file contains 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
// Converts string to UTF16-encoded representation (useful for emoji parsing) | |
let toUtf = str => ( | |
typeof str === 'string' | |
&& str.length > 0 | |
&& str.split('').map( | |
char => '\\u' + ( | |
// Zero-pad up to 16 bits (0xFFFF) | |
'0000' + char.charCodeAt(0).toString(16) | |
).slice(-4).toUpperCase() | |
).join('') |
This file contains 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
/** | |
* Base64 encoding. Fast enough. | |
* | |
* | |
* Usage example: | |
* base64("[email protected]") | |
* result: "bWVAc2liLmxp" | |
* | |
* UTF strings are also accepted. | |
* |
This file contains 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
// Solution by broc.seib from http://stackoverflow.com/a/15016605/1412330 | |
// Here exists better decoding (not encoding) solution: http://jsbase64.codeplex.com/ | |
// Comparisons between my encoding and solutions from Stackvverflow are here https://gist.github.com/siberex/9089425 | |
decodeBase64 = function(s) { | |
var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length; | |
var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
for(i=0;i<64;i++){e[A.charAt(i)]=i;} | |
for(x=0;x<L;x++){ | |
c=e[s.charAt(x)];b=(b<<6)+c;l+=6; | |
while(l>=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r+=w(a));} |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset=utf-8> | |
<title>Javascript Base64 encoding/decoding</title> | |
</head> | |
<body> | |
<script id="myBase64"> |
This file contains 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
var open = window.XMLHttpRequest.prototype.open, | |
send = window.XMLHttpRequest.prototype.send, | |
onReadyStateChange; | |
function openReplacement(method, url, async, user, password) { | |
var syncMode = async !== false ? 'async' : 'sync'; | |
console.warn( | |
'Preparing ' + | |
syncMode + | |
' HTTP request : ' + |
This file contains 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
## This is a sample configuration file. See the nxlog reference manual about the | |
## configuration options. It should be installed locally and is also available | |
## online at http://nxlog.org/nxlog-docs/en/nxlog-reference-manual.html | |
## Please set the ROOT to the folder your nxlog was installed into, | |
## otherwise it will not start. | |
#define ROOT C:\Program Files\nxlog | |
define ROOT C:\Program Files (x86)\nxlog |
This file contains 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
define ROOT C:\Program Files (x86)\nxlog | |
Moduledir %ROOT%\modules | |
CacheDir %ROOT%\data | |
Pidfile %ROOT%\data\nxlog.pid | |
SpoolDir %ROOT%\data | |
LogFile %ROOT%\data\nxlog.log | |
<Extension json> | |
Module xm_json |
OlderNewer