Skip to content

Instantly share code, notes, and snippets.

@ChillingHsu
ChillingHsu / emacs.sh
Last active Dec 29, 2021
Run Emacs.app as Client/Server, for someone who likes GUI emacs and emacsclient to speed up start-up time.
View emacs.sh
#!/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*")'
View vec.rs
#![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 / qsort.rs
Last active Nov 24, 2018
quick sort 2 way & 3 way
View qsort.rs
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) {