Skip to content

Instantly share code, notes, and snippets.

View spytheman's full-sized avatar
🏠
Working from home

Delyan Angelov spytheman

🏠
Working from home
View GitHub Profile
import json
pub struct Comment {
pub mut:
id string
comment string
}
pub struct Task {
mut:
// MIT License
// Copyright (c) 2021 blackshirt
// This module provides two function specified in RFC 7748 Elliptic Curves for Security,
// in the form x25519 and x448 function for elliptic curves over prime fields.
// For arithmatic operations, this implementation relies on `v_gmp` module from VincentLaisney.
// at https://github.com/VincentLaisney/v_gmp. It was V-lang binding
// to `GMP`, The GNU Multiple Precision Arithmetic Library that mostly available
// on all platform.
// NOTE: Use this with your own risk, not fully tested, and you've been warned!
@spytheman
spytheman / make_screenshot_demo.v
Created July 26, 2021 15:46
A way to make screenshots with V's gg
import gg
import gx
import os
import rand
import time
fn C.glPixelStorei(ename int, param int)
fn C.glReadBuffer(emode int)
fn C.glReadnPixels(x int, y int, width int, height int, eformat int, etype int, bufsize int, data voidptr)
1[20:31:40]delian@nemesis: (main) /v/vinix $
1[20:31:40]delian@nemesis: (main) /v/vinix $
1[20:31:41]delian@nemesis: (main) /v/vinix $ make
mkdir -p build 3rdparty
cd build && [ -f bootstrap.link ] || ( ln -s ../sysroot system-root && xbstrap init .. )
cd build && xbstrap install -u --all
xbstrap: Running the following plan:
fetch v
checkout v
patch v
(gdb) thread 1
[Switching to thread 1 (Thread 0x7f201257c740 (LWP 217305))]
#0 futex_abstimed_wait_cancelable (private=0, abstime=0x0, clockid=0, expected=0, futex_word=0x16bd938) at ../sysdeps/nptl/futex-internal.h:320
320 in ../sysdeps/nptl/futex-internal.h
(gdb) bt
#0 futex_abstimed_wait_cancelable (private=0, abstime=0x0, clockid=0, expected=0, futex_word=0x16bd938) at ../sysdeps/nptl/futex-internal.h:320
#1 do_futex_wait (sem=sem@entry=0x16bd938, abstime=0x0, clockid=0) at sem_waitcommon.c:112
#2 0x00007f201278e4e8 in __new_sem_wait_slow (sem=0x16bd938, abstime=0x0, clockid=0) at sem_waitcommon.c:184
#3 0x00000000004656db in sync__Semaphore_wait (sem=0x16bd938) at /tmp/v/test_session_84184488180398/channel_push_or_2_test.11194069820672318206.tmp.c:17770
#4 0x0000000000461cc4 in sync__Channel_try_push_priv (no_block=0 '\000', src=0x7ffcf23de158, ch=0x16bd8e0)
import x.json2
struct First {
mut:
a int
}
struct Second {
mut:
ok bool
// This program is a direct port of https://crypto.stanford.edu/pbc/notes/pi/code.html
// which in turn is an implementation of (Beeler et al. 1972, Item 120),
// see https://mathworld.wolfram.com/PiFormulas.html
// It calculates and prints the first 800 digits of pi, using only integer math.
const maxr = 2800
fn main() {
mut r := [maxr + 1]int{}
mut i, mut k, mut b, mut d, mut c := 0, 0, 0, 0, 0
for i = 0; i < maxr; i++ {
import time
import runtime
// these are here just as a harness to test the threads/channel setup below:
struct Dataset {
data string
}
struct Options {
import term
fn show(a []int, b []int) {
padding := ' '.repeat(26)
eprintln(padding +
'a.cap: $a.cap | a.len: $a.len ${a:-20} | b.cap: $b.cap | .len: $b.len ${b:-20}\n')
}
fn explain(code string, msg string) {
padding := ' '.repeat(25 - code.len)
{
"ast_type": "ast.File",
"path": "/v/vmaster/a.v",
"path_base": "a.v",
"lines": 13,
"bytes": 113,
"mod": {
"ast_type": "Module",
"name": "main",
"short_name": "main",