Skip to content

Instantly share code, notes, and snippets.

View brownsmith's full-sized avatar

Paul Brownsmith brownsmith

  • Camberley, Surrey
View GitHub Profile
@brownsmith
brownsmith / MUIDataGrid.js
Last active March 14, 2023 09:53
Remove Export button on MUI DataGrid
componentsProps={{
toolbar: {
csvOptions: { disableToolbarButton: true },
printOptions: { disableToolbarButton: true },
},
}}
@brownsmith
brownsmith / reduxNotes.js
Last active March 18, 2020 11:00
Redux action types, actions and action creators
// action type
const orderCardType = 'ORDER_CARD';
// action
const orderCardAction = () => ({
type: orderCardType,
});
// action creator
const orderCardActionCreator = () => dispatch => {
@brownsmith
brownsmith / .zshrc
Created March 28, 2019 11:34
zsh config
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/paulbrownsmith/.oh-my-zsh"
SPACESHIP_PROMPT_ORDER=(
battery # Battery level and status
dir # Current directory section
git # Git section (git_branch + git_status)
@brownsmith
brownsmith / promises.js
Created March 19, 2019 15:16
Promise stuff
function hello(resolve) {
// do whatever
resolve();
}
function hello2(resolve) {
// do whatever
resolve();
}
@brownsmith
brownsmith / blatdocker.sh
Created May 31, 2018 10:10
Delete all docker images
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@brownsmith
brownsmith / super.js
Last active May 30, 2018 13:39
Use of super in React Class constructor
// ES6 class constructors MUST call super if they are subclasses.
// Thus, you have to call super() if you have a constructor.
// A subclass does not have to have a constructor (see #1)
// #1 no need to call super() here as there is no constructor
class MyClass extends React.Component {
render(){
return <div>Hello { this.props.world }</div>;
}
}
@brownsmith
brownsmith / amp.js
Created May 29, 2018 07:28
Classes and composition
// ##### CLASS INHERITANCE:
class GuitarAmp {
constructor ({ cabinet = 'spruce', distortion = '1', volume = '0' } = {}) {
Object.assign(this, {
cabinet, distortion, volume
});
}
}
class BassAmp extends GuitarAmp {
@brownsmith
brownsmith / closure.js
Created May 17, 2018 15:37
Closure notes
function bookSlotByCustId(customerId) {
const custId = customerId
return function bookSlot(slotId) {
//psuedo code here:
dispatch({
apiCall: api.bookSlot(custId, slotId)
});
}
}
@brownsmith
brownsmith / sort.js
Last active May 9, 2018 09:15
Array sorting - returning products in price order
const products = [
{
price: '123',
name: 'cproduct1'
},
{
price: '50',
name: 'bproduct1'
},
{
@brownsmith
brownsmith / prefs.js
Created May 3, 2018 09:49
VSCode prefs
{
"workbench.colorTheme": "One Dark+ (Sublime)",
"eslint.autoFixOnSave": true,
"terminal.integrated.shell.osx": "zsh",
"editor.tabSize": 2,
}