Skip to content

Instantly share code, notes, and snippets.

View astocko's full-sized avatar
💭
I may be slow to respond.

Alexander Stocko astocko

💭
I may be slow to respond.
View GitHub Profile
@astocko
astocko / absflip.cc
Created November 21, 2013 17:00
Absolute value and sign flip demo with bitmask and SSE instructions.
#include <iostream>
static constexpr int kAbsMask = 0x7FFFFFFF;
static constexpr int kFlipMask = 0x80000000;
int main(int argc, char const *argv[])
{
float y = -30.234;
float z = 40.023;
@astocko
astocko / fastsin.cc
Last active December 29, 2015 00:29
Fast sine approximation using SSE instructions.
char *ctable = "\x53\xBE\x25\xE6\xBC\xAB\xC4\x3E\x00\x00\x00\x00\x00\x00\x00"
"\x00\x7B\xFC\xAB\xE4\x24\xAA\xC4\x3E\x16\x46\x6F\x57\xCF\x00\xDF\x3E\xFB\x53"
"\x29\x1F\x5D\xA5\xC4\x3E\x47\x5F\xF3\x64\x6B\xFE\xEE\x3E\x2D\xE8\x53\x52\x66"
"\x9D\xC4\x3E\x3F\x66\xCA\xCB\xD3\x3B\xF7\x3E\x18\x49\x90\xB8\x41\x92\xC4\x3E"
"\x3B\xF9\x14\xB6\xDC\xF4\xFE\x3E\x53\xF8\xC0\x09\xF1\x83\xC4\x3E\x8B\xC8\x87"
"\xC9\x8F\x54\x03\x3F\xF2\x93\x02\x7B\x76\x72\xC4\x3E\x1B\x4C\x71\x20\xB6\x2B"
"\x07\x3F\xEA\xB1\x54\xBE\xD4\x5D\xC4\x3E\x84\x64\x87\xC4\x49\xFF\x0A\x3F\x64"
"\x79\x2F\x02\x0F\x46\xC4\x3E\xC1\x78\x97\xA7\xB3\xCE\x0E\x3F\x65\x0A\x06\xF1"
"\x28\x2B\xC4\x3E\x93\x8D\xE3\xAF\xAE\x4C\x11\x3F\x28\xC7\xB5\xB0\x26\x0D\xC4"
"\x3E\x9F\xE9\x62\x9F\x58\x2F\x13\x3F\x7B\x95\xE2\xE1\x0C\xEC\xC3\x3E\x1D\xFE"
# create assembler code:
c++ -S -fverbose-asm -g -O2 test.cc -o test.s
# create asm interlaced with source lines:
as -alhnd test.s > test.lst
@astocko
astocko / tls.py
Created November 9, 2015 15:17
Total Least Squares using PCA
"""Total Least Squares using PCA"""
# Copyright (c) 2015 Alexander Stocko <[email protected]>
# License: BSD 3 Clause
import numpy as np
import sklearn.decomposition
def tls_ratio(x, y):
A = np.stack([x, y]).T
@astocko
astocko / PerformanceRelated.txt
Created January 26, 2016 18:30 — forked from neomatrix369/PerformanceRelated.md
Interesting links in the areas of HPC, low latency, mechanical harmony/sympathy, garbage collection
Everything I Ever Learned About JVM Performance Tuning @Twitter- by Attila Szegedi
http://www.infoq.com/presentations/JVM-Performance-Tuning-twitter (video & slides)
9 Fallacies of Java Performance - by Ben Evans
http://www.infoq.com/articles/9_Fallacies_Java_Performance (video & slides)
Visualizing Java GC - by Ben Evans
http://www.infoq.com/presentations/Visualizing-Java-GC (video & slides)
@astocko
astocko / tmux.md
Created June 9, 2016 14:19 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

python -m json.tool my_json.json
@astocko
astocko / bad-words
Created June 15, 2016 14:26 — forked from fjfish/bad-words
Plain text file of regexps to match "bad" words, e.g. using grep -fi bad-words *.txt
[^[:alnum:]]ahole[^[:alnum:]]
[^[:alnum:]]anus[^[:alnum:]]
[^[:alnum:]]ash[0o]le[^[:alnum:]]
[^[:alnum:]]ass[^[:alnum:]]
[^[:alnum:]]azz[^[:alnum:]]
[^[:alnum:]]bassterd[^[:alnum:]]
[^[:alnum:]]bast[ae]+rd[^[:alnum:]]
[^[:alnum:]]b[i1]+[a]*tch[^[:alnum:]]
[^[:alnum:]]bl[o0]+wj[o0]+b[^[:alnum:]]
[^[:alnum:]]boffing[^[:alnum:]]
This file has been truncated, but you can view the full file.
/// Generated struct and trait implementations for:
/// ADC
/// Add with Carry
pub struct ADC {}
impl Ins2x<HardCodedOp, Imm8> for ADC {
pub fn ins2x(runtime: &JitRuntime, arg0: HardCodedOp, arg1: Imm8) {
bytes.push(0x14);
}
}
impl Ins2x<GPRegister8, Imm8> for ADC {
#![crate_type = "lib"]
pub fn increment(data: &mut u32, next: fn() -> usize) -> usize {
*data += 1;
next()
}