Skip to content

Instantly share code, notes, and snippets.

@daniepetrov
daniepetrov / index.js
Last active November 8, 2019 13:06
How to emulate <br> inside text box in React (the right way)
// Insert the text as you normally would, and fix the line breaks with CSS:
// Don't use dangerouslySetInnerHTML unless you really have to.
const title = "Don't use dangerouslySetInnerHTML \n unless you really \n have to."
const StyledTitle = styled('div')`
white-space: pre-wrap;
`
// And that way you get behavior like if you place <br>'s
@daniepetrov
daniepetrov / gist:1fa5653e2206335073da40ff1ba406d6
Created November 6, 2019 07:58
One liner to stoOne liner to stop / remove all of Docker containers:p / remove all of Docker containers:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@daniepetrov
daniepetrov / .npmrc
Created November 1, 2019 12:52 — forked from ikaruce/.npmrc
.npmrc( proxy and strict-ssl setting )
proxy http://{proxy_server}:{proxy_port}
https-proxy http://{proxy_server}:{proxy_port}
strict-ssl=false
const envConfig = {
development: {
SITE_URL: 'http://localhost:3000',
API_URL: 'http://localhost:3000/api'
},
testing: {
SITE_URL: 'https://test.site.com',
API_URL: 'https://api.test.site.com'
},
production: {
@daniepetrov
daniepetrov / package.json
Created July 8, 2019 15:41
Custom next.js server using Express
"scripts": {
"dev": "node server.js",
"start": "NODE_ENV=production node server.js",
"build": "next build",
}
function importAll(r) {
const images = {}
r.keys().map(item => {
images[item.replace('./', '')] = r(item)
return null
})
return images
}
const images = importAll(require.context('./images', false, /\.(png|jpe?g|svg)$/))

The apt-get version of node is incredibly old, and installing a new copy is a bit of a runaround.

So here's how you can use NVM to quickly get a fresh copy of Node on your new Bash on Windows install

$ touch ~/.bashrc
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
// restart bash
$ nvm install node
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"baseUrl": ".",
"paths": {
"common/*": ["./src/common/*"],
"core/*": ["./src/core/*"]
}
},
@daniepetrov
daniepetrov / gist:e312e0f63547675326b53433dafeaa01
Created August 19, 2018 20:24 — forked from vargeorge/gist:8b20488b7d7b6c101b4b
Show full path on OS X terminal / iTerm before the $ prompt
1. Edit ~/.bash_profile and add the following line to show full path before the $ prompt.
For example, as user@hostname:path/to/directory$
# show path before the $ prompt
export PS1='\u@\H:\w$ '
2. Save file and restart terminal or run source command
$ source ~/.bash_profile
toggleSubMenu = menuItem => e => {
this.setState((state, props) => {
return {
...state,
[menuItem]: true
}
});
}