Skip to content

Instantly share code, notes, and snippets.

View akoppela's full-sized avatar

Andrey Koppel akoppela

View GitHub Profile
@akoppela
akoppela / 80-pragmatapro.conf
Created November 29, 2021 13:54
Add font to NixOS
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<test name="family" compare="contains" ignore-blanks="true">
<string>PragmataPro</string>
</test>
<edit name="fontfeatures" mode="append">
@akoppela
akoppela / basic_regex_parser.js
Created October 1, 2020 08:48
Basic regex parser
// n - text size, m = patter size
// Time: O(n+m), Space: O(m)
function isMatch(text, pattern) {
var tokens = tokenize(pattern);
var textPointer = 0;
var tokenPointer = 0;
while (tokenPointer < tokens.length) {
var token = tokens[tokenPointer];
var char = findChar(text, textPointer);
module Effects exposing (Effects, apply, applyWithPriority, batch, from, map, none)
{-| In Elm all effects are managed (no side effects).
Effects are described with commands and subscriptions (Cmd msg, Sub msg).
Only private organisations/people have access to add/describe new effects.
Effects module helps to manage additional program effects.
For instance effects can be used for communication between programs.
It make sense especially for programs described as a composition of sub-programs.
A program effect should be supplied by a consumer.
@akoppela
akoppela / CustomElementForAngularComponent.js
Created March 19, 2020 08:49
Bare minimum to compile AngularJS component with custom Element.
angular
.module('shared', [])
.run(function ($rootScope, $compile) {
'use strict';
function CustomElementConstructor() {
// Super call
var self = HTMLElement.call(this) || this;
// Create custom element scope which is used as a store of data and as a parent for component scope.
@akoppela
akoppela / README.md
Last active June 10, 2023 18:32
Custom Elements with ES5 syntax

You'll need to include two pollyfils before you include a code with your custom elements:

webcomponents/webcomponentsjs/custom-elements-es5-adapter.js - this is for new browsers in order to understand ES5 syntax

webcomponents/custom-elements/custom-elements.min.js - this is for old browsers without customElements support

You can add them to your index.html file in the following way:

<div id="custom-elements-adapter">
gulp.task('elm:coverage', function () {
var coverageHtml = new jsdom.JSDOM(fs.readFileSync(PATH_COVERAGE + 'coverage.html').toString()),
mainOverview = coverageHtml.window.document.getElementsByClassName('overview')[0],
mainOverviewBodyRows = Array.from(mainOverview.querySelectorAll('tbody tr'));
var errors = mainOverviewBodyRows.reduce(function (accumulator, row) {
var result = Array.from(row.querySelectorAll('td')).reduce(function (accumulator, cell) {
var progress = cell.querySelector('progress');
if (progress) {
{-| Returns just true if given maybe is just something.
Otherise returns just false if given maybe is nothing.
maybeAndToBool (Just 42) == Just True
maybeAndToBool Nothing == Just False
-}
maybeAndToBool : Maybe a -> Maybe Bool
maybeAndToBool maybe =
case maybe of
Just _ ->
{-| Takes two maybe values and maybe test. Returns first maybe value if test is just true.
Otherwise returns second maybe value if test is just false.
-}
maybeAndWhenOrHelper : Maybe a -> Maybe a -> Maybe Bool -> Maybe a
maybeAndWhenOrHelper maybeValueWhen maybeValueWhenNot =
let
doTest test =
if test then
maybeValueWhen
else
%menu#first-menu{:type => 'list'}
%li{:value => '1'} 1
%li{:value => '2'} 2
%li{:value => '3'} 3
%menu#second-menu{:type => 'list', :target => '$$ #first-menu :set()'}
%li{:value => '1'} 1
%li{:value => '2'} 2
%li{:value => '3'} 3