Skip to content

Instantly share code, notes, and snippets.

View psenger's full-sized avatar
:octocat:
Makin Bacon

Philip A Senger psenger

:octocat:
Makin Bacon
View GitHub Profile
@psenger
psenger / mysql_cheat_sheet.md
Last active October 18, 2020 02:49 — forked from bradtraversy/mysql_cheat_sheet.md
[MySQL Cheat Sheet] #MySQL

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@psenger
psenger / addition_difference.js
Last active August 9, 2021 01:38
[Tricks in JavaScript] #JavaScript
// not sure I understand this
let a=1, b=2;
a = a+b;
b = a-b;
a = a-b;
@psenger
psenger / curry.js
Created October 20, 2020 22:18
[Curry] #JavaScript
const curry = function curry(func) {
return function curried(...args) {
if (args.length >= func.length) {
return func.apply(this, args);
} else {
return function(...args2) {
return curried.apply(this, args.concat(args2));
}
}
};
@psenger
psenger / index.js
Created October 20, 2020 22:45
[Proxy] #JavaScript
const target = {};
const handler = {
get: (tar, prop) => {
console.log('get',tar, prop)
return tar[prop];
},
set: (tar, prop, val) => {
console.log('set', tar, prop, val);
tar[prop] = val;
},
@psenger
psenger / index.js
Last active October 29, 2020 22:32
[React useState / useEffect] #ReactJs #JavaScript
/**
* Use a useEffect for a single purpose
**/
function App() {
const [varA, setVarA] = useVarA();
const [varB, setVarB] = useVarB();
return (
<span>
@psenger
psenger / README.md
Last active October 22, 2020 03:45
[Specificity] #css

Specificity Hierarchy

There are four categories defining the level of specificity.

  1. Inline styles - An inline style is attached directly to the element. EG. <h1 style="color: #ffffff;">.
  2. IDs - An element ID is a unique identifier for an element in a DOM. EG. #navbar.
  3. Classes, attributes and pseudo-classes - This category includes .classes, [attributes] and pseudo-classes like :hover, :focus etc.
  4. Elements and pseudo-elements - This category includes element names and pseudo-elements, such as h1, div, :before and :after.

Specificity Calculatation

@psenger
psenger / JQuery-Cheet-Sheet.md
Last active August 13, 2022 12:58
[JQuery Cheat Sheet] #Jquery
@psenger
psenger / binding-error.js
Last active October 27, 2020 03:46
[Arrow Functions, Use When Appropriate] #JavaScript
let sad = {
data: '"Wazzzzzzup"',
// As you can see this is a Arrow funciton
sayGoGo: () => {
console.log(`Mr Monkey says ${this.data}`);
}
};
// This will NOT work. `this` ( the context )
@psenger
psenger / Bucket_with_two_Items_sorted_to_appear_at_the_top_of_the_list.js
Last active May 21, 2025 23:49
[Bucketize / Count Occurrences / Group / Separate an array of objects by a value as defined by the attribute, Ways to Sort] #JavaScript #Array #bucket #groupBy #collect #bag #counter
// Buckets of Data, with two Items appearing at the top of the list.
// note that OOO and AAA are at the top, whilst everything else is sorted
// Desired outcome:
// -------------------------------------------------------------------------------------------------
// OOO [ { type: 'OOO', attributes: {} }, { type: 'OOO', attributes: {} } ]
// AAA [ { type: 'AAA', attributes: {} } ]
// BBB [ { type: 'BBB', attributes: {} }, { type: 'BBB', attributes: {} } ]
// ZZZ [ { type: 'ZZZ', attributes: {} }, { type: 'ZZZ', attributes: {} } ]
const desiredFirstItem = 'OOO'
@psenger
psenger / index.js
Last active October 29, 2020 22:04
[Create an Index Object from an Array of values, based on a passed attribute's value] #JavaScript #Array
// Creates a Dictionary / Index Object for all the objects based on the passed attribute value.
/**
* Create an object with keys based on a passed attribute within the array of values
* @param {[*]} objects - array of objects
* @param {string} attributeName - the attribute name
* @return {*}
*/
var indexByAttribute = function indexByAttribute ( objects, attributeName ) {
return (objects||[])