Skip to content

Instantly share code, notes, and snippets.

(defun compileandrun()
(interactive)
(let* ((src (file-name-nondirectory (buffer-file-name)))
(exe (file-name-sans-extension src)))
(compile (concat "g++ -std=c++11 -Wshadow -Wall " src " -o " exe " -O2 -Wno-unused-result && ./" exe))))
@heeh
heeh / hamming_weight.rs
Last active June 5, 2021 15:24
Hamming Weight
fn countOnes(x: usize) -> usize {
let mut c = 0;
let mut x = x;
c = (x & 0x55555555) + ((x >> 1) & 0x55555555);
c = (c & 0x33333333) + ((c >> 2) & 0x33333333);
c = (c & 0x0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f);
c = (c & 0x00ff00ff) + ((c >> 8) & 0x00ff00ff);
c = (c & 0x0000ffff) + ((c >> 16) & 0x0000ffff);
return c;
}
@heeh
heeh / batch_predict.sh
Last active November 16, 2020 02:29
GNU Parallel Example
#!/bin/bash
if [ ! -d "targets" ]; then
mkdir targets
fi
if [ ! -d "frames" ]; then
mkdir frames
fi
word2target() {
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(setq pkgs
'(company
ido-vertical-mode
impatient-mode
use-package
@heeh
heeh / surfraw
Created May 4, 2020 02:25
This script enables surfraw to open chrome without address bar
#!/bin/sh
# Surfraw -- Shell Users' Revolutionary Front Against the World wide web
#
# Copyright (c) 2003-2018 The Surfraw-Devel Team
# <surfraw-devel@lists.alioth.debian.org>
# Copyright (c) 2000-2001 Julian Assange, placed into the public domain
# Copyright (c) 2000 Melbourne Institute for Advanced Study, placed into the public domain
#
# see the file COPYING for further copyright details
#