Skip to content

Instantly share code, notes, and snippets.

View merryhime's full-sized avatar

merry merryhime

  • UK
  • 01:24 (UTC +01:00)
View GitHub Profile
a.out: file format mach-o-x86-64
Disassembly of section .text:
0000000100000e30 <_main>:
100000e30: 55 push %rbp
100000e31: 48 89 e5 mov %rsp,%rbp
100000e34: 41 57 push %r15
100000e36: 41 56 push %r14
@merryhime
merryhime / notes.txt
Last active February 17, 2016 23:43
Transfer Function Notes
Implementing signal flow graphs:
Signal flow graph for this implementation. All junctions are additive.
G(z) = (b0 + b1 z^-1 + b2 z^-2) / (1 - a1 z^-1 - a2 z^-2)
There are many possible implementations for a given transfer fuction, this is but one of them.
For ease of understanding this implementation uses twice as many delays as necessary, and is thus non-canonical wrt delays.
x tmp y
@merryhime
merryhime / Explanation-SA.md
Last active March 4, 2016 12:56
Strict Aliasing

When you construct an object, you allocate memory. For example, T foo; allocates memory sufficient for type T.

In your mental model, associate the block of memory where foo sits with T.

The essense to be safe is:

If a block of memory has type T, you may only use:

  • [const/volatile] T* pointer
  • a [unsigned] char* pointer
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Aeson
import qualified Data.Aeson.Types as T
import Data.Text (Text)
import Control.Applicative ((<$>))
import Control.Monad (mzero)
@merryhime
merryhime / hash-speed.txt
Last active June 7, 2016 09:42
Data comes from https://gist.github.com/epixoip/a83d38f412b4737e99bbef804a270c40 (As always please just use bcrypt or scrypt.)
Note each bucket has an order-of-magnitude difference from the last.
# xxx GH/s
Hashtype: MySQL323 414.4 GH/s
**Hashtype: MD4 350.8 GH/s**
Hashtype: NTLM 334.0 GH/s
Hashtype: Joomla < 2.5.18 200.6 GH/s
**Hashtype: MD5 200.3 GH/s**
Hashtype: PostgreSQL 200.1 GH/s
(1 0 ¯1 1 0 ¯1 1 0 ¯1)⌽"(1 0 ¯1)⊖"⊂M
Here we have a matrix M
Let's say it looks like this:
> M
0 0 0 0 0
0 0 0 0 0
// Superfast trig, x = [0.0, 1.0] only.
// Breaks for negative x.
// A circle is from x = 0 (0º) to x = 1 (360º). x = 0.5 is the same as 180º.
func sinCos(x float32) (float32, float32) {
cos := x - 0.25 - float32(int(x+0.25))
sin := x - float32(int(x+0.5))
cos *= 16.0 * (abs(cos) - 0.5)
sin *= 16.0 * (0.5 - abs(sin))
return sin, cos
}
package terraingen
var simplexPermutation [515]uint8
var simplexPermutationMod12 [515]uint8
func init() {
simplexPrecompute(0x12345678)
}
func simplexPrecompute(seed uint32) {
lfsr := makeLfsr(0x53494d50, 0x4c455830, seed)
// Here we use the Fisher–Yates shuffle to generate a random permutation
// It's an angled sobel operator.
// Pseudocode follows:
// input is RGB, output is greyscale
auto edge_detect (u8 input_image[W][L][3]) → u8[W][L] {
u8 output_image[W][L] = {0};
constexpr double angle = -135.0;
double radians = angle * 2.0 * PI / 360.0;
List of x64 microprocessors that don't support SSE3:
### AMD
* Athlon 64 Clawhammer (Sept 23, 2003) [C0 stepping also doesn't support NX, but CG stepping does]
* Athlon 64 FX Sledgehammer (Sept 23, 2003) [also doesn't support NX]
* Athlon 64 Newcastle (2004)
* Athlon 64 Wincheseter (2004)
* Athlon 64 FX Clawhammer (June 1, 2004) [also doesn't support NX]
* Opteron Sledgehammer (April 22, 2003)