Skip to content

Instantly share code, notes, and snippets.

View gmmorris's full-sized avatar

Gidi Meir Morris gmmorris

View GitHub Profile
@gmmorris
gmmorris / index.html
Created February 5, 2014 23:59
Logo Image Replacement
<h1 class="ir-logo">
<span>My Site</span>
</h1>
@gmmorris
gmmorris / .bash_profile
Last active April 11, 2020 10:24
My .bash_profile file
# Add ll like linux
alias ll='ls -l'
# type 'srv' in any folder to open a web browser and chrome
alias srv='python -m SimpleHTTPServer 8000'
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
@gmmorris
gmmorris / index.html
Last active August 29, 2015 13:56 — forked from webapprentice/tutorial_39_example_1.html
Small snippet for a fullscreen mode utility
<div id='container'>
<img src='assets/slideshow_3.png' id='myimage' />
</div>
<p style='text-align: center'>
Click the image to expand - Hit the ESC key to collapse
</p>
<style type="text/css">
@gmmorris
gmmorris / dom_for_selectors.html
Created July 26, 2015 15:00
Example for article on Medium.com about Simmerjs
<div id="new_panel">
<div>
Lorem ipsum...
</div>
<div class="blurb">
<div>
Lorem ipsum...
<div>
<em>This is what we're doing!</em>
</div>
@gmmorris
gmmorris / Document level ommunication
Created August 29, 2015 14:39
Gists for my article on the LH rewrite
var StateController = new function(){
this.GetState = function(){
$(document).trigger('navestate:giveMeTheState',this)
};
this.hereYouGo = function(navState){
// Do something with navState
};
};
var NavState = new function(){
@gmmorris
gmmorris / hof.js
Last active November 1, 2015 15:17
An example of a higher order function for my How to Grok a Higher Order Class article
// Our higher order function which converts pennies to pounds (£) (or cents to dollars, for that matter)
function convertPenniesToPounds(priceFunction) {
return function() {
return priceFunction.apply(this, arguments)/100;
}
}
// we have component which fetches a price in pennies
const PriceFetcher = {
getPriceInPence : function(productId) {
@gmmorris
gmmorris / chof.js
Created November 1, 2015 15:17
An example of a composer higher order function for my How to Grok a Higher Order Class article
// Our higher order function which logs all returned values to the function properties on an object
function attachLogger(objectOrFunction) {
if(typeof objectOrFunction === 'function'){
return function() {
let ret = objectOrFunction.apply(this, arguments);
console.log(ret);
return ret;
}
}
@gmmorris
gmmorris / composers_factory.js
Last active November 1, 2015 16:47
An example of a composer factory for my How to Grok a Higher Order Class article
const FactorySentinal = Symbol('ClassFactory');
export function isFactory(SupposedFactory) {
return SupposedFactory && SupposedFactory[FactorySentinal];
}
export default function(methodComposer) {
return ClassToCompose => {
const proto = ClassToCompose.prototype;
function factory() {
const instance = new ClassToCompose(...arguments);
@gmmorris
gmmorris / constructor_function_syntax.js
Created November 1, 2015 16:18
An example of a misuse of a Constructor Function for my How to Grok a Higher Order Class article
function MyConstructor() {
}
// meant to be called this way:
var myInstance = new MyConstructor();
// but could also be called, usually incorrectly, this way
var myInstance = MyConstructor();
@gmmorris
gmmorris / extend_constructor_composer.js
Last active November 1, 2015 16:46
An example of a Constructor Composer for my How to Grok a Higher Order Class article
export default function(methodComposer) {
return ClassToCompose => {
const proto = ClassToCompose.prototype;
return class extends ClassToCompose {
constructor() {
super(...arguments);
for (const prop of Object.getOwnPropertyNames(proto)) {
const method = proto[prop];
const {configurable, writable} = Object.getOwnPropertyDescriptor(proto, prop);