Skip to content

Instantly share code, notes, and snippets.

S33wVnoswA(FrlguwvBPI3Pu2BUa(sEX1KPZePCw90BwPTPKOS5MuKAjPStxnk)0Gfy25H9HDEzMNhG595HfOxGgZFM(c2N6)cBCoreKbjdErwsUQSBvUsBjEjIteXjoXjox(IZvp)SZhnlCYY4lCIViXj6k3KlC8xCTZ5JpF0sVlw4e5gKCX4LZMDr8c3jEo(x47EJR)5NQC(i3pNe5CH3KWGlIVo82lM6oZni27gx4TJNe5Ti5IPojoKA5uSQokmiojA5KKWOJcN6sQ7Lbts8cdU)Y9ID9NT)9xUmWl5KPSp88iN5UKp7gCZzoJ9Hpslw8BDV)BV)s2pPFQxVz(oXxF)Ltxg5GfD6T8dN44F)Lh9MtF(jV4IN)Qdg9Ylo(9V7GZo5nNE)Lpnxz3N0OM5DvFSWoUurjwFZDcw647F39xojY1jX9(lDU)Ya3BV)Yesh0YiYfMfgr(21WNOeNtG38cfP3msNqqyswRT)O5KY95WBCgTK6ILIiDW(P6xbBy1DBG0ERpHUJEYri9FYCNRixFV0bG(tCIto0jQ7QuVpzKBYrH(HrPv0EQKHp8FRCbDGV)Bd9csI3t4vDdMUcdiL64VCzSxWv8HfODEBy0NA54Xb8I5LlhZhuUSCRQ8vy8GHbKU87WXg(uG9K0R0MEhYeV9K2HoDLONN7f4fFT70nbn9sVPURpn5i0hJuvoU0dYD39QMA2N3BVVyZSowqKv5KGAQtsfksDKsUZbGuZomoCPIy(gnYDui)RVvJ1(BwM8aRETAREG4u62MbHgy6rQl3iutZll29cZR5cw3RrjVx(nKMw3Qkns31gQ4AJCm2GYBDIIDXBfxzfI3UBUfQODp5(58rVjaMZSTwtSHXYNmkjCXEYjscPTaES4VZXFPBmzr8KZhnIwF3TW98t1oF07xqwKFRr8vqwN5nNu7Qwwd11mnujAJSmY)8rNp60ftoLujms9zbqbp98dpF07CVXlMqANFQLLwA7kv3eAZXIuaK3MFBYmMZhHnDuHN)w37o
@aloucks
aloucks / two_sum.rs
Created March 10, 2022 16:40
two_sum.rs
use std::collections::HashMap;
impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut map = HashMap::with_capacity(nums.len());
for (i, n) in nums.iter().copied().enumerate() {
let i = i as i32;
let r = target - n;
if let Some(j) = map.get(&r) {
let j = *j;
@aloucks
aloucks / vulkan_case.rs
Last active March 15, 2021 23:54
vulkan symbol case converter
pub fn snake_case_to_pascal_case(item: &str) -> String {
let mut tmp = String::new();
let mut upper = true;
let mut last_char = ' ';
for mut c in item.chars() {
if c == '_' {
upper = true;
last_char = ' ';
continue;
}
@aloucks
aloucks / generate_normals.rs
Last active October 11, 2020 02:47
Generate normals from a height map
// https://stackoverflow.com/questions/44120220/calculating-normals-on-terrain-mesh
fn generate_normals(
height_map: &image::ImageBuffer<image::Luma<u16>, Vec<u16>>,
normal_map: &mut image::ImageBuffer<image::Rgb<u8>, Vec<u8>>)
{
let (cols, rows) = height_map.dimensions();
let up = cgmath::vec3(0.0, 0.0, 1.0);
//let mut normals = vec![up; (cols * rows) as usize];
// the `size_factor` reduces to `width / 1024` with this `cell_size`.
let cell_size = 1.0 / (cols as f32 / 128.0);
@aloucks
aloucks / faster_slerp.rs
Last active April 21, 2020 02:16
faster_slerp.rs
use directx_math::*;
// http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/
// simd version:
fn slerp(mut Q0: XMVECTOR, Q1: XMVECTOR, t: f32) -> XMVECTOR {
const DOT_THRESHOLD: XMVECTORF32 = XMVECTORF32 { f: [0.9995, 0.9995, 0.9995, 0.9995] };
let mut dot = XMQuaternionDot(Q0, Q1);
diff --git a/collector/slave_status.go b/collector/slave_status.go
index e343258..1fea965 100644
--- a/collector/slave_status.go
+++ b/collector/slave_status.go
@@ -18,7 +18,6 @@ package collector
import (
"context"
"database/sql"
- "fmt"
"strings"
@aloucks
aloucks / vulkaninfo.txt
Created June 1, 2019 00:34
vulkaninfo with gfx portability and mesa drivers
$ RUST_BACKTRACE=1 VK_ICD_FILENAMES=portability-linux-debug.json vulkaninfo > ~/vulkaninfo.txt
==========
VULKANINFO
==========
Vulkan Instance Version: 1.1.106
@aloucks
aloucks / atom-one-dark.icls
Created March 20, 2019 01:04
atom one dark intellij rust
<scheme name="Atom One Dark" version="142" parent_scheme="Darcula">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2019-03-19T21:00:29</property>
<property name="ide">Idea</property>
<property name="ideVersion">2018.3.5.0.0</property>
<property name="modified">2019-03-19T21:01:04</property>
<property name="originalScheme">_@user_Atom One Dark</property>
</metaInfo>
<option name="CONSOLE_FONT_NAME" value="Consolas" />