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
// exchange btc to eth | |
// trx - transaction from db | |
let hitbtc = new ccxt.hitbtc(); | |
hitbtc.apiKey = ''; | |
hitbtc.secret = ''; | |
// check balance | |
const balance = await hitbtc.fetchBalance(); | |
// balance >= trx.amountFrom check in btc |
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
function argsList(method) { | |
method = method.toString(); | |
const fn = /^function\s*[^\(]*\(\s*([^\)]*)\)/m; | |
const cls = /constructor\s*[^\(]*\(\s*([^\)]*)\)/m; | |
const FN_ARGS = method[0] === 'f' ? fn : cls; | |
const depsStr = method.match(FN_ARGS); | |
const deps = (depsStr) ? depsStr[1].trim().split(/[\s,]+/) : ['']; | |
if (deps[0] === '') { | |
return []; |
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
var n = 7; | |
var center = Math.round(n / 2); | |
var steps = 1; | |
var stepCnt = n * n; | |
var y = center; | |
var x = center; | |
var getPos = (function* getPos() { | |
while (true) { | |
yield 'up' |
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
<?php | |
function callPrivateMethod($object, $method, $args) | |
{ | |
$classReflection = new \ReflectionClass(get_class($object)); | |
$methodReflection = $classReflection->getMethod($method); | |
$methodReflection->setAccessible(true); | |
$result = $methodReflection->invokeArgs($object, $args); | |
$methodReflection->setAccessible(false); | |
return $result; |
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
#!/bin/bash | |
GPG_COMMAND="gpg -c -z 0 --batch --passphrase XXXXXXXXXX" | |
FS_FILE=/tmp/$SERVER_NAME-fs.$TIME.tar.gz.gpg | |
MYSQL_FILE=/tmp/$SERVER_NAME-mysql.$TIME.sql.gz.gpg | |
# Archiving filesystem | |
tar -cz /etc /root /home | $GPG_COMMAND > $FS_FILE |
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
<?php | |
function binarySearch(array $searchArray, $needle) | |
{ | |
$length = count($searchArray); | |
$centerKey = (int)($length / 2); | |
$currentKey = $centerKey; | |
$start = 0; | |
$end = $length - 1; |
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
<?php | |
function bubble_sort($array) | |
{ | |
$n = count($array); | |
for ($i = 0; $i < $n - 1; $i++) { | |
for ($j = 0; $j < $n - 1 - $i; $j++) { | |
if ($array[$j] > $array[$j + 1]) { | |
list($array[$j], $array[$j + 1]) = [$array[$j + 1], $array[$j]]; |
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
<?php | |
function stupid_sort($array) | |
{ | |
$i = 0; | |
$n = count($array); | |
while ($i < $n - 1) { | |
if ($array[$i + 1] < $array[$i]) { | |
list($array[$i], $array[$i + 1]) = array($array[$i + 1], $array[$i]); | |
$i = 0; |
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
<?php | |
/** | |
* Created by Alexander Litvinov | |
* Email: [email protected] | |
* May be freely distributed under the MIT license | |
*/ | |
function typehint($level, $message) { | |
if($level == E_RECOVERABLE_ERROR && preg_match('/^Argument (\d)+ passed to (?:(\w+)::)?(\w+)\(\) must be an instance of (\w+), (\w+) given/', $message, $match)) { | |
if($match[4] == $match[5]) { |
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
function BarcodeScannerDetector(options) { | |
this.options = options || {}; // Default | |
this.options.keypressDelay = this.options.keypressDelay || 100; // Delay between press | |
this.chars = []; // Our barcode | |
this.events(); | |
} | |
BarcodeScannerDetector.prototype.delay = function(callback, ms) { | |
clearTimeout(this.timer); | |
this.timer = setTimeout(callback, ms); |
NewerOlder