Skip to content

Instantly share code, notes, and snippets.

View krfong916's full-sized avatar
Do your job

Big Dog Lil Dog krfong916

Do your job
  • University of California, Santa Cruz
View GitHub Profile
@krfong916
krfong916 / custom-fns.js
Created January 22, 2020 00:50
A list of all the custom util functions I've created
function callAll(...functions) {
return function(...args) {
functions.forEach(function(fn) {
fn(...args)
})
}
}
function pluck(property, obj) {
return Object.keys(obj).reduce((temp, key) => {

The Fundamentals

box-shadows

  • Soft inset: box-shadow: inset 0 2px 4px 0 hsla(0,0%,0%,.2)
  • Transparent: box-shadow: inset 0 0 0 1px hsla(0,0%,0%,.1)
  • Soft shadow 1: box-shadow: 0 1px 3px hsla(0, 0%, 0%, 0.2), 0 4px 12px rgba(0, 0, 0, 0.08);
  • Soft shadow 2: box-shadow: 0 5px 15px 0 hsla(0,0%,0%,0.15)

position basics

  • By default, all elements are position:static. This means the element will be positioned according to the order in the HTML structure.
@krfong916
krfong916 / git-commands.md
Last active January 12, 2020 12:09
Git commands

Change remote url

git remote set-url origin new.git.url/here

Migrating code to new repo

  • Create github repo
  • git remote set-url origin new.git.url/here
  • git init in repo to migrate
  • Prune/Cleanup the local references to remote branch
    • show branches to prune: git remote prune origin --dry-run
  • prune all branches: git remote prune origin
@krfong916
krfong916 / ddd.md
Last active February 5, 2025 21:35
Notes on Clean, MVC, and DDD

DDD and Object Oriented: Concepts, Analysis, Heuristics

Points

Why do we move logic from a controller?

If we make a change, like add a property to the domain model, we have to make the same change for every use case of that model, and there could be n more use cases. We would also add m validations for that property - so one change could result in n x m changes.

What roles do factories play? What do we put in them? When do we use them?

var dfs = {
result: function(){
return {
test: []
}
},
setup: function() {
var test1 = this.result()
test1.test.push('a');
this.modify(test1)
import java.util.Scanner;
class Fibonacci {
/**
* We can represent the fibonacci sequence as an array
*/
int fibIterative (int n) {
// we define the size of array as n+2 to accomodate the base cases, f[0] & f[1]

Scope and closure

What is scope?

Scope is the set of rules that determines how to locate a variable identifier and assign it a value

Compiler theory

How is code compiled? There are a few phases

  • Tokenizing: characters are broken into chunks - tokens
  • Lexing: when the tokenizer invokes the stateful parser rules to figure out whether a chunk is a distinct token or part of another token
  • Parsing: we build an Abstract Syntax Tree (AST) from a stream of tokens. The AST represents a structure of a program. For instance: the top-level node called a program and the children nodes could be a variable declarations and function declarations. The variable declarations have children nodes that describe properties of the variable.

This, objects, and es6 classes

Summary

In this document, we will cover the this keyword, object prototypes, uses of .call() and .apply(), lexical this, arrow functions, es6 classes, object behavior delegation, some class theory, and objects-linking-other-objects. Our motivation is to learn these concepts is that we must know the finer points of object creation, assignment of values, and behavior delegation in order to better understand Javascript.

This

The this keyword is a special mechanism in Javascript - it allows us to implicitly pass reference values to other objects. It is a source of frustration for many developer's, but it's not as complicated as they make it out to be. In this section, we'll cover the this keyword, how it functions, why it's useful, and how it can help us write more expressive code.
     this has nothing to do with where a function is declared, but everything to do with how a function is called. When a function is invoked, an act

@krfong916
krfong916 / component-creation-react.js
Created May 31, 2019 21:08
A document detailing the tradeoffs we make in each of the ways that we can create components in React
// Component class
class Car extends Component {
constructor ( props ) {
super();
this.propertyA = this.propertyA.bind( this );
this.propertyB = this.propertyB.bind( this );
}
}
class ShoppingItem extends Component {
@krfong916
krfong916 / heap.js
Last active March 10, 2019 01:57
Implementation of a min-heap and heapsort
var MinHeap = {
_rootLevel: 1,
init: function() {
this.arr = []
this.level = this._rootLevel
},
insert: function(value) {
this.arr[this.level] = value
this._bubbleUp(this.level)
},