Skip to content

Instantly share code, notes, and snippets.

View d3lm's full-sized avatar
💻
Coding

Dominic Elm d3lm

💻
Coding
View GitHub Profile
function isElementInViewport(el) {
let rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}
@d3lm
d3lm / webpack.config.js
Created July 16, 2016 07:07
Phenomic Webpack Config
import path from "path"
import webpack from "webpack"
import ExtractTextPlugin from "extract-text-webpack-plugin"
import pkg from "./package.json"
// note that this webpack file is exporting a "makeConfig" function
// which is used for phenomic to build dynamic configuration based on your needs
// see the end of the file if you want to export a default config
@d3lm
d3lm / .git-functions.sh
Last active January 26, 2018 10:59
Git workflow to checkout or update pull requests
show_branch() {
echo $(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/')
}
update_pr() {
CURRENT_BRANCH=$(show_branch)
IFS='/' read -ra array <<< "$CURRENT_BRANCH"
PR_ID=${array[1]}
if [ "${array[0]}" != "pr" ]
@d3lm
d3lm / hyper.js
Last active March 21, 2018 14:26
Hyper Configuration
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
paneNavigation: {
indicatorPrefix: '⌥',
hotkeys: {
navigation: {

Array<T>

Legend:

  • ✏️ method changes this.
  • 🔒 method does not change this.

Array<T>.prototype.*:

  • concat(...items: Array: T[] 🔒 ES3
@d3lm
d3lm / ng-let.directive.ts
Created August 24, 2018 06:07
*ngLet Directive
import { Directive, Input, TemplateRef, ViewContainerRef, OnInit } from '@angular/core';
export class NgLetContext {
$implicit: any = null;
ngLet: any = null;
}
@Directive({
selector: '[ngLet]'
})
@d3lm
d3lm / op.py
Last active August 7, 2019 13:10
class Operation():
def __init__(self, input_nodes=None):
self.input_nodes = input_nodes
self.output = None
# Append operation to the list of operations of the default graph
_default_graph.operations.append(self)
def forward(self):
pass
class add(BinaryOperation):
"""
Computes a + b, element-wise
"""
def forward(self, a, b):
return a + b
def backward(self, upstream_grad):
raise NotImplementedError
@d3lm
d3lm / graph.py
Last active August 7, 2019 13:10
class Graph():
def __init__(self):
self.operations = []
self.placeholders = []
self.variables = []
self.constants = []
def as_default(self):
global _default_graph
_default_graph = self
@d3lm
d3lm / constant.py
Last active August 7, 2019 13:09
class Constant():
def __init__(self, value=None):
self.__value = value
_default_graph.constants.append(self)
@property
def value(self):
return self.__value
@value.setter