Skip to content

Instantly share code, notes, and snippets.

const std = @import("std");
pub fn preallocate_file(fd: std.os.fd_t, offset: std.os.off_t, len: std.os.off_t) void {
_ = std.os.linux.fallocate(fd, 0, @intCast(i64, offset), len);
}
pub fn main() anyerror!void {
const argv = std.process.argsAlloc(std.heap.c_allocator) catch unreachable;
if (argv.len < 3) {
std.log.warn("Usage: {s} <length> <file> [--preallocate]\n", .{argv[0]});
import logo from "./logo.svg";
import "./App.css";
function App() {
const ms = Date.now() - parseInt(window.location.search.substring(1), 10);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h3>Loaded in {ms}ms.</h3>
//go:generate go-enum -f=$GOFILE --marshal
// originally a fork of https://github.com/blang/semver iirc
package node_semver
import (
"math"
"math/bits"
"sort"
"strconv"
"strings"
pub fn eqlComptime(self: string, comptime alt: anytype) bool {
switch (comptime alt.len) {
0 => {
@compileError("Invalid size passed to eqlComptime");
},
2 => {
const check = comptime std.mem.readIntNative(u16, alt[0..alt.len]);
return self.len == alt.len and std.mem.readIntNative(u16, self[0..2]) == check;
},
const std = @import("std");
const Api = @import("./api/schema.zig").Api;
usingnamespace @import("./global.zig");
/// QueryString array-backed hash table that does few allocations and preserves the original order
pub const QueryStringMap = struct {
allocator: *std.mem.Allocator,
slice: string,
buffer: []u8,
list: Param.List,
// AUTO-GENERATED
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#define ZIG_DECL extern
#define CPP_DECL extern
#pragma mark - JSC::JSObject
#pragma once
/*
* Copyright (C) 2006-2021 Apple Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
@Jarred-Sumner
Jarred-Sumner / symbols.c
Last active July 13, 2021 20:43
JavaScriptCore.framework symbols list. Generated via https://github.com/macmade/dyld_cache_extract on the dyld cache, choosing JavaScriptCore, then running https://github.com/DerekSelander/dsdump on the output
0x7fff3659cf30 __ZN3WTF15initializeDatesEv
0x7fff3659d1a0 __ZN3JSC30FixedVMPoolExecutableAllocatorC2Ev
0x7fff3659d400 __ZN3WTF12RedBlackTreeINS_13MetaAllocator13FreeSpaceNodeEmE6insertEPS2_
0x7fff3659d810 __ZN3JSC5LLInt10initializeEv
0x7fff3659db00 __ZN3WTF10StringImplD2Ev
0x7fff3659e0c0 __ZN3WTF7CString18copyBufferIfNeededEv
0x7fff3659e4b0 __ZN3WTFL19wtfThreadEntryPointEPv
0x7fff3659e650 __ZN3WTF10StringImpl15stripWhiteSpaceEv
0x7fff3659eaa0 __ZN3WTF10StringImpl6toUIntEPb
0x7fff3659f9b0 __ZN3WTF17double_conversion6StrtodENS0_15BufferReferenceIKcEEi
@Jarred-Sumner
Jarred-Sumner / gist:e4ae7b4c988426f8f4d57890934882ca
Created July 13, 2021 20:41
JavaScriptCore.framework symbols list. Generated via https://github.com/macmade/dyld_cache_extract on the dyld cache, choosing JavaScriptCore, then running https://github.com/DerekSelander/dsdump on the output
This file has been truncated, but you can view the full file.
0x7fff3659cf30 __ZN3WTF15initializeDatesEv
0x7fff3659d1a0 __ZN3JSC30FixedVMPoolExecutableAllocatorC2Ev
0x7fff3659d400 __ZN3WTF12RedBlackTreeINS_13MetaAllocator13FreeSpaceNodeEmE6insertEPS2_
0x7fff3659d810 __ZN3JSC5LLInt10initializeEv
0x7fff3659db00 __ZN3WTF10StringImplD2Ev
0x7fff3659e0c0 __ZN3WTF7CString18copyBufferIfNeededEv
0x7fff3659e4b0 __ZN3WTFL19wtfThreadEntryPointEPv
0x7fff3659e650 __ZN3WTF10StringImpl15stripWhiteSpaceEv
0x7fff3659eaa0 __ZN3WTF10StringImpl6toUIntEPb
0x7fff3659f9b0 __ZN3WTF17double_conversion6StrtodENS0_15BufferReferenceIKcEEi
@Jarred-Sumner
Jarred-Sumner / show-ulimit.zig
Created June 29, 2021 19:52
show-ulimit.zig
const std = @import("std");
pub fn main() anyerror!void {
var out = std.io.getStdOut();
var writer = out.writer();
var str: [256]u8 = undefined;
var len = str.len;
var os_version = try std.os.sysctlbynameZ("kern.osproductversion"[0.. :0], &str, &len, null, 0);
try writer.print("macOS: {s}\nFile Descriptor Limit\n", .{str[0..len]});
if (std.os.getrlimit(.NOFILE)) |limit| {