Skip to content

Commit

Permalink
Aug 2022: merge Google Sheets
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsoderlund committed Aug 9, 2022
1 parent aaa3e29 commit a91998a
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 170 deletions.
124 changes: 77 additions & 47 deletions Development/Apps/React Native.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,48 @@ Templates:

### Nice-to-have’s after basic setup

Official TS Tabs template:

mkdir assets
mkdir -p components/__tests__
mkdir constants
mkdir hooks
mkdir navigation
mkdir screens

Tom’s:

mkdir assets
mkdir -p components/__tests__
mkdir -p components/common
mkdir -p components/navigators
mkdir -p components/screens/StartScreen
mkdir screens
mkdir -p screens/StartScreen
touch screens/StartScreen/index.js
mkdir navigation
mkdir hooks
mkdir lib
mkdir config
touch config/config.js
mkdir types

#### Install useful packages

yarn add standard --dev
expo install expo-font
yarn add @react-navigation/native

### Installing packages

NOTE: use `expo install` primarily (rather than yarn/npm), e.g:

expo install react-native-maps
expo install expo-location
expo install react-native-svg

Managed:
expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view

https://docs.expo.dev/ui-programming/react-native-toast/

### New React Native project with Next.js

Expand Down Expand Up @@ -84,43 +121,19 @@ module.exports = {

##### React v17 issues, use v16.9

### Installing packages

NOTE: use `expo install` primarily (rather than yarn/npm), e.g:

expo install react-native-svg
expo install react-native-maps
expo install expo-location

### Standard setup

Create standard folders and files:

mkdir -p screens/StartScreen
touch screens/StartScreen/index.js
mkdir -p components/screen
touch components/screen/Screen.js
mkdir lib
mkdir hooks
mkdir config
touch config/config.js

Install useful packages:

yarn add standard --dev
expo install expo-font
yarn add @react-navigation/native

Managed:
expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view

https://docs.expo.dev/ui-programming/react-native-toast/

#### package.json

"lint": "standard",
"fix": "standard --fix",
"screen": "mkdir -p screens/NewScreen && touch screens/NewScreen/index.js",
"dev": "yarn start",
"start": "expo start",
"eject": "expo eject",
"test": "echo 'Running Standard.js and Jest unit tests...\n' && yarn lint && yarn unit",
"unit": "jest --watchAll",
"lint": "ts-standard",
"fix": "ts-standard --fix",
"new": "mkdir -p screens/NewScreen; cp screens/PlaceHolderScreen/index.tsx screens/NewScreen; echo \"Now rename folder 'screens/NewScreen' to whatever you want.\"",
"pub": "expo publish",
"build": "eas build --platform ios",
"appstore": "eas submit --latest --platform ios",
"v+": "yarn version --patch",
"v++": "yarn version --minor"

Expand Down Expand Up @@ -431,7 +444,7 @@ https://expo.dev/eas

1. Install EAS: `yarn global add eas-cli && eas login`
2. Create `eas.json`
3. Create a new app on https://appstoreconnect.apple.com/apps – note the bundle ID
3. Create a new app on https://appstoreconnect.apple.com/apps – note the bundle ID (just characters, avoid underscore/dash, e.g. `com.mydomain.myappname`)
4. Set up and build with `eas build` (or `eas build -p ios`)
5. Submit with `eas submit` (or `eas submit -p ios`)

Expand All @@ -440,6 +453,10 @@ https://expo.dev/eas
https://docs.expo.dev/build/eas-json/

{
"cli": {
"version": ">= 0.53.0",
"requireCommit": true
},
"build": {
"development": {
"developmentClient": true,
Expand All @@ -448,21 +465,34 @@ https://docs.expo.dev/build/eas-json/
"preview": {
"distribution": "internal"
},
"production": {}
"production": {
}
},
"cli": {
"version": ">= 0.53.0",
"requireCommit": true
"submit": {
"production": {
"android": {
"serviceAccountKeyPath": "./appstores/googleplay/pc-api-667.json",
"track": "internal"
},
"ios": {
"appleId": "[my appleid login-email]",
"ascAppId": "[NUMERIC ID FROM appstoreconnect.apple.com]"
}
}
}
}

### Using GitHub Actions with Expo/EAS

https://github.com/marketplace/actions/expo-github-action

Note: add `EXPO_TOKEN` in repo settings -> Secrets -> Actions
1. Verify you have set up `eas.json`
2. Create a `.github/workflows/production.yml` (see below)
3. Get a token on https://expo.dev/accounts/[account]/settings/access-tokens and add `EXPO_TOKEN` to repo settings → Secrets → Actions
4. Run EAS build non-interactive from command line the first time to set up accounts etc: `eas build --platform ios`
5. For `eas submit`, you need 1) an ASC API key and 2) an Issuer ID from: https://appstoreconnect.apple.com/access/api

Example `.github/workflows/production.yml`
Example `.github/workflows/production.yml`:

# Commit to `production` branch → build with EAS

Expand Down Expand Up @@ -524,9 +554,9 @@ Steps:

- App ID
- https://developer.apple.com/account/resources/identifiers/list
- `com.tomorroworld.myappname`
- `com.mydomain.myappname`
- Service ID
- `com.tomorroworld.myappname.login`
- `com.mydomain.myappname.login`
- Callback URL: https://lioz*****.supabase.co/auth/v1/callback
- Key
- https://developer.apple.com/account/resources/authkeys/list
Expand Down Expand Up @@ -559,7 +589,7 @@ https://medium.com/wix-engineering/the-full-react-native-layout-cheat-sheet-a414
- `justifyContent`: primary axis
- `alignItems`: cross (secondary) axis
- `alignContent`: bunches children together as if they were one element
- `alignSelf`: overwrites parent’s alignItems property
- `alignSelf`: overwrites parent’s `alignItems` property
- `flexDirection`: column*/row
- `flexWrap`: nowrap*/wrap

Expand Down
2 changes: 2 additions & 0 deletions Development/Databases/Firebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ Order:

coordinates: new firebase.firestore.GeoPoint(lat, long)

Geo queries: use Geohashes: https://firebase.google.com/docs/firestore/solutions/geoqueries

### Events/Triggers

https://firebase.google.com/docs/functions/firestore-events
Expand Down
78 changes: 0 additions & 78 deletions Development/Databases/Google Sheets.md

This file was deleted.

7 changes: 4 additions & 3 deletions Development/JavaScript/JavaScript client.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ Geographic distance:
}


## Strings/Text
## Strings/Texts

http://www.w3schools.com/jsref/jsref_obj_string.asp

Expand Down Expand Up @@ -709,7 +709,7 @@ Slugs:
// For both
var newStr = str.trim()
.toLowerCase()
.replace(/ |_/g, '-') // space/underscore to dash
.replace(/ |_|\//g, '-') // space/underscore/slash to dash
// Remove ÅÄÖ etc?
if (removeInternationalChars) {
newStr = newStr.replace(/[åäæâãáà]/g, 'a').replace(/[ëêéè]/g, 'e').replace(/[öøôõóò]/g, 'o').replace(/[üûúù]/g, 'u') // convert ÅÄÖÜ to Latin characters
Expand Down Expand Up @@ -754,6 +754,7 @@ Slugs:

/** '{variable}' => 'value' */
const replaceStrings = (template, stringsObj) => {
if (!template) return template
let newString = template
const keys = Object.keys(stringsObj)
for (let k in keys) {
Expand Down Expand Up @@ -1070,7 +1071,7 @@ http://www.w3schools.com/jsref/jsref_obj_array.asp

thisYear = new Date().getYear() + 1900

const formatDate = dateObj => `${dateObj.getFullYear()}-${('0' + (dateObj.getMonth()+1)).slice(-2)}-${('0' + dateObj.getDate()).slice(-2)}`
const formatDate = dateObj => `${dateObj.getFullYear()}-${`0${dateObj.getMonth() + 1}`.slice(-2)}-${`0${dateObj.getDate()}`.slice(-2)}`
const formatTime = dateObj => `${dateObj.getHours()}:${dateObj.getMinutes()}`

`[${new Date().getHours()}:${new Date().getMinutes()}]`
Expand Down
42 changes: 19 additions & 23 deletions Development/JavaScript/JavaScript server - NodeJS etc.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ http://javascriptplayground.com/blog/2012/08/writing-a-command-line-node-tool/
return result
}

## Read/write/delete files

// text = await getTextFromFile(filename)
const getTextFromFile = (filename) => require('fs').promises.readFile(filename, 'utf8')

Expand All @@ -437,7 +439,7 @@ http://javascriptplayground.com/blog/2012/08/writing-a-command-line-node-tool/
})
}

Read/write/delete files:
### Read/write/delete files – async

const fs = require('fs')

Expand Down Expand Up @@ -466,18 +468,29 @@ Read/write/delete files:
const { promises: fs } = require('fs')
const fileNames = await fs.readdir('path/to/dir')

// CSV
const fs = require('fs')
const path = require('path')
const parse = require('csv-parse')
### CSV files: `csv-parse`

import { parse } from 'csv-parse/sync'

const getCsvDataFromUrl = async function (url) {
const dataAsCsv = await fetch(url).then(res => res.text())
const dataAsArray = parse(dataAsCsv, { columns: true, skip_empty_lines: true })
return dataAsArray
}

Older:

const fs = require('fs')
const path = require('path')
const parse = require('csv-parse')

const parseCsvFile = function (fileName, actionFunction) {
const filePath = path.join(__dirname, fileName)
const parser = parse({ delimiter: ',' }, actionFunction)
fs.createReadStream(filePath).pipe(parser)
}

// parseCSV
// parseCSV: own implementation
type CsvDataRow = Record<string, any>
type CsvData = CsvDataRow[]
export const parseCSV = (text: string, separator = '\t'): CsvData => {
Expand All @@ -504,15 +517,6 @@ Read/write/delete files:
})
}

var fs = require('fs')
fs.writeFile('/tmp/test', 'Hey there!', function(err) {
if (err) {
return console.log(err)
}
console.log('The file was saved!')
})


## CDN - AWS CloudFront

1. Enable both HTTPS and HTTP, otherwise 301.
Expand All @@ -522,14 +526,6 @@ Read/write/delete files:

- `Cache-Control: public, max-age=120` (seconds)


# Desktop App

http://electron.atom.io/docs/tutorial/quick-start/

npm install --save-dev electron


## PassportJS / Authentication

Best practice: server-side encrypted cookie
Expand Down
Loading

0 comments on commit a91998a

Please sign in to comment.