Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fschutt
fschutt / How to fix the WebRender MaxTextureSize error (error code 1282)
Created July 19, 2019 13:56
How to fix the WebRender MaxTextureSize error (error code 1282)
If you are using WebRender and you get a MaxTextureSize error,
the problem is that the OpenGL context is broken. When calling
Renderer::new(), the context you are binding to *must be current*.
Otherwise, Renderer::new() will crash with a assert!(0, 1282) in
debug and a MaxTextureSize error in release mode.
@fschutt
fschutt / Rust.sublime-color-scheme
Created June 15, 2018 16:17
Rust Sublime Color Scheme
{
"name": "Rust color scheme",
"rules": [
/* --- grey items --- */
{
"scope": "comment",
"foreground": "color(var(black) blend(#fff 50%))",
},
/* --- red items --- */
{
extern crate itoa;
extern crate smallvec;
macro_rules! print_time {
($start:expr, $end:expr) => (println!("time: {} ns", ($end - $start).subsec_nanos() as f32 / 1_000_000.0);)
}
// 189 ns
fn new_order_slow(stock: &str, price: i32, quantity: i32) -> String {
format!("NEW {} {} {}", stock, price, quantity)
pub enum MyMarker { };
let a = MyMarker{ }; // no!
let b = MyMarker; // no!
let c = MyMarker:: ; // ???
mod private_module {
pub struct PublicStruct;
}
pub fn public_function() -> PublicStruct { /* ... */ }
#[cfg(not(use_double_precision))]
pub type fsize = f32;
#[cfg(use_double_precision)]
pub type fsize = f64;
let x: fsize = 50.0;
@fschutt
fschutt / insertion_sort.rs
Created January 1, 2018 00:32
Insertion sort in Rust
fn insertion_sort(data: &mut Vec<u8>) {
if data.len() < 2 { return; /* already sorted */ }
for j in 1..data.len() {
let key = data[j];
let mut i = (j as i8) - 1;
while i >= 0 && data[i as usize] > key {
data[(i + 1) as usize] = data[i as usize];
@fschutt
fschutt / solution.txt
Created December 24, 2017 13:55
How to enable two-finger scrolling using xinput (ThinkPad T420)
I can't say that this will work for everyone, but here's what I did:
First, list the input devices:
xinput list
You should get output like this:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]