Skip to content

Instantly share code, notes, and snippets.

View Cypher1's full-sized avatar

Jay Pratt Cypher1

View GitHub Profile
@Cypher1
Cypher1 / dot.dot
Last active November 22, 2022 02:55
Compiler Architecture
# Copyright 2022 Google LLC.
# SPDX-License-Identifier: Apache-2.0
digraph architecture {
subgraph cluster_01 {
node [shape=plaintext]
label = <<b>Legend</b>>;
{rank=same; key, key2 }
key [label=<<table border="0" cellpadding="2" cellspacing="0" cellborder="0">
<tr><td align="right" port="i1">Requests (internal)</td></tr>
<tr><td align="right" port="i2">Response (internal)</td></tr>
@Cypher1
Cypher1 / Reference <: Ownership
Created October 31, 2022 05:17
Ideas about the rust type system
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
trait ToRef<T> {
fn to_ref(&self) -> &T;
}
trait ToRefMut<T>: ToRef<T> {
fn to_mut(&mut self) -> &mut T;
}
@Cypher1
Cypher1 / Cargo.toml
Last active March 26, 2024 00:28
'Interactive' TUI with tokio and crossterm
[package]
name = "rusterm"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
crokey = "0.5.1"
crossbeam = "0.8.2"
@Cypher1
Cypher1 / types.rs
Created October 27, 2022 01:17
A couple of handy types for Rust programming
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0use std::marker::PhantomData;
#[derive(PartialEq, Eq, Hash)]
pub struct TypedIndex<T>(Index, PhantomData<T>);
impl<T> std::fmt::Debug for TypedIndex<T> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}[{}]", std::any::type_name::<T>(), self.0)
}
}
impl<T> TypedIndex<T> {
@venik
venik / build_tf.sh
Last active February 22, 2024 06:12
Bash script for local building TensorFlow on Mac/Linux with all CPU optimizations (default pip package has only SSE)
#!/usr/bin/env bash
# Author: Sasha Nikiforov
# source of inspiration
# https://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions
# Detect platform
if [ "$(uname)" == "Darwin" ]; then
# MacOS
@timothyklim
timothyklim / haskell-records.md
Created April 7, 2017 15:01 — forked from mtesseract/haskell-records.md
Working around Haskell's namespace problem for records

The Problem

Defining records in Haskell causes accessor functions for the record's fields to be defined. There is no seperate namespace for these accessor functions.

The Goal

Be able to

  • use records in Haskell, which share field names.
  • use lenses for accessing these fields