Skip to content

Instantly share code, notes, and snippets.

View thomcc's full-sized avatar
🦀

Thom Chiovoloni thomcc

🦀
View GitHub Profile
#[derive(Default, Debug, Clone)]
pub struct RadixSorter {
// TODO: only need one buffer.
unsorted_buf: Vec<(usize, u32)>,
pub sorted_buf: Vec<(usize, u32)>,
}
impl RadixSorter {
#[inline]
@thomcc
thomcc / rust-snippets.json
Last active September 12, 2019 02:26
vscode rust snippets
{
"unwrap or return": {
"scope": "rust",
"prefix": ["unwrap or return", "let if let"],
"body": [
"let $1 = if let ${3:Some($1)} = ${2:expr} {",
"\t$1",
"} else {",
"\treturn ${0:Ok(())};",
"};"
/// ```
/// # #[allow(dead_code)] fn code_requiring_fma_and_avx() {}
/// # #[allow(dead_code)] fn code_requiring_sse41() {}
/// # #[allow(dead_code)] fn code_requiring_sse2() {}
/// # #[allow(dead_code)] fn fallback_code() {}
/// # fn main() {
/// let thing = t3m::simd_match! {
/// // Comma separate required target features to require both.
/// "fma", "avx" => code_requiring_fma_and_avx(),
/// "sse4.1" => code_requiring_sse41(),
#[derive(Debug, Clone, Default)]
pub struct Shape {
pub vertices: Vec<V3>,
pub tris: Vec<[u16; 3]>,
}
impl Shape {
// ...
pub fn new_sphere(radius: f32, bands: (usize, usize)) -> Self {
use std::{f32, u16};
@thomcc
thomcc / gist:86e3bb41413d18ea6ce230b3460cd3f6
Last active February 11, 2019 02:36
crdts-for-sync.txt
<tcsc> i spent some time digging into how we could implement vector clocks in
the record sync stuff, but the vector clock algorithm requires you be able to
assign an id to anything that wants to be able to modify records. the main
downside to the id changing is space usage
<tcsc> i've been reading a bunch of stuff about CRDTs, and i'm pretty sure the
line we always throw out about how they don't work with server side encryption
is wrong -- they do. the difficulty of coming up with a good 'client id' value
is a stumbling point, though
diff --git a/places/examples/autocomplete.rs b/places/examples/autocomplete.rs
index d8e940b..0d44a47 100644
--- a/places/src/api/matcher.rs
+++ b/places/src/api/matcher.rs
@@ -8,7 +8,7 @@ use rusqlite::{
};
use url::Url;
-use db::PlacesDb;
+use db::{PlacesDb, db::unicode_normalize};
package org.mozilla.sync15_logins_example
import com.beust.klaxon.JsonObject
import com.beust.klaxon.Parser
import mozilla.components.service.fxa.*
import org.mozilla.sync15.logins.*
/**
* A minimal login example.
*
@thomcc
thomcc / logins-build.md
Last active September 6, 2018 20:45
Doing a local build of the logins archive

Doing a local build of the logins archive:

Note that we're working on improving this, but this is where we are currently. The first 5 steps you should only need to do once, and after that you can just run ./gradlew library:assembleRelease from the right dir (step 6).

Also note that this is somewhat sensitive to your local config, so while I've tried to test and make sure it works, well, hopefully I didn't forget any steps that I have already done in the past.

  1. Install NDK r15c from https://developer.android.com/ndk/downloads/older_releases (yes, this sucks, but newer versions don't understand the --deprecated-headers argument required to build OpenSSL against a v21 toolchain).

    • Extract it and put it somewhere we'll call $NDK_HOME.
  2. Install rustup from https://rustup.rs. You can do this while part 1 is happening.

@thomcc
thomcc / android-logins.fish
Last active August 8, 2018 23:58
local build script for libloginsapi_ffi.so that i'm using for android. big hacks here.
#!/usr/bin/env fish
set -l target x86
set -l triple i686-linux-android
set -l appsvc_root $HOME/application-services
if not test -d $appsvc_root
# Otherwise we'll make a mess later when we mkdir -p
echo "No application services dir found at expected location"
exit 1
@thomcc
thomcc / cargo bloat --crates --release --bin mentat_cli
Last active June 27, 2018 17:43
Mentat cli bloat stuff (after fixes from mailing list post)
File .text Size Name
15.3% 31.9% 796.6KiB [Unknown]
8.8% 18.5% 460.6KiB std
4.9% 10.2% 254.0KiB mentat_db
3.7% 7.8% 194.8KiB mentat_cli
2.6% 5.4% 134.4KiB regex
2.1% 4.4% 110.7KiB edn
1.7% 3.6% 90.4KiB regex_syntax
1.7% 3.6% 89.5KiB mentat_query_algebrizer
0.8% 1.8% 43.7KiB mentat