Skip to content

Instantly share code, notes, and snippets.

View jmahc's full-sized avatar
🏠
Working from home

Jordan McArdle jmahc

🏠
Working from home
View GitHub Profile
@jmahc
jmahc / fakePromise
Created October 26, 2016 18:55
Fakes a promise and returns "fetched" data from a remote API.
/**
* For demonstration purposes only. Normally this promise would
* do something cool, like fetch data from a remote API.
*
* @param entity
* @returns {Promise}
*/
function fakePromise() {
return new Promise(resolve => {
const delay = _getShortDelay();
@jmahc
jmahc / validate.js
Created November 4, 2016 17:02
validate form input react
const isEmpty = value => value === undefined || value === null || value === '';
const join = (rules) => (value, data) => rules.map(rule => rule(value, data)).filter(error => !!error)[0 /* first error */ ];
export function email(value) {
// Let's not start a debate on email regex. This is just for an example app!
if (!isEmpty(value) && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value)) {
return 'Invalid email address';
}
}
@jmahc
jmahc / eslint-block-example.js
Created November 17, 2016 16:29
ESLint description
// This example would cause an error by ESLint because we are using ES6 JS (it would suggest `const` or `let`)
/* eslint-disable */
var x = 1;
/* eslint-enable */
var y = 2; // throws eslint-error suggestioning to use `const` or `let`
@jmahc
jmahc / Root.jsx
Created December 1, 2016 19:40 — forked from vdh/Root.jsx
Moderately-successful hot reloading for react-router v3
import React, { PropTypes } from 'react';
import { Provider } from 'react-redux'; // Or something else, if you're not using Redux
import Router from 'react-router/lib/Router';
const Root = ({ store, history, routes }) => (
<Provider store={store} key="provider">
<Router history={history} routes={routes} />
</Provider>
);
@jmahc
jmahc / index.html
Created December 9, 2016 14:03
Loading page for Webpack while it builds.
<div id="root">
<style type="text/css" scoped>
h1 { z-index: 10; font-family: 'Roboto', 'Helvetica', sans-serif; display: inline-block; }
.loader {
margin: 10% auto;
font-size: 10px;
position: relative;
text-indent: -9999em;
border-top: 1.1em solid rgba(100, 100, 100, 0.2);
@jmahc
jmahc / styles.less
Created December 14, 2016 20:21
Atom font-style settings found in Atom.io's configuration settings.
// ==== Ligature fonts for atom
// JM 12/14/2016
// Sources:
// - https://github.com/tonsky/FiraCode
// - http://www.dafont.com/flottflott.font
//
// Reference (original): https://medium.com/@docodemore/an-alternative-to-operator-mono-font-6e5d040e1c7e#.nm9fchwv1
// Reference (improved): https://gist.github.com/MattMcFarland/e41ef709b1d82adea800563a86805559#gistcomment-1835618
@fontsize: 16px;
@jmahc
jmahc / autoexec.cfg
Created December 21, 2016 03:02
CSGO settings as of 12/20/2016 @9:02
//------------------------
// General/Matchmaking Settings (begin)
//------------------------
mm_dedicated_search_maxping “70″
cl_autowepswitch "0"
cl_loadout_colorweaponnames "1"
cl_mute_enemy_team "1"
cl_bob_lower_amt 0
cl_bobamt_lat 0
cl_bobamt_vert 0
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
@jmahc
jmahc / anagram-v2.js
Last active January 10, 2017 22:54
JavaScript method that determines if two string values are anagrams.
function anagram(wordOne, wordTwo) {
var isAnagram = false;
if (wordOne.split('').length === wordTwo.split('').length) {
wordOne.split('').sort().every(function(one, two) {
return isAnagram = one === wordTwo.split('').sort()[two];
});
}
return isAnagram;
}
console.log(anagram("jordan", "najorad"));
@jmahc
jmahc / settings.json
Last active November 6, 2019 23:07
VS Code Solution for Fira Code and Flottflott - based on the Medium article: https://medium.com/@docodemore/an-alternative-to-operator-mono-font-6e5d040e1c7e#.jq6tb618c
// `File > Preferences > User Settings`(WINDOWS)
// Place your settings in this file to overwrite the default settings
{
"editor.fontSize": 14,
"editor.fontFamily": "'Fira Code', Consolas, 'Courier New', monospace",
"editor.fontLigatures": true,
"editor.fontWeight": "normal",
"editor.tabSize": 2,
"editor.formatOnSave": true,