Skip to content

Instantly share code, notes, and snippets.

View jittdev's full-sized avatar

Subrosa Games LLC jittdev

View GitHub Profile
@jittdev
jittdev / table_of_contents.md
Created March 14, 2023 16:11
gist Table of Contents
@jittdev
jittdev / LoadingScriptsAsynchronously1.txt
Created March 14, 2023 13:59
loading scripts asynchronously :: #ALGORITHMS
to speed up html page load
<script async> #as long as the script doesn't affect the DOM
<script defer> #waits as long as it takes for the html to load (third party script that aren't that important)
Critical Render Path loading: HTML -> CSS -> Javascript, and JS can pause finishing of html if not careful
//testing sites
@jittdev
jittdev / OptimizingMediaAttributes&Specificity1.txt
Created March 14, 2023 13:59
optimizing media attributes & specificity :: #ALGORITHMS
// if you only need media for certain screen sizes:
<link rel="stylesheet" href:"./style2.css" media="only screen and (min-width:500px)">
// so, at a minimum width of 500px, browser will load the style2.css
// and with CSS specificity can slow stuff down:
/* bad */
.header .nav .item .link a.important {
@jittdev
jittdev / LoadingCssAfterTheFold1.js
Created March 14, 2023 13:59
loading css after the fold :: #ALGORITHMS
<script type="text/javascript">
const loadStyleSheet = src => {
if(document.createStyleSheet) {
document.createStyleSheet(src)
} else {
const stylesheet = document.createElement('link');
stylesheet.href = src;
stylesheet.type = 'text/css';
stylesheet.rel = 'stylesheet';
document.getElementsByTagName('head')[0].appendChild(stylesheet)
@jittdev
jittdev / InsteadOfNestedForLoops(N^2)...1.js
Created March 14, 2023 13:59
Instead of nested for loops (n^2)... :: #ALGORITHMS
const array1 = ['a', 'c', 'g', 'x']
const array2 = ['z', 'y', 'a']
// Naive
function hasPairWithSum(arr, sum) {
var len = arr.length;
for(var i =0; i<len-1; i_++){
for (var j = i+1; j<len; j++){
if (arr[i] + arr[j] === sum)
return true;
@jittdev
jittdev / GoogleInterviewQuestion1.yaml
Created March 14, 2023 13:59
Google Interview Question :: #ALGORITHMS
find matching pair that equals a sum from a collection of numbers
[1,2,3,9] Sum =8
[1,2,4,4] Sum =8
how are these numbers given: memory/array?
repeating elements? can i repeat the same element? --same number might occur twice
are these integers or floats -- ints
can they be negative -- Yes
are they sorted? -- yes
@jittdev
jittdev / Algorithms1.txt
Created March 14, 2023 13:59
Algorithms :: #ALGORITHMS
Sorting
Dynamic Programming
BFS + DFS (Searching)
Recursion
@jittdev
jittdev / DataStructures1.txt
Created March 14, 2023 13:59
Data Structures :: #ALGORITHMS
Arrays
Stacks
Queues
Linked Lists
Trees
Tries
Graphs
Hash Tables
@jittdev
jittdev / 3PillarsOfProgramming1.txt
Created March 14, 2023 13:59
3 Pillars of Programming :: #ALGORITHMS
1. Readable
2. Scalable Speed: Time Complexity = Big O
3. Scalable Memory: Space Complexity) = Big O
All three have trade-offs.
@jittdev
jittdev / BigONotation1.js
Created March 14, 2023 13:59
Big O Notation :: #ALGORITHMS
// Rules:
//1: Worst Case
//2: Remove Constants
//3: Different terms for inputs
//4: Drop Non Dominant terms (n's) => 0(x^2+3x+100+x/2) becomes 0(x^2)
function doSomething(array1, array2) {
array1.forEach(function(array1) {
console.log(array1);
})