Skip to content

Instantly share code, notes, and snippets.

@yuce
yuce / get_memory_size.py
Created February 13, 2025 23:46 — forked from philschmid/get_memory_size.py
Get needed GPU per precision for a Hugging Face Model Id
from typing import Dict, Union
from huggingface_hub import get_safetensors_metadata
import argparse
import sys
# Example:
# python get_gpu_memory.py Qwen/Qwen2.5-7B-Instruct
# Dictionary mapping dtype strings to their byte sizes
bytes_per_dtype: Dict[str, float] = {
@yuce
yuce / module_simple.prolog
Created December 10, 2024 19:09
Example for using SWI-Prolog modules with PySwip
from pyswip import Prolog
Prolog.assertz("m1:parent(A,B) :- m1:father(A,B); m1:mother(A,B)")
Prolog.assertz("m1:father(f,c)")
Prolog.assertz("m1:mother(m,c)")
for soln in Prolog.query("m1:parent(X,Y)"):
print(f"{soln['X']} parent_of {soln['Y']}")
@yuce
yuce / module_pythonic.prolog
Created December 10, 2024 19:08
Python interface example for using SWI-Prolog modules with PySwip
from pyswip import Prolog, Functor, Variable, Atom, Query
from pyswip.easy import module, call
_ = Prolog()
assertz = Functor("assertz")
if_ = Functor(":-", arity=2)
or_ = Functor(";", arity=2)
parent = Functor("parent", 2)
@yuce
yuce / 0-go-os-arch.md
Created July 15, 2022 03:51 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
import time
dv = {
1: 2,
2: 3,
3: 4,
4: 5,
5: 6,
6: 7,
7: 8,
@yuce
yuce / main.go
Created February 12, 2021 09:29
Avro Serialization with Hazelcast Go Client v3
package main
import (
"fmt"
"github.com/hamba/avro"
"log"
"reflect"
"github.com/hazelcast/hazelcast-go-client"
"github.com/hazelcast/hazelcast-go-client/serialization"
@yuce
yuce / ParquetToArrow.java
Created June 5, 2020 16:19 — forked from animeshtrivedi/ParquetToArrow.java
Example program to convert Apache Parquet data to Apache Arrow
/* This code snippet is a part of the blog at
https://github.com/animeshtrivedi/blog/blob/master/post/2017-12-26-arrow.md
*/
import com.google.common.collect.ImmutableList;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.*;
import org.apache.arrow.vector.dictionary.DictionaryProvider;
import org.apache.arrow.vector.types.FloatingPointPrecision;
import org.apache.arrow.vector.types.pojo.ArrowType;
UUID=f236cd03-83ef-403c-8d81-1f3fc09419f0 /media/ext ext4 errors=remount-ro,defaults,noatime 0 1
/media/ext/var/lib/snapd /var/lib/snapd none bind 0 0
/media/ext/var/snap /var/snap none bind 0 0
@yuce
yuce / retract.py
Created March 24, 2019 07:58
PySWIP retract
>>> from pyswip import Prolog
>>> p = Prolog()
>>> p.assertz("foo(bar)")
>>> p.assertz("foo(bar)")
>>> list(p.query("foo(X)"))
[{'X': 'bar'}, {'X': 'bar'}]
>>> p.retract("foo(bar)")
>>> list(p.query("foo(X)"))
[{'X': 'bar'}]
>>> p.assertz("foo(bar)")
bindsym $mod+Shift+m move scratchpad
bindsym $mod+Tab scratchpad show
bindsym $mod+m exec i3-input -F 'mark %s' -P 'Mark: '
bindsym $mod+j exec i3-input -F '[con_mark="%s"] focus' -P 'Jump: '