Skip to content

Instantly share code, notes, and snippets.

View pjz's full-sized avatar

Paul Jimenez pjz

View GitHub Profile
@pjz
pjz / askdialog.py
Last active July 20, 2023 02:27
Wrapper for simple dialog/prompt using kivy
from kivy.logger import Logger
from kivymd.app import MDApp
from kivymd.uix.screen import MDScreen
from kivymd.uix.button import MDFlatButton
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.dialog.dialog import MDDialog
from kivymd.uix.textfield.textfield import MDTextField
@pjz
pjz / gist:66ce2f50a332a7c1be60585f0c9e9900
Last active April 1, 2023 15:23
LongShortTouchMixin
from kivy.clock import Clock
from kivymd.uix.widget import MDWidget as Widget
LONG_TOUCH_TIME = 0.8
class LongShortTouchMixin(Widget):
def __init__(self, **kw):
self.last_touch = None
@pjz
pjz / Makefile
Last active August 20, 2022 00:25
Zig from source
LLVM_PROJECT=llvm-project-14
LLVM_BASE=Downloads/$(LLVM_PROJECT)
LLVM_INST=$(LLVM_BASE)/local
ZIG2 := $(shell realpath stage2/bin/zig)
ZIG3 := $(shell realpath stage3/bin/zig)
ZIG4 := $(shell realpath stage4/bin/zig)
@pjz
pjz / zigstatus.md
Last active March 18, 2022 17:39
zig stage2 status

Status of the stage-2 compiler for Zig

graph TB
    Random:::done --> Sort:::done --> MultiArrayList ---> Parser
    HashMap:::done --> GeneralPurposeAllocator:::done --> Parser
    MultiArrayList --> ArrayHashMap --> AstGen
    HashMap & Parser --> AstGen 
 Allocator:::done --> ArrayList:::done --> Parser
@pjz
pjz / zig_inst
Last active August 31, 2021 20:02
#!/bin/bash
VERINDEX_URL="https://ziglang.org/download/index.json"
VERINDEX=/tmp/zig-download-index.json
fetch_index() {
FLAGFILE=/tmp/index-refetch.$$
touch -d '1 day ago' $FLAGFILE
if [ -f "$VERINDEX" ]; then
results_dir = Path(__file__).parent / 'expected_results_dir'
def test_one_process(bash):
bash.run_script('prog1', ['arg1', 'arg2'])
assert bash.path_exists('/path/to/outfile')
assert bash.file_contents('/path/to/outfile') == 'expected_result_text'
assert bash.file_contents('/path/to/outfile') == bash.file_contents(results_dir / 'one_process_results.txt')
def test_two_processes(bash):
bash.run_script('prog1', ['arg1', 'arg2'])
#!/bin/bash
# based on https://github.com/victorcoder/dkron/issues/212
#dkron_url="http://localhost:8080"
dkron_url=$1
if [ -z "$dkron_url" ]; then
echo "Usage: $0 <dkron base url>"
exit 1
fi
curl -s -X GET "$dkron_url/v1/jobs" -H "accept: application/json" -o -
echo
@pjz
pjz / update_pip.yaml
Created February 14, 2017 16:13
Ansible task to update pip
- name: get the pip version
command: pip --version
register: pip_version
ignore_errors: True
- name: fetch pip installer
get_url:
url: https://bootstrap.pypa.io/get-pip.py
dest: /tmp/get-pip.py
when: pip_version|failed
def test_ma_short_skips():
ma = MovingAverage([1,2,5,10])
for i in range(11):
ma.update(i, 5)
assert ma.cur == [ 5, 5, 5, 5 ]
ma = MovingAverage([1,2,3])
@pjz
pjz / timing.py
Last active April 11, 2016 17:28
import timeit
class Foo: pass
foo = Foo()
sfoo = 'foo' * 333
sfo = 'foo' * 332
dfoo = { 'foo': 1, 'bar': 2, 'baz': 3, 'bal': 4 }
setfoo = set(['foo', 'bar', 'baz', 'bal'])