Skip to content

Instantly share code, notes, and snippets.

@vgrichina
vgrichina / web4-min.zig
Last active March 15, 2024 00:20
Minimalistic Web4 demo using Zig language
const std = @import("std");
// NOTE: In smart contract context don't really have to free memory before execution ends
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
var allocator = arena.allocator();
// Import host functions provided by NEAR runtime.
// See https://github.com/near/near-sdk-rs/blob/78c16447486285fd952765ef3e727e16d6c8c867/near-sdk/src/environment/env.rs#L117
extern fn input(register_id: u64) void;
extern fn read_register(register_id: u64, ptr: u64) void;
@miraclx
miraclx / GitHubRepoSize.user.js
Last active November 17, 2023 16:44
Calculate repo size and inject into GitHub page
// ==UserScript==
// @name GitHub Repo Size
// @namespace https://gist.github.com/miraclx/aad03f43fe8ac85682b0243f4f242f0d
// @description Calculate repo size and inject into GitHub page
// @icon https://github.githubassets.com/favicons/favicon.png
// @version 0.2.0
// @author miraclx
// @license Apache-2.0
// @supportURL https://gist.github.com/miraclx/aad03f43fe8ac85682b0243f4f242f0d
// @grant GM_xmlhttpRequest
@Shourai
Shourai / Mount SD Cards within VirtualBox on Mac OS X
Created November 2, 2018 11:00
Mount SD Cards within VirtualBox on Mac OS X
From: https://blog.lobraun.de/2015/06/06/mount-sd-cards-within-virtualbox-on-mac-os-x/
Mount SD Cards within VirtualBox on Mac OS X
Sometimes you need to mount your SD cards inside a VirtualBox machine to work with the files on the card. Working with the Raspberry Pi SD card on Mac OS X is an example for this.
My Raspberry Pi runs on Linux with some version of the EXT file system. While there is some support for this on Mac OS X, the available solutions have a lot of limitations, especially when it comes to write support on EXT file systems. As I do not have an USB keyboard, I sometimes need to mount the filesystem on another system to fix a startup problem when some of my experiments go wrong.
VirtualBox in theory allows for passing the internal card reader of the MacBooks to the virtual machine. Unfortunately, this does not work for me (and it seems for many other people).
@jdevera
jdevera / invalid_swagger_model.py
Created November 3, 2017 10:34
Create a model object without validation (useful for testing) in a generated Python Swagger Client
def make_invalid_model(model_class, **kwargs):
"""
create a model object bypassing all member validation
:param model_class: the class of the generated model that needs to be instantiated
:param kwargs: all the model parameters, as they would be passed to the constructor
:return: an instance of model_class
"""
def get_default_values(model_class, attributes):
signature = inspect.signature(model_class.__init__)
@huonw
huonw / blackmagic.rs
Created January 15, 2014 12:42
do-while loops in Rust
while {
let x = foo();
bar(x);
x != 0
} {}