Skip to content

Instantly share code, notes, and snippets.

View clementsjj's full-sized avatar

JJ Clements clementsjj

View GitHub Profile

CSV Manipulation in Terminal

Problem

A 9 million row csv file should be split and combined with required data

Head

head -n 1116604 file.csv > file1.csv This will take the first n amount of rows and output to a new file

Result
const result = [
  { contactId: 1217, emailId: 509379 },
  { contactId: 7170, emailId: 509380 },
  { contactId: 1217, emailId: 509381 },
  { contactId: 1217, emailId: 509382 }
]
Desired Result

Resolving Node Module Errors

This addresses a number of errors.
Ex:

  • Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (72)

Redo Node Packages
  1. Check that you are in the proper directory (/frontend/ or /main/
  2. Delete package-lock.json in the correct directory
  3. Recursively remove all from /node_modules/ (with sudo)

Optional Chaining Operator == Null Propagation Operator

Currently in Stage 2 Used to check if a value in an object is undefined or null

?.

const firstName = person.profile.name.firstName
try {
  yield put({
    type: 'SET_BUILDING_DOWNLOAD',
    loading: true,
    complete: false,
    loadOption: 'buildingOwnersLoading',
    completeOption: 'buildingOwnersComplete',
  });
 
case types.RENAME_SOCIAL_SUCCESS:
  return {
    ...state,
    social: state.social.map(item => {
      if (item.socialId === action.socialId) {
        //item.name = action.name
        return {
          ...item,
 name: action.name
case types.RENAME_SOCIAL_SUCCESS:
  return {
    ...state,
    social: state.social.map(item => {if(item.socialId === action.socialId)item.name = action.name})
  };
const objarray = [
  {a: 1, b: 2, c:3},
  {a: 2, b: 3, c:4},
  {a: 3, b: 4, c:69},
]
objarray.filter(item => !Object.values(item).includes(69))

Console Options

Console What it do
.log
.trace
.time
.timeEnd
.memory
.profile
.profileEnd
.count

Imported from redux-saga/effects

effect example what it do
put send data to redux store
call sends the AJAX api request
all runs multiple effects in parallel, kind of like Promise.all
select
takeEvery
takeLatest yield takeLatest("API_CALL_REQUEST", workerSaga) Listens for action type and then executes workerSaga