Skip to content

Instantly share code, notes, and snippets.

View kandy's full-sized avatar

Andrii Kasian kandy

View GitHub Profile
<?php
namespace Co;
if (!function_exists('go')) {
function go($f) { $f(); }
function run($f) { $f(); }
} else {
\Co::set(['hook_flags' => SWOOLE_HOOK_TCP]);
}
echo "Start time: ", date(DATE_ATOM), PHP_EOL;
<?php
namespace Xhgui\Profiler;
class UploadSaver
{
/** @var string */
private $url;
/** @var int */
private $timeout;
@kandy
kandy / Bloomberg Market Crawler.py
Created April 3, 2022 01:29 — forked from tomy0000000/Bloomberg Market Crawler.py
Crawl Some Data from Bloomberg
import requests
import json
Req = [
"KOSPI2:IND",
"NIFTY:IND",
"SX5E:IND",
"UKX:IND",
"NDX:IND"
]
Data = {}
#!/usr/bin/env bash
set -e
# complain to STDERR and exit with error
die()
{
echo "$*" >&2
print_usage
exit 2
@kandy
kandy / unduplicate.js
Created September 10, 2020 03:36
Image deduplicator
(function (blockSelector, itemSelector) {
let list = document.querySelector(blockSelector);
let observer = () => list.querySelectorAll(itemSelector +":not(.imd-hash)")
.forEach(el => {
el.classList.add('imd-hash');
let width = 32;
let height = 32;
let img = new Image();
img.onload = function() {
let canvas = document.createElement("canvas");
@kandy
kandy / custom-task-definition.yml
Created April 29, 2020 23:45 — forked from guillaumesmo/custom-task-definition.yml
CloudFormation Custom Task Definition POC
# Sources:
# https://cloudonaut.io/how-to-create-a-customized-cloudwatch-dashboard-with-cloudformation/
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html
# https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/ECS.html
Resources:
CustomTaskDefinition:
Type: 'Custom::TaskDefinition'
Version: '1.0'
Properties:
@kandy
kandy / parse-options.sh
Created October 24, 2019 16:36 — forked from cosimo/parse-options.sh
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@kandy
kandy / parse-options.sh
Created October 24, 2019 16:36 — forked from cosimo/parse-options.sh
Example of how to parse options with bash/getopt
#!/bin/bash
#
# Example of how to parse short/long options with 'getopt'
#
OPTS=`getopt -o vhns: --long verbose,dry-run,help,stack-size: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
echo "$OPTS"
@kandy
kandy / job.yaml
Created June 26, 2019 21:52 — forked from alexellis/job.yaml
Use a Kubernetes Job and Kaniko to build an OpenFaaS function from Git
# Alex Ellis 2018
# Example from: https://blog.alexellis.io/quick-look-at-google-kaniko/
# Pre-steps:
# kubectl create secret generic docker-config --from-file $HOME/.docker/config.json
# Other potential optimizations (suggested by @errordeveloper)
# - Store "templates" in a permanent volume
# - Download source via "tar" instead of git clone
@kandy
kandy / criticalcss-bookmarklet-devtool-snippet.js
Created March 15, 2019 03:07 — forked from PaulKinlan/criticalcss-bookmarklet-devtool-snippet.js
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");