Skip to content

Instantly share code, notes, and snippets.

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@ashybaye
ashybaye / react fetch with pagination
Created November 30, 2022 16:30
Example of react fetch from api and displaying the results using ReactPaginate
import React, { useState } from 'react';
import ReactPaginate from 'react-paginate'; #New
const NewsCard = (props) => {
return (
<div style={{ padding: '20' }}>
<a href={props.url}>
{props.title} by {props.author}
</a>
</div>
@ashybaye
ashybaye / useFetchWithAbort.tsx
Created November 30, 2022 16:26
React: Fetch Hook (with AbortController to avoid race conditions and memory leaks)
import { useState, useEffect } from "react";
/* H/T:
Avoiding Race Conditions and Memory Leaks in React useEffect
https://javascript.plainenglish.io/avoiding-race-conditions-and-memory-leaks-in-react-useeffect-2034b8a0a3c7
*/
interface IUseFetchWithAbortResponse {
fetchedData: unknown;
isLoading: boolean;
@ashybaye
ashybaye / visually-hide.css
Created May 21, 2019 14:37
A11y snippets
// visually hide
.hide-accessibly {
position: absolute !important;
opacity: 0;
pointer-events: none;
}
@ashybaye
ashybaye / debug-plugins.txt
Last active April 29, 2019 19:33
WP debug helpers
* Core Control (outdated) - https://wordpress.org/plugins/core-control/
* WP Debug Bar - https://wordpress.org/plugins/debug-bar/
@ashybaye
ashybaye / wp-cli-commands.md
Last active April 24, 2019 13:16
Useful WP-CLI commands

Create dummy content:

@ WordPress project root directory

$ curl -OL https://raw.githubusercontent.com/poststatus/wptest/master/wptest.xml
$ wp import wptest.xml --authors=create
// stop git ask for passphrase
ssh-add -K
@ashybaye
ashybaye / disable GA trackers
Last active October 3, 2018 15:15
GA trackers handy js functions
function disable_ga_trackers() {
console.log('disabling trackers');
ga(function() {
var trackers = ga.getAll();
for (i = 0, len = trackers.length; i < len; i += 1) {
var trackerID = trackers[i].get('trackingId');
console.log(trackerID);
var dis_trackerID = 'ga-disable-' + trackerID;
window[dis_trackerID] = true;
console.log(dis_trackerID);
@ashybaye
ashybaye / Sync db and files
Created October 19, 2017 18:37
Useful pipeline commands
// Sync local database with prod
// <in uiowa703/docroot>
drush @<alias>.local sql-drop
drush sql-sync @<alias>.prod @<alias>.local
// Sync local uploaded files with prod
drush rsync @<alias>.prod:%files @<alias>.local:%files
// OR
drush @source.env rsync -A @self:%files @destination.env:%files
export PATH="$PATH:/Applications/DevDesktop/tools"
export PS1='\[\033[33;1m\]\w\[\033[m\]\$ '
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
export PATH=${PATH}:/usr/local/mysql/bin
export PATH=/usr/local/php5/bin:$PATH