Skip to content

Instantly share code, notes, and snippets.

View Guria's full-sized avatar

Aleksei Gurianov Guria

View GitHub Profile
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 / cerebral-cli.js
Last active July 13, 2016 13:43
cerebral-view-inquirer :)
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) */ },
@Guria
Guria / dabblet.css
Created September 19, 2016 19:04
HTML5 / CSS3 Circle with Partial Border
/**
* 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%;
// 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
}
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)
@Guria
Guria / use-hover-example.js
Last active October 30, 2018 16:31 — forked from gragland/use-hover-example.js
React Hook recipe from https://usehooks.com
import { useRef, useState, useEffect } from 'react';
// Usage
function App() {
const [ref, isHovered] = useHover(ref);
return (
<div ref={ref}>
{isHovered ? '😁' : '☹️'}
</div>
<!DOCTYPE html>
<html
lang="en"
xmlns="http://www.w3.org/1999/xhtml"
prefix="og: http://ogp.me/ns# fb: http://www.facebook.com/2008/fbml"
>
<head>
<meta http-equiv="refresh" content="2;url=https://bb-ui.dev.sg.salondev.net/review/08d7bd31-a7da-46e8-b63a-b47a434e09c0" />
<!-- Facebook Open Graph meta tags
documentation: https://developers.facebook.com/docs/sharing/opengraph -->
%%private(let keyStringifyRegexp = %re("/([=:@$/])/g"))
%%private(let valueStringifyRegexp = %re("/([&;/])/g"))
%%private(let keyParseRegexp = %re("/[=:@$]/"))
%%private(let valueParseRegexp = %re("/[&;]/"))
%%private(
let encodeString = (str, regexp) =>
Js.Global.encodeURI(Js.String2.replaceByRe(str, regexp, "/$1"))
)
@Guria
Guria / README.md
Created June 12, 2023 13:41
Bash script for Manual Installation of GNOME Extension from ZIP File

GNOME Extension Installer Script

This bash script allows you to manually install GNOME extensions from a ZIP file. It's a helpful tool for installing GNOME extensions from local files rather than using GNOME Extensions or other online sources.

Usage

  1. Save the install_gnome_extension.sh script to your local machine.

  2. Make the script executable: