Skip to content

Instantly share code, notes, and snippets.

@isabellachen
isabellachen / google-analytics-react.md
Last active August 27, 2019 10:21
Add Google Analytics to React App

Adding GA to your React Project

The guide here uses this package: Lazy Analytics

This package can initiate GA for development enironments. Usually when initializing GA, the ga() command queue is called like so ga('create', 'UA-XXXXX-Y', 'auto'); If the pacakge is initialized with google-test-code, the command queue is instead run like so ga('create', {env: 'dev', google: 'google-test-code'}, 'auto')

It is helpful to install the Google analytics debugger With this extension, you don't actually have to have a GA account and the associated UA key set up for your site. The extension will track and log into the console all the tracking beacons being sent from your SPA.

In the feature branch
- git rebase origin master //fast forward your master to origin master
- git checkout my-feature
- git rebase master //rebase your branch with your local master branch
@isabellachen
isabellachen / bootstrap-strapi.js
Created July 23, 2019 09:24
bootstrap.js to initiate providers strapi beta
'use strict';
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
@isabellachen
isabellachen / promise-race.js
Created July 13, 2019 21:03
Ping an API with SetInterval and clear the Interval if the API never responds after a certain time
const fetch = require('cross-fetch');
let id;
const promisifedPingApi = new Promise((resolve, reject) => {
id = setInterval(() => {
fetch('https://api.chucknorris.io/jokes/random')
.then(res => res.json())
.then(json => resolve(json));
}, 500);
});
Promise.race([
@isabellachen
isabellachen / todo-react-hooks.js
Created June 30, 2019 15:33
Todo list with React Hooks
/* Dead easy implementation of a Todo list with React Hooks
* Demonstrates how to split state
* Shows how to bind click handlers when there is no class
* Codesandbox: https://codesandbox.io/s/react-hooks-1zk7f
* File: 04-todo.js, make sure to toggle 'current module view' - top right of preview screen
*/
import React, { useState } from "react";
import ReactDOM from "react-dom";
@isabellachen
isabellachen / lettra-package.json
Created June 20, 2019 20:07
package.json for compiling scss into css in wordpress theme
{
"name": "lettra",
"version": "1.0.0",
"description": "WP Theme for Writers",
"scripts": {
"build:style": "node-sass sass/style.scss style.css --output-style expanded",
"build": "run-p \"build:*\"",
"watch": "chokidar \"**/*.scss\" -c \"npm run build\" --initial"
},
"devDependencies": {
@isabellachen
isabellachen / mixed-content-chrome-dev.md
Created June 7, 2019 15:02
Search for mixed content

To search for mixed content, click the Network tab. In the input box,mixed-content:displayed

@isabellachen
isabellachen / flywheel-local-xdebug-vscode.md
Created June 1, 2019 14:06 — forked from ahmadawais/flywheel-local-xdebug-vscode.md
Debug WordPress with Visual Studio Code | VSCode WordPress Debug Setup | WordPress xDebug Setup for Local by FlyWheel with VSCode | Part of the VSCode Learning Course → https://VSCode.pro

VSCode WordPress Debugging Setup: WordPress Xdebug Setup for Local by FlyWheel with VSCode


Consider supporting my work by purchasing the course this tutorial is a part of i.e. VSCode Power User

🚅 TL;DR

  • Make sure your Local by FlyWheel WordPress install is a custom install
@isabellachen
isabellachen / file.extension.spec.ts
Created March 29, 2019 13:50
Functionality to test for file size
import './file.extension';
describe('FileExtension', () => {
const generateFile = (filesize: number = 20) => {
const fileBits: BlobPart[] = [new Array(filesize + 1).join('1')];
const fileName: string = 'example.txt';
return new File(fileBits, fileName);
};
it('should define isSizeValid', () => {
@isabellachen
isabellachen / react-component-typescript.js
Created February 7, 2019 16:32
Declaring React Stateful Components with Typescript
//Into the type constraint of the component, that is the <>, input two arguments.
//The first are the typings for props, the second is the typings for state.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
class App extends React.Component<{
message: string
}, {
count?: number