Skip to content

Instantly share code, notes, and snippets.

View stevensacks's full-sized avatar

Steven Sacks stevensacks

  • Tokyo, Japan
View GitHub Profile
@stevensacks
stevensacks / watcher-stylelint.xml
Created August 24, 2020 06:59
WebStorm Stylelint File Watcher
<TaskOptions>
<TaskOptions>
<option name="arguments" value="$FileName$ --fix" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="css" />
<option name="immediateSync" value="false" />
<option name="name" value="Stylelint" />
<option name="output" value="$FileDir$" />
@stevensacks
stevensacks / README.md
Last active November 23, 2019 01:47
FontAwesomeIcon without using 'as'

FontAwesomeIcon without using as

To avoid dealing with duplicate names from different icon styles (solid, regular, etc.), just use apply!

@stevensacks
stevensacks / explanation.md
Last active January 3, 2019 06:13
Free Code Camp - Intermediate Algorithms - Missing Letters
const onlyLetters = str => str.replace(/[^a-zA-Z]/g, '');
const alphabetize = str => str.split('').sort().join('');
const toLowerCase = str => str.toLowerCase();
const fromCharCode = code => String.fromCharCode(code);
const charCode = char => char.charCodeAt(0);
const excludes = (str, char) => !str.includes(char);
const first = str => str[0];
const last = str => str[str.length - 1];
const defined = f => f || undefined;
@stevensacks
stevensacks / topTen.js
Last active September 1, 2018 02:42
Top Ten words in an array
// "word" array generator
const letter = () => String.fromCharCode(~~(Math.random() * 26) + 97);
const pair = () => `${letter()}${letter()}`;
const gen = length =>
Array(length)
.fill()
.map(pair);
@stevensacks
stevensacks / DatePicker.js
Last active June 26, 2023 08:59
React Bulma DatePicker
import {addDays, format, isAfter, isBefore, startOfDay} from 'date-fns';
import React, {Component, Fragment} from 'react';
import classes from 'classnames';
import DatePickerDialog from './DatePickerDialog';
import Dialog from 'components/Dialog';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {getDisabled} from '../../../utils/component';
import PropTypes from 'prop-types';
import './index.css';
@stevensacks
stevensacks / Dialog.js
Last active July 16, 2022 15:08
Dialog as a promise
import React, {Component} from 'react';
import {delay} from 'lodash';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {getDisabled} from '../../utils/component';
import PropTypes from 'prop-types';
import './index.css';
export default class Dialog extends Component {
static propTypes = {
cancel: PropTypes.string,
@stevensacks
stevensacks / axios.js
Last active July 5, 2019 12:10
Axios Render Props component inspired by React-Apollo Query/Mutation components
import axios, {getError} from 'services/axios';
import {Component} from 'react';
import {connect} from 'react-redux';
import {delay} from 'lodash';
import {getAuth} from 'rdx/selectors';
import PropTypes from 'prop-types';
/* eslint-disable no-console */
class Axios extends Component {
static propTypes = {
import axios from 'axios';
import {createAction} from 'redux-actions';
export default store => next => action => {
const {dispatch} = store;
if (action.payload && action.payload.axios) {
return new Promise((res, rej) => {
const apiToken = store.getState().apiToken;
const payload = {
...action.payload.axios,
@stevensacks
stevensacks / WorkIt.scpt
Created January 16, 2018 12:12
Automate launching my work environment
say "Oh k, let's work" using "Oliver"
-- go to space 3
tell application "System Events"
key code 20 using {control down}
end tell
-- start iTunes downtempo radio
tell application "Safari"
activate