Skip to content

Instantly share code, notes, and snippets.

View ebeloded's full-sized avatar

Evgenij (Eugene) Beloded ebeloded

View GitHub Profile
@ebeloded
ebeloded / get-git-branch.js
Created November 10, 2019 03:03
Get git branch
const childProcessExec = require('child_process').exec;
const util = require('util');
const exec = util.promisify(childProcessExec);
checkCommitMessage();
async function checkCommitMessage(){
const branches = await exec('git branch');
console.log(branches.stdout);
function proxify<T extends Object>(promise: Promise<T>): T {
const proxy = (path: Array<string> = []) =>
new Proxy(() => {}, {
get: (_target, prop: string) => proxy([...path, prop]),
apply: (_, _this, argumentsList) =>
promise.then((resolvedAPI) =>
path
.reduce<any>((p, c) => p[c], resolvedAPI)
.apply(_this, argumentsList),
@ebeloded
ebeloded / list-files-to-upload.sh
Created April 13, 2021 02:18
gcloud list files to upload
gcloud meta list-files-for-upload
@ebeloded
ebeloded / Dockerfile
Created April 15, 2021 07:10
build-test-env
FROM node:12.21.0-alpine
# RUN apk update
RUN apk add curl bash python
RUN sudo curl -sL https://firebase.tools | bash
RUN curl -sL https://sentry.io/get-cli | bash
RUN curl https://sdk.cloud.google.com | --disable-prompts --install-dir=/home bash
ENV PATH $PATH:/home/google-cloud-sdk/bin
@ebeloded
ebeloded / document-and-collection.ts
Last active May 14, 2021 02:13
document-and-collection.ts
const videoDoc = (id: string) => ({
get() {
return { id }
},
delete() {},
})
type QueryConstraint = number
const videosCollection = (...constraints: QueryConstraint[]) => ({
observe() {
const call =
<A, B>(fn: (a: A) => B) =>
(v: A): B =>
fn(v)
const doCall = call((v: number) => {
return v.toString()
})
const result = doCall(123)
@ebeloded
ebeloded / getFunctionParams.ts
Last active July 30, 2021 23:33
getFunctionParams
/**
* Returns parameters of a function
* Works for anonymous and named functions
* @param {Function} func
*/
const getFunctionParams = (func: Function): string[] =>
new RegExp('(?:\\s*|^)\\s*\\((.*?)\\)')
.exec(func.toString().replace(/\n/g, ''))![1]
.replace(/\/\*.*?\*\//g, '')
.replace(/ /g, '')
@ebeloded
ebeloded / input-datalist-unstyled.svelte
Created December 10, 2021 23:16
input datalist unstyled
<label for="browser">Choose your browser from the list:</label>
<input type="text" list="browsers" name="browser" id="browser" />
<datalist id="browsers">
<option value="Edge"></option>
<option value="Firefox"></option>
<option value="Google Chrome"></option>
<option value="Opera"></option>
<option value="Safari"></option>
@ebeloded
ebeloded / dynamically-load-languages.ts
Created February 17, 2022 21:18
dynamically load languages
Object.entries(import.meta.glob('../locales/*.yaml'))
.map(([path, f]) => [/locales\/(.+?)\.yaml/.exec(path)?.[1], f] as any)
.forEach(([key, f]) => {
console.log({ key, f })
locales[key] = true
if (key !== 'en') register(key, f)
})
const objectify = <T, EXT extends Object>(
f: (v: string) => T,
ext?: EXT,
root?: string
): Record<string, T> & EXT =>
new Proxy(f, {
get: (target, prop) =>
typeof prop === 'string'
? ext?.[prop] || target(prop as string)
: () => root,