Skip to content

Instantly share code, notes, and snippets.

@ChillingHsu
ChillingHsu / qsort.rs
Last active November 24, 2018 04:52
quick sort 2 way & 3 way
use std::cmp::Ordering;
fn qsort3way<T: Ord + Copy>(sli: &mut [T], lo: usize, hi: usize) {
if hi <= lo {return;}
let mut lt = lo;
let mut i = lt + 1;
let mut gt = hi;
let v = sli[lo];
while i <= gt {
match sli[i].cmp(&v) {
@ChillingHsu
ChillingHsu / vec.rs
Created November 7, 2018 10:30
Toy Vec
#![feature(ptr_internals, alloc)]
use std::ops::{Deref, DerefMut};
use std::ptr::{self, Unique};
use std::{alloc, marker::PhantomData, mem};
struct RawVec<T> {
ptr: Unique<T>,
cap: usize,
}
@ChillingHsu
ChillingHsu / emacs.sh
Last active December 29, 2021 16:15
Run Emacs.app as Client/Server, for someone who likes GUI emacs and emacsclient to speed up start-up time.
#!/bin/bash
BG_RED=`tput setaf 1`
BG_GREEN=`tput setaf 2`
BOLD=`tput bold`
RESET=`tput sgr0`
EMACS='/Applications/Emacs.app'
EMACS_CLIENT='/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'
DEFAULT_EVAL='(switch-to-buffer "*scratch*")'