This file contains 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
/* | |
Sometimes we only want to run an effect the very first time the component mounts. | |
In my experience, the majority of these times have been firing off a tracking event. | |
Usually I’ll maintain a hasSent local variable that I flip from false to true after I’ve sent it the first time. | |
*/ | |
import { useRef, useEffect } from 'react' | |
const useInitialMount = () => { | |
// refs exist across component re-renders, so | |
// we can use it to store a value for the |
This file contains 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
function useTraceUpdate(props) { | |
const prev = useRef(props); | |
useEffect(() => { | |
const changedProps = Object.entries(props).reduce((ps, [k, v]) => { | |
if (prev.current[k] !== v) { | |
ps[k] = [prev.current[k], v]; | |
} | |
return ps; | |
}, {}); |
This file contains 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
SELECT REGEXP_REPLACE('b.ol.aj.i+fafd@gmail.com', '(?!@)\+\w*|(?<!@gmail)\.', '', 'g'), 'b.ol.aj.i+fafd@gmail.com' as email; |
This file contains 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
{ | |
"scripts": { | |
"start": "babel-node $1" | |
} | |
} | |
// with this you can run the user microservice with `npm run start user.js` or `yarn start user.js` | |
// and the music service with `npm run start music.js` or `yarn start music.js` | |
// i think you can even exclude the `.js`, it should be smart enough t pick the file. |
This file contains 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
help: ## Display this help section | |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-38s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
This file contains 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
- addons.js | |
- config.js | |
- webpack.config.js |
This file contains 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
const fizzBuzz = i => ({ | |
truefalse : 'Fizz', | |
falsetrue : 'Buzz', | |
truetrue : 'FizzBuzz', | |
}[(i % 3 == 0) + '' + (i % 5 == 0)] || i) |
This file contains 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
var downloadAsCSV = function (arr, filename) { | |
csvRows = []; | |
for (var i = 0, l = arr.length; i < l; i++) { | |
csvRows.push(arr[i].join('#')); | |
} | |
var csvString = csvRows.join('%0A'); | |
csvString = csvString.replace(/ /g, '__'); | |
var a = document.createElement('a'); |
This file contains 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
{ | |
"workbench.colorTheme": "Min Dark", | |
"python.formatting.provider": "none", | |
"editor.lineHeight": 25, | |
"editor.letterSpacing": 0.5, | |
"files.trimTrailingWhitespace": true, | |
"editor.renderWhitespace": "all", | |
"workbench.iconTheme": "material-icon-theme", | |
"editor.fontSize": 14, | |
"workbench.sideBar.location": "left", |
This file contains 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 Sequelize from 'sequelize'; | |
const { | |
Op, | |
col: sequelizeCol, | |
cast: sequelizeCast | |
} = Sequelize; | |
// http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html#static-method-cast | |
const valueCast = sequelizeCast(sequelizeCol('value'), 'int'); |