Skip to content

Instantly share code, notes, and snippets.

View inPhoenix's full-sized avatar
🏠
Working from home

inPhoenix inPhoenix

🏠
Working from home
View GitHub Profile
@inPhoenix
inPhoenix / gist:7a169736d7d58d04a0b3934bc806050a
Created January 25, 2023 21:05
Explanation about ^ on the node_modules package versions
Having the ^ character in front of the version number indicates that any version that is compatible with the specified version can be used. So, if you have "example-package": "^1.0.1" in your package.json file and you run npm install, npm will install the latest version of "example-package" that is compatible with version 1.0.1. This includes patch versions (e.g. 1.0.2, 1.0.3) and any new minor versions that starts with 1.0 (e.g. 1.0.x) but not new major versions (e.g. 2.0.0).
The package-lock.json file will not prevent having patched versions installed when the value of "example-package" is with the ^ on package.json.
----------------------------------------------------------------------------------------------------
When you run npm install command, npm will look at the version specified in the package.json file and install the latest version of the package that is compatible with the version specified in the package.json, disregarding the version specified in the package-lock.json.
If you have "example
@inPhoenix
inPhoenix / gitCommitEmojiCyberpunk.md
Last active January 15, 2023 17:39
Git Commit Messages Emoji Cyberpunk
Commit type Emoji
Initial commit 🌃 :night_with_stars:
Version tag 🌄 unrise_over_mountains
New feature 🌇 :city_sunrise:
Bugfix 🚊 :tram:
Documentation 🚉 :station:
Performance 🚟 :suspension_railway:
Cosmetic 👾 :space_invader:
Tests 🌉 :bridge_at_night:
@inPhoenix
inPhoenix / configPhpStormCustomImport.md
Last active June 1, 2019 18:47
PhpStorm / WebStorm Custom Import Paths
@inPhoenix
inPhoenix / ShowHide.jsx
Created December 8, 2018 09:19
React Spring super simple example
import React, { Component } from 'react'
import { Spring } from 'react-spring'
class ShowHide extends Component {
state = {
opacity: 0
}
onHover = () => {
this.setState(prevState => ({
@inPhoenix
inPhoenix / ReactHooks.js
Last active December 29, 2018 11:41
React Hook Simple Example
// https://daveceddia.com/intro-to-hooks/
import React, { useState } from 'react';
import { render } from 'react-dom';
function OneTimeButton(props) {
const [clicked, setClicked] = useState(true) // setClicked update the clicked state.
function clickedTest() {
props.onClick()
setClicked(!clicked)
@inPhoenix
inPhoenix / gist:a109a630b34c975018773f479754a2f9
Created August 8, 2018 20:34
cache array.find on long list example
const nodes = [
{ id:"abc", content:"Lorem ipsum"},
{ id:"def", content:"Dolor sit" },
// ...
];
const keyedNodes = {}
const getNode = id => {
if (!keyedNodes[id]) {
@inPhoenix
inPhoenix / isEmpty
Last active February 28, 2024 16:36
Alternative to lodash _.isEmpty
const isEmpty = value => {
return (
value == null || // From standard.js: Always use === - but obj == null is allowed to check null || undefined
(typeof value === 'object' && Object.keys(value).length === 0) ||
(typeof value === 'string' && value.trim().length === 0)
)
}
export default isEmpty
@inPhoenix
inPhoenix / consoleLog.txt
Created June 8, 2018 15:54
Customised Console Log
console.log('%c つ ◕_◕ ༽つ' $START$, 'background: white; color: red;', $START$)
@inPhoenix
inPhoenix / AutoBindArrow
Last active December 1, 2018 11:01
React ES6 stage2 autobinding Arrow Function with parameters
// Example using create-react-app.
// For scratch configurations, add babel-plugin-transform-class-properties.
// More info: https://babeljs.io/docs/plugins/transform-class-properties/
import React from 'react'
class Example extends React.Component {
example = (param) => () => {
console.log('Hello ', param)
}
@inPhoenix
inPhoenix / render callback to get window size
Last active January 23, 2019 15:32
Get the Window Size for React Render using (Render callback / function as a Child / render props / props.children as a function) pattern
// https://medium.com/@martin_hotell/react-children-composition-patterns-with-typescript-56dfc8923c64
// https://www.robinwieruch.de/react-render-props-pattern/
// https://www.youtube.com/watch?v=AiJ8tRRH0f8
// https://www.youtube.com/watch?v=BcVAq3YFiuc
constructor () {
this.state = {
width: 0,
...
}
}