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
import React, {useCallback, useLayoutEffect} from 'react'; | |
import Quagga from '@ericblade/quagga2'; | |
import QrCodeReader from '@ericblade/quagga2-reader-qr'; | |
Quagga.registerReader('qrcode', QrCodeReader); | |
function getMedian(arr) { | |
arr.sort((a, b) => a - b); | |
const half = Math.floor(arr.length / 2); | |
if (arr.length % 2 === 1) { |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"os" | |
"strings" | |
"sort" | |
) |
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
/** | |
* @param array $list | |
* @param string $sortAttribute | |
* @return array | |
*/ | |
public static function by(array $list, $sortAttribute) | |
{ | |
usort($list, function($o1,$o2) use($sortAttribute) { | |
if (!property_exists($o1, $sortAttribute) || !property_exists($o2, $sortAttribute)) { | |
throw new InvalidArgumentException(sprintf('At least one object does not contains attribute \'%s\' used for sorting.', $sortAttribute)); |
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
<?php | |
/** | |
* usage: php matrix.php 4 2 3 | |
*/ | |
$m=$argv[1]; | |
$n=$argv[2]; | |
$k=$argv[3]; |