Skip to content

Instantly share code, notes, and snippets.

@sjordan1975
sjordan1975 / RetryTest.php
Created November 9, 2020 10:39 — forked from orottier/RetryTest.php
Retry function for PHP with exponential backoff
<?php
class RetryTest extends TestCase
{
public function setUp()
{
parent::setUp();
// abuse superglobal to keep track of state
$_GET['a'] = 0;
}
@sjordan1975
sjordan1975 / create-react-app.md
Last active June 23, 2019 06:11
[Create React App] Set up a modern web app by running one command. (https://facebook.github.io/create-react-app/) #react

Create React App Build Status PRs Welcome

Create React apps with no build configuration.

Create React App works on macOS, Windows, and Linux.
If something doesn’t work, please file an issue.

@sjordan1975
sjordan1975 / jenv.txt
Last active June 6, 2019 03:26
[jenv] Common jenv commands (https://github.com/jenv/jenv) #jenv
# Use jenv add to inform jenv where your Java environment is located. jenv does not, by itself, install Java; for example:
$>jenv add /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
oracle64-1.6.0.39 added
$>jenv add /Library/Java/JavaVirtualMachines/jdk17011.jdk/Contents/Home
oracle64-1.7.0.11 added
# List java versions under management
$>jenv versions
# Configure global version
@sjordan1975
sjordan1975 / npm-update.txt
Created June 6, 2019 00:15
[npm update] update all the packages listed to the latest version respecting semver #npm
npm update [-g] [<pkg>...]
aliases: up, upgrade
This command will update all the packages listed to the latest version (specified by the tag config), respecting semver.
It will also install missing packages. As with all commands that install packages, the --dev flag will cause devDependencies to be processed as well.
If the -g flag is specified, this command will update globally installed packages.
@sjordan1975
sjordan1975 / falsey-js.txt
Created May 20, 2019 22:56
[JS Falsey] Falsey values in JavaScript #js #javascript
There are only six falsey values in JavaScript:
undefined, null, NaN, 0, "" (empty string), and false
@sjordan1975
sjordan1975 / eslint+prettier+react.txt
Last active May 16, 2019 07:32
[How to integrate Eslint & Prettier in React] Shows how to integrate eslint & prettier in react #react #eslint #prettier
How to integrate Eslint & Prettier in React
Based on instructions here:
https://medium.com/quick-code/how-to-integrate-eslint-prettier-in-react-6efbd206d5c4
create base react app
$>npx create-react-app <project-name>
@sjordan1975
sjordan1975 / addLocalToBitbucket.txt
Created May 9, 2019 04:27
[Add Local Repo to Bitbucket] Add existing local repo to Bitbucket #git #bitbucket
Create a new BitBucket repository, copy the repository url to the clipboard, and then add that repository as a new remote to your local repository (full steps below):
Get Repo URL
1. In your BitBucket repo, choose "Clone" on the top-right
2. choose "HTTPS" instead of "SSH" in the top-right of the dialog
3. it should show your repo url in the form git clone <repository url>
Add Remote Using CLI
1. cd /path/to/my/repo
2. git remote add origin https://bitbucket.org/<username>/<reponame>.git
@sjordan1975
sjordan1975 / shell.txt
Created May 9, 2019 00:07
[Reload shell profile] Reload bash_profile / profile without starting a new shell session #shell #terminal
Reload bash_profile / profile without starting a new shell session
$> source ~/.bash_profile
@sjordan1975
sjordan1975 / isAjax.txt
Created May 8, 2019 23:02
[isAjax Request] Is the incoming request an ajax request #php #ajax
define('__ERROR__', -1);
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
// if this page is not being accessed via AJAX, return error
if (!IS_AJAX){
echo __ERROR__;
exit;
}
@sjordan1975
sjordan1975 / gist:d3e4071a2a3ac5516f4708d9e4790e22
Created April 28, 2019 03:15
Top level list of installed modules
npm list --depth=0
...or, if you want to list the globally-installed modules:
npm list --depth=0 -g