Skip to content

Instantly share code, notes, and snippets.

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

Erica Edge duggiemitchell

🏠
Working from home
View GitHub Profile
@duggiemitchell
duggiemitchell / removeArrItem.js
Created July 18, 2023 17:15
immutably remove an item from a list
// source list
const theList = [{id: 'foo'}, {id: 'bar'},{id: 'bazzle'} ];
// the item to remove
const item = {id: 'foo'};
// get the item's index from soure list
const indx = theList.findIndex(v => v.id === item.id)
// function to remove
@duggiemitchell
duggiemitchell / userAcceessLevel.ts
Last active June 30, 2022 17:43
Typscript UserAccessLevel
enum UserAccessLevel {
READ = 1,
READ_WRITE = 2,
ADMIN = 3,
CO_OWNER = 4,
}
type Foo = {
[key in UserAccessLevel]:
| 'Read-only'
| 'Read/Write'
@duggiemitchell
duggiemitchell / example-eslintrc.json
Created February 2, 2022 18:54
Favorite eslint config
{
"parser": "@typescript-eslint/parser",
"env": {
"browser": true,
"es2021": true,
"node": true
},
"parserOptions": {"ecmaVersion": 2020},
"plugins": ["@typescript-eslint/eslint-plugin", "import"],
"extends": [

Keybase proof

I hereby claim:

  • I am duggiemitchell on github.
  • I am duggiemitchell (https://keybase.io/duggiemitchell) on keybase.
  • I have a public key ASD5q6Mw3W2nH6hb64b5eFkJ4zQN1vzVZPS-yq9PiFMWvAo

To claim this, I am signing this object:

@duggiemitchell
duggiemitchell / timer-class.jsx
Last active September 9, 2019 14:41
Timer component written as a class
class Timer extends React.Component {
constructor(props) {
super(props);
this.state = { seconds: 0 };
}
tick = () => {
this.setState(state => ({
seconds: state.seconds + 1
}));

Keybase proof

I hereby claim:

  • I am duggiemitchell on github.
  • I am duggie (https://keybase.io/duggie) on keybase.
  • I have a public key ASDGFLQpZPxDM2R8W_GkMM5jFUQCkFo2fibBo-1BDUHiHQo

To claim this, I am signing this object:

@duggiemitchell
duggiemitchell / MusicPreferences.tsx
Last active March 1, 2019 17:08
Stateful component called as a list that highlights to a random color on selection.
type Props = {
navigation: NavigationScreenProp<NavigationParams>;
};
type State = {
musicPreferences: any;
};
export class MusicPreferencesScreen extends React.Component<Props, State> {
static navigationOptions = ({}) => {
// Write JavaScript here and press Ctrl+Enter to execute
const Card = (props) => {
return (
<div style={{margin: '1em'}}>
<img style={{width: 75}} src={props.avatar_url} />
<div style={{display: 'inline-block', marginLeft: 10}}>
<div style={{fontSize: '1.25em', fontWeight: 'bold'}}>
{props.name}
</div>
@duggiemitchell
duggiemitchell / CounterApp.jsx
Created October 26, 2017 14:55
Example Counter Component in React
class Button extends React.Component {
handleClick = () => {
this.props.onClickFn(this.props.incrementValue)
}
render() {
return (
<button onClick={this.handleClick}>
@duggiemitchell
duggiemitchell / simple-promise.md
Last active May 10, 2017 14:48
Simplest example of a promise
let promiseToClean = new Promise(function( resolve, reject) { 
  // cleaning the room 
  
  let isClean = false;
  
  if (isClean){
    resolve('Clean');
  } else {
 reject('not Clean');