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
@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
} {}