Skip to content

Instantly share code, notes, and snippets.

View victorbruce's full-sized avatar
👨‍💻
focused

Victor Bruce victorbruce

👨‍💻
focused
View GitHub Profile
@victorbruce
victorbruce / index.tsx
Created October 25, 2022 09:08
using redux in a component
import {useAppSelector, useAppDispatch} from "hooks"
import {selectNotes, removeNote} from "slice"
const HomePage = (): JSX.Element => {
const notes = useAppSelector(selectNotes);
const dispatch = useAppDispatch();
const deleteNote = (noteId: string) => {
dispatch(removeNote(noteId))
}
@victorbruce
victorbruce / store-update.ts
Created October 25, 2022 08:24
adding a reducer to a store
import { configureStore } from "@reduxjs/toolkit"
import noteReducer from "slice"
export const store = configureStore({
reducer: {
notes: noteReducer
}
})
export type RootState = ReturnType<typeof store.getState>
import {TypedUseSelectorHook, useDispatch, useSelector} from "react-redux"
import type {RootState, AppDispatch} from "store"
// use throughout your app instead of useDispatch and useSelector
export const useAppDispatch: () => AppDispatch = useDispatch
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
@victorbruce
victorbruce / store.ts
Created October 24, 2022 09:05
Configuring a Redux store.
import { configureStore } from "@reduxjs/toolkit"
export const store = configureStore({
reducer: {
// reference reducers here
}
})
// create types for state and dispatch
export type RootState = ReturnType<typeof store.getState>
@victorbruce
victorbruce / .prettier.json
Created July 5, 2022 17:35
basic prettier rules to ensure consistent code formatting
{
"trailingComma": "es5",
"bracketSpacing": true,
"printWidth": 80,
"tabWidth": 2,
"singleQuote": true,
"arrowParens": "always"
}
@victorbruce
victorbruce / package.json
Created October 19, 2021 04:30
a script to bump either the major, minor, or patch number
"scripts": {
"bump-patch": "npm version patch --no-git-tag-version && bundle exec fastlane bump",
"bump-minor": "npm version minor --no-git-tag-version && bundle exec fastlane bump",
"bump-major": "npm version major --no-git-tag-version && bundle exec fastlane bump"
}
@victorbruce
victorbruce / decrypting.yml
Created October 19, 2021 04:28
decrypting a secret in Github action workflow
- name: Decrypting
run: sh ./.github/scripts/decrypt.sh
env:
KEYS_KEYSTORE_PASSPHRASE: ${{secrets.KEYS_KEYSTORE_PASSPHRASE}}
- name: Make fastlane/keys.properties executable
run: |
chmod +x fastlane/keys.properties
- name: Dump fastlane/keys.properties into .env file
run: |
cat fastlane/keys.properties > fastlane/.env
@victorbruce
victorbruce / cd.yml
Created October 19, 2021 04:25
workflow to deploy code and tag each release
jobs:
build-production:
runs-on: macos-latest
steps:
- name: Checkout Repository in Github VM
uses: actions/checkout@v2
- name: Run Node in Github VM
uses: actions/setup-node@master
- name: Install Dependencies
@victorbruce
victorbruce / decrypt-encrypted-files.sh
Created October 19, 2021 04:23
A script to decrypt encrypted files
#!/bin/sh
# Decrypt the file
# --batch to prevent interactive command
# --yes to assume "yes" for questions
gpg --quiet --batch --yes --decrypt --passphrase="$KEYS_KEYSTORE_PASSPHRASE" \
--output android/app/release-key.keystore android/app/release-key.keystore.gpg
gpg --quiet --batch --yes --decrypt --passphrase="$KEYS_KEYSTORE_PASSPHRASE" \
@victorbruce
victorbruce / deploy-to-firebase-app-distribution.yml
Created October 19, 2021 04:19
Github action to deploy a react native application to firebase app distribution
name: Deploy To Firebase App Distribution And Bump Tag Version
on:
push:
branches: [master]
jobs:
build-production:
runs-on: macos-latest