Skip to content

Instantly share code, notes, and snippets.

View KaMeHb-UA's full-sized avatar
🇺🇦
working from Ukraine, for Ukraine

KaMeHb-UA

🇺🇦
working from Ukraine, for Ukraine
  • Ukraine
  • 11:00 (UTC +03:00)
View GitHub Profile
@KaMeHb-UA
KaMeHb-UA / constants.mjs
Created May 7, 2020 08:21
PayMFC shared settings and constants
export const PAYMENT_STATE_CREATING = 0x00
export const PAYMENT_STATE_CREATED = 0x01
export const PAYMENT_STATE_SENT = 0x02
export const PAYMENT_STATE_CONFIRMED = 0x03
@KaMeHb-UA
KaMeHb-UA / app.js
Last active August 29, 2019 13:38
apostrophe-column-widget
// just because its needed in template...
Array.prototype.mapToNum = function(){
return this.map(v => parseFloat(v))
}
Array.prototype.mapWithIdx = function(){
return this.map((v, i) => ({ v, i }))
}
Array.prototype.filterByRegExp = function(regex){
regex = new RegExp(regex.source);
const res = [];
@KaMeHb-UA
KaMeHb-UA / loader.mjs
Created July 5, 2019 19:44
nodejs esm loader with https protocol support
// just place this file where you want, then exec node with --experimental-modules --loader "path-to-loader.mjs"
import path from 'path';
import process from 'process';
import Module from 'module';
import https from 'https';
import os from 'os';
import fs from 'fs';
const __tmpdir = os.tmpdir();
@KaMeHb-UA
KaMeHb-UA / README.md
Last active May 15, 2018 13:14
Simple node-like require for browser
@KaMeHb-UA
KaMeHb-UA / main.js
Created May 2, 2018 13:26
Simple browser __filename and __dirname realization (checked on Chrome and Firefox)
(()=>{const __filename=(a=>{return `${a[a.length-3]}://${a[a.length-2]}`})((new Error('')).stack.split(/(\w+):\/\/(\S+):\d+:\d+/)),__dirname=(a=>{a.pop();return a.join('/')})(__filename.split('/'));(()=>{
console.log([__filename, __dirname])
})()})()
@KaMeHb-UA
KaMeHb-UA / pkg
Last active May 27, 2018 00:34
Simple apt-like wrapper for yaourt (install: wget https://goo.gl/ZxoPLP -O - | /bin/sh)
#!/usr/bin/env node
const args = (shorts => {
var res = {
params: {},
args: []
};
for(var i = 2; i < process.argv.length; i++){
if(process.argv[i][0] == '-'){
if(process.argv[i][1] == '-'){
let [arg, ...val] = process.argv[i].slice(2).split('=');
@KaMeHb-UA
KaMeHb-UA / .bashrc
Created March 18, 2018 16:13
Beautiful and useful .bashrc example for TRUECOLOR terminals
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
@KaMeHb-UA
KaMeHb-UA / gogs.log
Created November 3, 2017 10:59
Gogs log
2017/11/03 09:48:56 [TRACE] Log Mode: File (Trace)
2017/11/03 09:48:56 [ INFO] Gogs 0.11.29.0727
2017/11/03 09:48:56 [ INFO] Cache Service Enabled
2017/11/03 09:48:56 [ INFO] Session Service Enabled
2017/11/03 09:48:58 [ INFO] Git Version: 2.15.0
2017/11/03 09:48:58 [ INFO] Run Mode: Production
2017/11/03 09:48:58 [ INFO] First-time run install finished!
2017/11/03 09:48:58 [TRACE] Doing: CheckRepoStats
2017/11/03 09:49:52 [TRACE] Session ID: eaa0726005172017
2017/11/03 09:49:52 [TRACE] CSRF Token: GzQbKG70RoFN9R6KaH8eQTaS9KE6MTUwOTcwMjUzMzMzODE0ODE5Mw==