Skip to content

Instantly share code, notes, and snippets.

View stenin-nikita's full-sized avatar

Nikita Stenin stenin-nikita

View GitHub Profile
#!/bin/bash
# This script zeroes out any space not needed for packaging a new Debian Vagrant base box.
# Run the following command in a root shell:
#
# curl -sL https://gist.github.com/stenin-nikita/ad4023fc531bf01bcea3400addfe8244/raw/vagrant-clean.sh | bash -
function print_green {
echo -e "\e[32m${1}\e[0m"
}
@stenin-nikita
stenin-nikita / install-packages.sh
Last active August 1, 2017 08:14
Install packages for Debian 8
#!/usr/bin/env bash
# run command:
# wget -qO- https://gist.githubusercontent.com/stenin-nikita/069e653666be5612aec509011c2af498/raw/install-packages.sh | DB_ROOT_PASSWORD="secret" DB_USER_PASSWORD="secret" bash
export DEBIAN_FRONTEND=noninteractive
function print_green {
echo -e "\e[32m${1}\e[0m"
}
@stenin-nikita
stenin-nikita / react-verificator-example-1.jsx
Created November 12, 2017 18:38
Example API for react-verificator
import React, { Component } from 'react'
import validator from 'react-verificator'
const mapValidatorToProps = ({ ownProps, validator }) => ({
validator
})
@validator({
rules: {
name: 'required',
@stenin-nikita
stenin-nikita / calc.php
Created December 11, 2017 17:32
kmyacc example
<?php
/* Prototype file of PHP parser.
* Written by Masato Bito
* This file is PUBLIC DOMAIN.
*/
$buffer = null;
$token = null;
$toktype = null;
@stenin-nikita
stenin-nikita / ApolloUpload.php
Last active May 12, 2018 13:40
ApolloUpload Middleware for Laravel
<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
/**
* Class ApolloUpload
const EFFECT = Symbol('@@Reatom/EFFECT');
function createActionCreatorWithEffect(type, effect) {
return (payload) => ({
type,
payload,
[EFFECT]: (store) => effect(payload, store),
})
}
import { useContext, useEffect } from 'react';
import { context } from '@reatom/react';
export function useActionEffect(actionCreator, callback) {
const store = useContext(context);
useEffect(() => store.subscribe(actionCreator, () => callback()), [store, callback]);
}
import React, { FC } from 'react';
import { useAtom } from '@reatom/react';
import { declareAtom } from '@reatom/core';
interface TreeNode {
id: string;
parentId: string | null;
name: string;
children: string[];
properties: {
const paths = declareAtom({}, on => [
on(itemsAtom, (state, items) => {
const ims = values(items);
const paths = {};
for (const id of ims) {
paths[id] = getPathForItem(id, items);
}
return paths;
@stenin-nikita
stenin-nikita / isAction.ts
Last active October 27, 2020 15:41
reatom-helpers
import { Action } from '@reatom/core';
export function isAction(arg: any): arg is Action<any> {
return arg && typeof arg === 'object' && typeof arg.type === 'string';
}