Skip to content

Instantly share code, notes, and snippets.

View Larpon's full-sized avatar
💭
Out now https://blackgrain.dk/non/

Larpon

💭
Out now https://blackgrain.dk/non/
View GitHub Profile
@spytheman
spytheman / encode_and_decode_using_mbedtls_pk.v
Created February 5, 2024 19:38
Encoding and Decoding data with RSA keys, using Vlang's net.mbedtls wrapper
import os
import net.mbedtls
const x = mbedtls.is_used // just silence a V warning, since we are using only the C functions from net.mbedtls, but not any pub V fn etc
type FnRNG = fn(p_rng voidptr, output &u8, output_len usize) int
fn C.mbedtls_pk_parse_public_keyfile(pk &C.mbedtls_pk_context, path &u8) int
fn C.mbedtls_pk_encrypt(pk &C.mbedtls_pk_context, const_input &u8, ilen usize, output &u8, olen &usize, osize usize, f_rng FnRNG, p_rng voidptr) int
fn C.mbedtls_pk_decrypt(pk &C.mbedtls_pk_context, const_input &u8, ilen usize, output &u8, olen &usize, osize usize, f_rng FnRNG, p_rng voidptr) int
@withs
withs / vxx.v
Created May 10, 2022 19:57
Create Cxx classes with methods and members In V (poc)
// I have a special case where i need to create and give a c++ class with virtual methods,
// so i came up with this proof of concept.
// Known limitation:
// - accesing class member/methods from "this" is pertty impossible without storing the Cxx struct globaly
// - you can't pass struct methods since the struct ptr will overwrite the real "this" ptr
// use it:
// v -enable-globals -shared vxx.v (work well with autofree and prod)
// g++ vxx_class.cc
@spytheman
spytheman / veditor.v
Last active November 17, 2020 09:10
import os
fn C.execvp(file charptr, argv &charptr) int
fn main() {
final_editor_cmd := os.file_name(os.args[0])[1..]
if os.args.len < 2 {
eprintln('Usage: `v$final_editor_cmd FILE:LINE: ...`')
exit(1)
}
@spaceface777
spaceface777 / mouse.v
Created September 26, 2020 13:23
linux terminal mouse input in V
import os
os.system('stty -icanon')
os.system('stty -echo')
println('\x1b[?1003h\x1b[?1015h\x1b[?1006h')
for signal in 0 .. 64 {
os.signal(signal, fn() {
os.system('stty icanon')
os.system('stty echo')
@cart
cart / FXAA.tscn
Last active January 30, 2024 18:17
Godot Nvidia FXAA 3.11 Port
[gd_scene load_steps=3 format=2]
[sub_resource type="Shader" id=1]
code = "shader_type canvas_item;
// Godot Nvidia FXAA 3.11 Port
// Usage: Drop this in to any 3D scene for FXAA! This is a port of the \"PC High Quality Preset 39\". However the medium quality
// parameters are also included. For medium quality, just comment out sections \"PS 6\" and above and uncomment the \"med 13\" variables.
package org.veiset.tsar.world
import com.badlogic.gdx.math.Vector2
import org.veiset.tsar.engine2.utils.component1
import org.veiset.tsar.engine2.utils.component2
import org.veiset.tsar.engine2.utils.x
import org.veiset.tsar.world.icon.WorldIcon
import kotlin.math.absoluteValue
import kotlin.math.cos
import kotlin.math.pow
import QtQuick 2.9
Binding {
id: root
property int delay: 500
property alias value: root._delayedValue
property alias _actualValue: root.value
property var _delayedValue
@tankorsmash
tankorsmash / SimpleInputRec.cpp
Created May 22, 2018 13:14
SIMPLE INPUT RECORD/PLAYBACK (c) 2015 Brian Provinciano
/******************************************************************************/
// SIMPLE INPUT RECORD/PLAYBACK
// (c) 2015 Brian Provinciano
//
// You are free to use this code for your own purposes, no strings attached.
//
// This is a very basic sample to record and playback button input.
// It's most useful when activated on startup, deactivated on shutdown for
// global button recording/playback.
//
@vurtun
vurtun / _readme_quarks.md
Last active December 9, 2023 12:03
Quarks: Graphical user interface

gui

// adapted from http://pythonwise.blogspot.in/2009/06/strftime-for-javascript.html
/*
To use it , save this gist in a file , import it into the desired QML
call as:
DateUtils.strftime ( format , dateObj);