This file contains hidden or 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 builtin = @import("builtin"); | |
pub const StringContext = struct { | |
pub inline fn hash(_: @This(), s: []const u8) u64 { | |
return std.hash_map.hashString(s); | |
} | |
pub inline fn eql(_: @This(), a: []const u8, b: []const u8) bool { | |
return std.mem.eql(u8, a, b); | |
} |
This file contains hidden or 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 fn SlabAllocation(comptime types: []const type) type { | |
var alignment: usize = 1; | |
var slices: [types.len]type = undefined; | |
for (types, 0..) |T, i| { | |
slices[i] = []T; | |
alignment = @max(alignment, @alignOf(T)); | |
} | |
const out_alignment = alignment; | |
const Slices = std.meta.Tuple(&slices); | |
return struct { |
This file contains hidden or 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
// compile with: -mcpu=x86_64+sse2 to ensure sse2 support | |
pub fn decodeHex(input: []const u8, output: []u8) !void { | |
const block_size = 16; // change block size to use avx2 | |
const ByteBlock = @Vector(block_size, u8); | |
const IntBlock = @Vector(block_size / 4, u32); | |
if (input.len & 1 != 0) { | |
return error.OddLenghtInput; | |
} |
This file contains hidden or 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
// The MIT License (MIT) | |
// Copyright (c) 2018 cmf028 | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH |
This file contains hidden or 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
using UnityEngine; | |
using System.Collections; | |
// This script is meant to be attached to your main camera. | |
// If you want to use it on more than one camera at a time, it will require | |
// modifcations due to the Camera.on* delegates in OnEnable()/OnDisable(). | |
[ExecuteInEditMode] | |
public class CustomProjection : MonoBehaviour { | |
private void OnEnable(){ |
This file contains hidden or 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
using UnityEngine; | |
/* | |
Copyright 2016 Max Kaufmann (max.kaufmann@gmail.com) | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
This file contains hidden or 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
# - - coding: utf-8 - - | |
# This class http://www.w3.org/International/URLUTF8Encoder.java | |
# In Python | |
# To understand how | |
# 新 ("xin", 1st tone, means "new" in Mandarin) | |
# U+65B0 (Unicode codepoint http://unicode-table.com/en/search/?q=%E6%96%B0) | |
# %E6%96%B0 (URL encoding in UTF-8 http://www.url-encode-decode.com/) | |
# Interesting: Not fixed-width! "新" not same size as "T" |