Skip to content

Instantly share code, notes, and snippets.

Aleksei Gurianov Guria

Block or report user

Report or block Guria

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View use-hover-example.js
import { useRef, useState, useEffect } from 'react';
// Usage
function App() {
const [ref, isHovered] = useHover(ref);
return (
<div ref={ref}>
{isHovered ? '😁' : '☹️'}
</div>
View maze.holy.js
const REVISIT_PENALTY = 1.5
const DEADEND_PENALTY = 100000
const directions = ['left', 'right', 'up', 'down']
const visitedScore = {}
const getNextCoords = (x, y) => ({ left: [x-1, y], right: [x+1, y], up: [x, y-1], down: [x, y+1] })
const getScore = (x, y) => visitedScore[`${x}:${y}`] || 0
const increaseScore = (x, y, n = 1) => visitedScore[`${x}:${y}`] = getScore(x, y) * REVISIT_PENALTY + n
function strategy(move, canMove, x, y, maze) {
const nextCoords = getNextCoords(x, y)
View smth.md
// Define state and state updates
function ReduxState (state = Immutable.fromJS({items: []}), action) {
  switch (actions.type) {
    case 'addItem':
      return state.push('items', action.item)
  }

  return state
}
@Guria
Guria / dabblet.css
Created Sep 19, 2016
HTML5 / CSS3 Circle with Partial Border
View dabblet.css
/**
* HTML5 / CSS3 Circle with Partial Border
* http://stackoverflow.com/q/13059190/1397351
*/
* { margin: 0; padding: 0; }
.circle {
position: relative;
margin: 7em auto;
width: 16em; height: 16em;
border-radius: 50%;
@Guria
Guria / cerebral-cli.js
Last active Jul 13, 2016
cerebral-view-inquirer :)
View cerebral-cli.js
import controller from './controller.js'
import {Computed} from 'cerebral'
import {set, copy} from 'cerebral/operators'
import inquirer from 'inquirer'
controller.addSignals({
pageChanged: [ copy('input:page', 'state:page') ],
scaffoldSelected: [
() => console.log('scaffold'),
() => { /* services.scaffold(options) */ },
View 1.rebem.ts
import { createElement, DOMElement, ReactNode } from 'react';
import { stringify, BEMEntity } from 'rebem-classname';
export interface BEMFactory {
(props: BEMEntity, ...children: ReactNode[]): DOMElement<BEMEntity>
}
function BEM (props: BEMEntity, ...children: ReactNode[]) {
const tag = props.tag || 'div';
@Guria
Guria / index.js
Created Jan 10, 2016
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
Controller = require('cerebral')
Model = require('cerebral-model-baobab')
controller = Controller(Model({}))
controller.modules({
a: function(){
return { metsgg: 4 }
},
b: function(m,c) {
@Guria
Guria / kg-menu.bemhtml
Created May 19, 2015
bemhtml an block `menu`
View kg-menu.bemhtml
block('kg-menu')(
content()(function(){
return [
this.ctx.button || { elem: 'button' },
{ elem: 'menu', content: this.ctx.content }
];
}),
elem('menu').def()(function(){
var self = apply('self');
return applyCtx({
View _noinit.js
/**
* Modules
*
* Copyright (c) 2013 Filatov Dmitry (dfilatov@yandex-team.ru)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* @version 0.1.0
*/
You can’t perform that action at this time.