Skip to content

Instantly share code, notes, and snippets.

Avatar

Jaroslaw Zabiello hipertracker

View GitHub Profile
View irish_bank_holidays.py
from workalendar.europe import Ireland
def irish_bank_holidays(year: int) -> list:
calc = Ireland()
return [x[0] for x in calc.holidays(year)]
@hipertracker
hipertracker / PageSearchInput.vue
Created Jun 17, 2020
Dynamic URL change: Quasar/Overmind + TypeScript + vue-router
View PageSearchInput.vue
<template>
<q-input clearable filled type="text" :value="q" @input="updateQuery" />
</template>
<script lang="ts">
import { defineComponent, ref, onMounted } from '@vue/composition-api';
export default defineComponent({
name: 'PageSearchInput',
@hipertracker
hipertracker / DynamicQuery.vue
Last active Jun 15, 2020
Dynamic URL change: Quasar + TypeScript + vue-router
View DynamicQuery.vue
<template>
<q-page padding>
<b>Search</b>
<q-form>
<q-input filled type="text" :value="query" @input="updateQuery" />
</q-form>
</q-page>
</template>
<script lang="ts">
@hipertracker
hipertracker / main.go
Last active Feb 27, 2020
Golang: sorting a slice of string with Polish sorting rules
View main.go
package main
import (
"fmt"
"sort"
"github.com/tidwall/collate"
)
type text []string
@hipertracker
hipertracker / tokenize.py
Last active Feb 1, 2020
Words tokenizer
View tokenize.py
import glob
import re
from typing import Iterator, List, Set, Tuple
from yaml import BaseLoader, load
def extract_words(text: str, min_length: int = 2) -> Set:
regex_words = re.compile(r"[\W]+", re.U)
return set(
@hipertracker
hipertracker / flatten.py
Created Jan 12, 2020
Missing list flatten function in Python
View flatten.py
def flatten(items: list, result: list = None) -> list:
if result is None:
result = []
for item in items:
if isinstance(item, list):
flatten(item, result)
else:
result.append(item)
return result
View test_verses_parser.py
from django.test import TestCase
from portal.lib.verses_parser import extract_verses, refs_with_chapter, split_refs
class VersesParserTestCase(TestCase):
maxDiff = None
def test_split_refs(self):
given = split_refs("Gen 1:2; 3:4-5", ["bw"])
@hipertracker
hipertracker / zsh-and-oh-my-zsh.txt
Created Dec 18, 2019
zsh + oh-my-zsh simple install
View zsh-and-oh-my-zsh.txt
1. Install zsh from packages
2. Install oh-my-zsh:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
3. configure ~/.zshrc
...
@hipertracker
hipertracker / react-custom-element.js
Created Dec 11, 2019
React refs forwarding to custom element issue
View react-custom-element.js
import * as React from 'react'
import {Component} from 'react'
class App extends Component {
setSvgRef(ref) {
console.log('Parrent React got ref:', ref); // this works
}
render() {
return <ScatterPlot svgRef={e => this.setSvgRef(e)}/>
@hipertracker
hipertracker / setStateSynchronous.js
Created Nov 14, 2019
React synchronous setState
View setStateSynchronous.js
setStateSynchronous(stateUpdate) {
return new Promise(resolve => {
this.setState(stateUpdate, () => resolve());
});
}
// https://stackoverflow.com/questions/42018342/is-there-a-synchronous-alternative-of-setstate-in-reactjs