Skip to content

Instantly share code, notes, and snippets.

@jbasko
jbasko / fix_paragraphs.vb
Last active November 28, 2022 11:35
Clear character formatting in Word except for italics and superscript (macro)
Sub ResetFindParameters(oRng As Range)
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
@jbasko
jbasko / koalicijas2022.py
Created October 6, 2022 10:32
Koalīciju rēķinātājs
import itertools
frakcijas = [
("JV", 26),
("ZZS", 16),
("AS", 15),
("NA", 13),
("S!", 11),
("LPV", 9),
("PRO", 10),
@jbasko
jbasko / indesign-generate-index.jsx
Last active November 8, 2021 22:39
Ģenerējam primitīvu jēdzienu rādītāju InDesign
/**
* Generate index based on multiple inflections of the same term.
* Requires http://underscorejs.org/ (with export statement removed) to be placed in the specified path.
*
*/
#target indesign;
#include "/path/to/underscore.js"
var _ = this._;
@jbasko
jbasko / locijumi.py
Created November 4, 2021 20:58
Termina visu locījumu izdabūšana laukā no tezaurs.lv
"""
Dabūt laukā visus terminu locījumus no tezaurs.lv
"""
from typing import List
import requests
import dataclasses
API = "https://api.tezaurs.lv/v1/inflections/"
@jbasko
jbasko / konva_drag_drop.html
Created April 12, 2020 16:36
Konva Drag&Drop with dedicated drop areas
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/konva@4.2.2/konva.min.js"></script>
<meta charset="utf-8" />
<title>Konva Drop</title>
<style>
body {
margin: 0;

Keybase proof

I hereby claim:

  • I am jbasko on github.
  • I am jbasko (https://keybase.io/jbasko) on keybase.
  • I have a public key ASCG6JaPj_Yn7o53c-omTdE900qmWFTal4bHwtRK2OJjlgo

To claim this, I am signing this object:

@jbasko
jbasko / kivy_recycle_view_scroll_y_helpers.py
Last active October 12, 2019 20:13
Kivy's RecycleView "metrics" - helpers to scroll based on item index
import math
from kivy.base import runTouchApp
from kivy.clock import Clock
from kivy.lang import Builder
from kivy.properties import ObjectProperty, StringProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.recycleview import RecycleView
@jbasko
jbasko / graph_and_topological_sort.py
Created March 30, 2019 12:53
Graph and Topological Sort using Kahn' s algorithm in Python 3
import collections
from typing import Iterable
class Vertex:
def __init__(self, value, graph: "Graph"):
self._graph = graph
self.value = value
def __hash__(self):
@jbasko
jbasko / pyenv_and_tox.md
Created September 7, 2018 22:56
pyenv and tox
cd ~
pyenv global 3.6.6 3.7.0
pip install tox
cd ~/workspace/xxx/project-name
pyenv local 3.6.6 3.7.0
tox
@jbasko
jbasko / wow.py
Last active April 10, 2018 04:57
This doesn't do what you think it does
def filter1(r):
return r % 3 == 0
def filter2(r):
return r % 5 == 0
def apply_all(records, *filters):