This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "./styles.css"; | |
// Memorize this function! Be able to transform an array of objects into | |
// a normalized object based on a key. Looking up an item in an array is a O(n) | |
// operation if you don't know the item's index. If you know a value on the | |
// item, and that value is unique, you can create an index based on that value | |
// to enable you to do O(1) look ups | |
const indexArrayBy = key => array => { | |
return array.reduce((acc, cur) => { | |
acc[cur[key]] = cur; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( $('#haven').length > 0 ) { | |
// do stuff here | |
} else { | |
console.log( 'wtf, why??' ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Oh shit, I did something terribly wrong, please tell me git has a magic time machine!?! | |
`git reflog` | |
### you will see a list of every thing you've done in git, across all branches! | |
### Each one has an index HEAD@{index} find the one before you broke everything. | |
`git reset HEAD@{index}` | |
### magic time machine` | |
## Oh shit, I committed and immediately realized I need to make one small change! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Path Variable | |
<?php $imgBasePath = "//cdn.4patriots.com/img"; ?> | |
//UseCase | |
<img src="//cdn.4patriots.com/img/food/prepared/beef-broccoli-rice-legacy.jpg" alt="Protein Kit Beef"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a * (b + c) // grouping | |
person.age // member | |
person[age] // member | |
!(a == b) // logical not | |
a != b // not equal | |
typeof a // type (number, object, function...) | |
x << 2 x >> 3 // minary shifting | |
a = b // assignment | |
a == b // equals | |
a != b // unequal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* all elements | |
div all div tags | |
div,p all divs and paragraphs | |
div p paragraphs inside divs | |
div > p all p tags, one level deep in div | |
div + p p tags immediately after div | |
div ~ p p tags preceded by div | |
.classname all elements with class | |
#idname element with ID | |
div.classname divs with certain classname |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Force HTTPS | |
RewriteEngine on | |
RewriteCond %{HTTPS} !on | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} | |
Force www | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^htmlg\.com [NC] | |
RewriteRule ^(.*)$ http://www.htmlg.com/$1 [L,R=301,NC] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RegEx | |
/regex/g global - matches all | |
. is a wildcard | |
\ escape | |
" " space is a character | |
\t Tabs | |
\r. \n, \r\n new line | |
\u unicode |