Skip to content

Instantly share code, notes, and snippets.

Avatar
🎼

Jake H 67hz

🎼
View GitHub Profile
@67hz
67hz / opacity.less
Created Nov 14, 2012
Background Opacity with support back to IE7 using LESS CSS
View opacity.less
/* .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)`;
@67hz
67hz / js-closure
Last active Aug 29, 2015
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.
View js-closure
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 / gist:fa626bef810d1fe1024b
Created Sep 15, 2014
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.
View gist:fa626bef810d1fe1024b
var subscribersModel = {
users: [
{
'id': '1asdf',
'activeSubscriptions': ['monthly', 'gold'],
'gender': 'm',
'age': '31',
'username': 'CowboyWayne'
},
{
@67hz
67hz / x86MemoryAddressingModes.md
Last active Mar 4, 2019
x86 Memory Addressing Modes with examples
View x86MemoryAddressingModes.md

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 / find_duplicates_in_unsorted_array.cpp
Last active Apr 13, 2019
passing array as ref to maintain size info in C++
View find_duplicates_in_unsorted_array.cpp
// If std::array is not an option (e.g embedded), use the following tactic to maintain size info of array as param
// This method uses non-type template arguments to retain size of array.
// See std::begin() and std::end() for similar approaches.
#include <iostream>
using namespace std;
// @param h {T} represents highest number in given array
// used to determine size of hash array
@67hz
67hz / finding_duplicates_in_string_using_bitwise_ops.cpp
Created Mar 27, 2019
A simple program to illustrate bitwise masking and merging to determine if a string contains duplicates.
View finding_duplicates_in_string_using_bitwise_ops.cpp
// Simple program to illustrate bitwise ops to check string for duplicates
#include <iostream>
using namespace std;
int main()
{
char * A = new char[20];
cout << "Enter string to be checked for duplicates" << endl;
cin >> A;
@67hz
67hz / main.asm
Created Apr 4, 2019
x86 Assembly: Scanning an array for a non-zero value
View main.asm
; Scanning array for non-zero value
.386
.model flat
.data
;intArray SWORD 0,0,0,0,4,3,0,-34,-56,7,8
intArray SWORD 0,0,0,0,0,0,0,0,0,0,0,0
.code
main proc
@67hz
67hz / erlang_notes.md
Last active Jul 26, 2019
My Erlang Notes circa 2004 with some recent additions
View erlang_notes.md

Erlang

  • let it crash philosophy - supervisors handle actor crashes
    • most common - restart actor with initial state
    • actor recieve messages in mailbox - can be across nodes
  • dynamically typed and strongly typed so no implicit conversion
  • atoms, tuples, pattern-matchingå
  • no true strings
  • atoms can't be garbage collected
  • Some BIFS implemented in C for speed
@67hz
67hz / .ycm_extra_conf.py
Created Feb 28, 2020
Simple ycm_extra_conf.py with gtk support (adjust gtk path as necessary)
View .ycm_extra_conf.py
def Settings( ** kwargs):
return {
'flags': [
'-x',
'c',
'-std=c99',
'-Wall',
'-Wextra',
'-Werror',
'-I/usr/local/Cellar/gtk+3/3.24.14/include/gtk-3.0',
View cc_notes.md