Skip to content

Instantly share code, notes, and snippets.

View 67hz's full-sized avatar
🎼

Jake H 67hz

🎼
View GitHub Profile
@67hz
67hz / x86MemoryAddressingModes.md
Last active March 4, 2019 22:38
x86 Memory Addressing Modes with examples

x86 Memory Addressing Modes

Effective Address

effectiveAddress = BaseReg + IndexReg * ScaleFactor + Displacement

BaseReg = any general purpose register
IndexReg = Index Register - any gen purpose register except Stack Pointer Reg (ESP)
ScaleFactor = 1,2,4,8

Displacement = Constant offset encoded w/in instruction

@67hz
67hz / gist:fa626bef810d1fe1024b
Created September 15, 2014 20:12
Underscore chaining. This example scans a collection, finds all items that match a condition, then returns a new collection from the matches with custom structure.
var subscribersModel = {
users: [
{
'id': '1asdf',
'activeSubscriptions': ['monthly', 'gold'],
'gender': 'm',
'age': '31',
'username': 'CowboyWayne'
},
{
@67hz
67hz / js-closure
Last active August 29, 2015 14:06
Closure demystified. Closure is best expressed when a function returns an anonymous function. If the nested anonymous function references a variable within the parent function context, that variable reference will be accessible when the nested function is invoked.
var multiplyByNumber = function (x) {
return function(y) {
// this nested anonymous function references
// parent 'x' arg variable
return x * y;
}
}
/**
* multiplyBy5 below is a function because multiplyByNumber returns a function.
@67hz
67hz / opacity.less
Created November 14, 2012 07:14
Background Opacity with support back to IE7 using LESS CSS
/* .bg-opacity() = the workhorse background opacity mixin. takes 2 sets of
* RGB plus opacity making a grand total of 7 params.
* Usage: .alert-box{ .bg-opacity(0,0,0,255,255,255,.75); }
*/
.bg-opacity (@r1: 0, @g1: 0, @b1:0, @r2: 0, @g2: 0, @b2:0, @opacity: .5) {
// convert RGB to HEX for IE mixin
// notice ~ escaping and ` for JS evaluation
@topHex: ~`((1 << 24) + (@{r1} << 16) + (@{g1} << 8) + @{b1}).toString(16).slice(1)`;
@bottomHex: ~`((1 << 24) + (@{r2} << 16) + (@{g2} << 8) + @{b2}).toString(16).slice(1)`;