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 IndexingPoolOptions = struct { | |
/// The maximum number of items the pool can hold. | |
max_items: usize = std.math.maxInt(u32), | |
/// The number of item indices to be kept for re-use. If this is | |
/// too low, items will leak until the pool is deinitialized. | |
free_list_len: usize = 64, | |
log: type = std.log.scoped(.indexing_pool), | |
}; |
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 python3 | |
import sys | |
import renderdoc as rd | |
actions = {} | |
def iterDraw(d, indent = ''): | |
global actions |
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 fn put(b: []u8, a: []const u8) usize { | |
@memcpy(b[0..a.len], a); | |
return a.len; | |
} | |
pub fn main() u8 { | |
var ally = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
defer ally.deinit(); |
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 assert = std.debug.assert; | |
const Log2Int = std.math.Log2Int; | |
comptime { | |
std.testing.refAllDeclsRecursive(@This()); | |
} | |
const Register = extern union { | |
signed: i32, |
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
(defvar | |
python-on-region-template | |
"#! /usr/bin/env python3\nimport sys\nfor line in sys.stdin:\n sys.stdout.write(line$$)\n" | |
"The template to use for python-on-region. $$ indicates the point.") | |
(defun python-on-region--run () | |
(interactive) | |
(save-buffer) | |
(delete-window) | |
(switch-to-buffer python-on-region--buffer) |
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
function memfrob(str) { | |
var out = ""; | |
for (var i = 0; i < str.length; i++) { | |
out += String.fromCharCode(str.charCodeAt(i) ^ 42); | |
} | |
return out; | |
} | |
function apply(id, frobbed) { | |
document.getElementById(id).href = memfrob(atob(frobbed)); |
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
struct random_bit_generator { | |
uint32_t word; | |
uint8_t bits_remaining; | |
}; | |
static bool next_bit(struct random_bit_generator *rbg) { | |
if (rbg->bits_remaining == 0) { | |
rbg->word = arc4random(); | |
rbg->bits_remaining = 32; | |
} |
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 delimiter = '\n'; | |
const default_bits = 64; | |
const Wordlist = struct { | |
bytes: std.ArrayListUnmanaged(u8), | |
word_indices: std.ArrayListUnmanaged(usize), | |
allocator: std.mem.Allocator, |
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 fn sizeReport(comptime T: type, comptime indent: []const u8) []const u8 { | |
comptime { | |
var result: []const u8 = ""; | |
result = result ++ std.fmt.comptimePrint("{s}size of {s} is {d} bytes ({d} bits)\n", .{indent, @typeName(T), @sizeOf(T), @bitSizeOf(T)}); | |
switch (@typeInfo(T)) { | |
.Struct => |s| { | |
result = result ++ std.fmt.comptimePrint("{s}field report ({s}):\n", .{indent, @tagName(s.layout)}); | |
for (s.fields) |field| { |
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
pub const Rc4 = struct { | |
s: [256]u8 = undefined, | |
i: u8 = 0, | |
j: u8 = 0, | |
pub fn init(key: []const u8) Rc4 { | |
var self = Rc4{}; | |
for(&self.s, 0..) |*c, i| c.* = @intCast(i); |
NewerOlder