Skip to content

Instantly share code, notes, and snippets.

const std = @import("std");
// usage:
// ./file-path:0 10
// 1 2 3
// 1. file path
// 2. Byte offset in file
// 3. ms update interval
pub fn main() anyerror!void {
@Jarred-Sumner
Jarred-Sumner / pretty.zig
Last active June 8, 2021 06:28
<red>red color</r><b>bold</r><red><b>red bold</r>
const print = @import("std").debug.print;
var enable_ansi_colors = true;
// Valid colors:
// <black>
// <blue>
// <cyan>
// <green>
// <magenta>
// <red>
const tester = @import("../test/tester.zig");
const std = @import("std");
threadlocal var parser_join_input_buffer: [1024]u8 = undefined;
threadlocal var parser_buffer: [1024]u8 = undefined;
// This function is based on Node.js' path.normalize function.
// https://github.com/nodejs/node/blob/36bb31be5f0b85a0f6cbcb36b64feb3a12c60984/lib/path.js#L66
pub fn normalizeStringGeneric(str: []const u8, buf: []u8, comptime allow_above_root: bool, comptime separator: u8, comptime isPathSeparator: anytype, lastIndexOfSeparator: anytype) []u8 {
const std = @import("std");
const Wyhash = std.hash.Wyhash;
const FixedBufferAllocator = std.heap.FixedBufferAllocator;
const HashKeyType = u64;
const IndexMap = std.HashMapUnmanaged(HashKeyType, u32, hash_hashFn, hash_eqlFn, 80);
pub const Result = struct {
hash: HashKeyType,
fn expectPrinted(t: *Tester, contents: string, expected: string, src: anytype) !void {
// ...
_ = t.expect(contents, copied, src);
}
test "test name" {
var t_ = Tester.t(std.heap.page_allocator);
var t = &t_;
try expectPrinted(t, "(-x) ** 2", "(-x) ** 2;\n", @src());
import {TSMeasureResult} from 'react-native-text-size';
import memoizee from 'memoizee';
import {NativeModules} from 'react-native';
import {LocationPermissionStatus, Location} from 'react-native-location';
import {isEmpty} from 'lodash';
import {LocationButton} from '../components/LocationButton';
import {GeocodeLocation} from './GeocodeLocation';
import {getBoundByRegion} from './getBoundByRegion';
const TextSize = NativeModules.RNTextSize;
@Jarred-Sumner
Jarred-Sumner / codemod.js
Last active March 19, 2021 21:43
Add import * as React from "react"; to the top of every TypeScript file
const addImports = require("jscodeshift-add-imports");
module.exports = function (fileInfo, api, options) {
const j = api.jscodeshift;
const code = fileInfo.source;
const root = j(code);
addImports(root, [j.template.statement`import * as React from 'react'`]);
return root.toSource();
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Untitled benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
//
// YeetJSIUTils.h
// yeet
//
// Created by Jarred WSumner on 1/30/20.
// Copyright © 2020 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <jsi/jsi.h>