Skip to content

Instantly share code, notes, and snippets.

Avatar
🌈
It's complicated?

Ryan Davis zenspider

🌈
It's complicated?
View GitHub Profile
View update_zig.sh
#!/bin/bash
set -e
# set -xv
DIR=/usr/local/opt/zig
if [ "$1" == "clean" ]; then
shift
echo "...from clean"
View expect_equal_deep.zig
const std = @import("std");
/// std.testing.expectEqual, but auto-coerces then uses expectEqualDeep
pub fn expectEqual(expected: anytype, actual: anytype) !void {
const T = @TypeOf(expected, actual);
return try expectEqualDeep(@as(T, expected), @as(T, actual));
}
pub const expectEqualSlices = expectEqualSlicesDeep;
View expect_equal_deep.zig
const std = @import("std");
/// std.testing.expectEqual, but auto-coerces then uses expectEqualDeep
pub fn expectEqual(expected: anytype, actual: anytype) !void {
const T = @TypeOf(expected, actual);
return try expectEqualDeep(@as(T, expected), @as(T, actual));
}
pub const expectEqualSlices = expectEqualSlicesDeep;
View zlox.zig
const Expr = union(enum) {
const Self = @This();
const CRef = *const Self;
binary: struct { lhs: CRef, op: Token, rhs: CRef },
grouping: struct { expression: CRef },
literal: struct { value: String }, // HACK -- needs to be a union(enum)
unary: struct { op: Token, rhs: CRef },
fn accept(self: Self, visitor: anytype) error{OutOfMemory}!void {
View shell-1.txt
# Running:
.................F....................
Finished in 0.033638s, 1129.6748 runs/s, 3389.0243 assertions/s.
1) Failure:
TestRuby2Ruby#test_case_in__find_pat [test/test_ruby2ruby.rb:874]:
not yet
View test.rb
def sanitize_exception e # :nodoc:
Marshal.dump e
e # good: use as-is
rescue TypeError
neuter_exception e
end
def neuter_exception e
bt = e.backtrace
msg = e.message.dup
View bisect.rb
#!/usr/bin/env ruby -w
# original test:
# rm -rf doc
# rdoc --verbose lib README.rdoc --main README.rdoc
# grep -q Minitest.html doc/index.html && echo good || echo bad
$: << "../../minitest-bisect/dev/lib"
require "fileutils"
require "minitest/find_minimal_combination"
View bench_eq.rb
#!/usr/bin/env ruby
# thawed = Object.new
# frozen = Object.new.freeze
# b = backwards/arg second (ie thawed == n)
# u = unless instead of if
# eq2 = ==
# neq2 = !=
require 'benchmark/ips'
View release_branch.rb
#!/usr/bin/env ruby -ws
$y ||= false
require "thread"
require "pry"
require "octokit"
require "zip"
require "fileutils"
View reopen_github_prs.rb
#!/usr/bin/env ruby
# require_relative "octokit_extensions"
require "thread"
require "pry"
require "octokit"
require "zip"
require "fileutils"
github_token = `git config github.oauth-token`.chomp