Skip to content

Instantly share code, notes, and snippets.

View CoryKelly's full-sized avatar
👾
Learning new stuff

Cory Kelly CoryKelly

👾
Learning new stuff
  • 4Patriots
  • Nashville, TN
View GitHub Profile
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;
if ( $('#haven').length > 0 ) {
// do stuff here
} else {
console.log( 'wtf, why??' );
}
@CoryKelly
CoryKelly / OhShitGit
Last active October 28, 2023 15:19
Git is hard: screwing up is easy, and figuring out how to fix your mistakes is fucking impossible. So here are some bad situations I've gotten myself into, and how I eventually got myself out of them in plain english
## 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!
//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">
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
* 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
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]
RegEx
/regex/g global - matches all
. is a wildcard
\ escape
" " space is a character
\t Tabs
\r. \n, \r\n new line
\u unicode