Skip to content

Instantly share code, notes, and snippets.

View CharlieHess's full-sized avatar
🗑️

Charlie Hess CharlieHess

🗑️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am CharlieHess on github.
  • I am chess (https://keybase.io/chess) on keybase.
  • I have a public key whose fingerprint is BAB8 B831 7A5E 18E9 9460 BE8B 7CD2 4F2D 402C C81A

To claim this, I am signing this object:

@CharlieHess
CharlieHess / oldFashionedProcedural.js
Last active August 26, 2015 05:34
Old Fashioned Procedural Ways
doABettingRound(players) {
for (let player of players) {
tellThatPlayerToAct(player);
startATimer(timerCallback);
seeIfTheySentAMessage(messageCallback);
}
}
...
@CharlieHess
CharlieHess / rxIsFire.js
Created August 26, 2015 05:49
New Rx Hot Shit
let timeExpired = rx.Observable.timer(0, 1000, scheduler)
.take(timeout + 1)
.publishLast();
let newPlayers = messages.where(e => e.text && e.text.toLowerCase().match(/\byes\b/))
.map(e => e.user)
.distinct()
.take(maxPlayers)
.publish();
@CharlieHess
CharlieHess / sign-in-window.js
Last active September 28, 2017 02:50
A redux-observable epic that handles first time sign-in
import { BrowserWindow } from 'electron';
import { REHYDRATE } from 'redux-persist/constants';
import { getWorkspacesCount } from '../reducers/workspaces';
const signInWindowEpic = (action$, store) => {
// Rehydrate is just a $10 word for "we loaded saved state from a file"
// Since we're a redux-persist app, it's one of the first actions that occurs
return action$.ofType(REHYDRATE)
.filter(() => getWorkspacesCount(store) > 0)
.map(() => createSignInWindow(store))
import { webContents as WebContents } from 'electron';
import { NOTIFICATIONS } from '../constants/actions';
import {
notificationClickCode,
notificationReplyCode
} from '../constants/code';
/**
* An epic that executes some code in the guest page when the user clicks or
* replies to a native notification.
@CharlieHess
CharlieHess / tally-workspace-usage.js
Last active September 27, 2017 02:20
An Epic that tallies time spent in workspaces
/**
* Keep a running total of time spent on each workspace and, once the app is quit,
* fire an action that updates the usage property in the store.
*/
const tallyWorkspaceUsageEpic = (action$, store, scheduler) => {
return selectionChangedObservable(action$, store)
.timeInterval(scheduler)
.pairwise()
.reduce(usagePayloadFromIntervals, {})
.map((payload) => ({
@CharlieHess
CharlieHess / tally-workspace-usage.spec.js
Last active September 30, 2017 21:13
A test for the workspace usage epic
import { rxSandbox } from 'rx-sandbox';
import { tallyWorkspaceUsageEpic } from '../epics/tally-workspace-usage';
describe('tallyWorkspaceUsageEpic', () => {
it('should accumulate time until the app is quit', () => {
const { hot, flush, getMessages, e } = rxSandbox.create();
const w = { type: WORKSPACE.SELECTION_CHANGED, payload: 'Hiro' };
const x = { type: WORKSPACE.SELECTION_CHANGED, payload: 'Fiona' };
Gift Your ex-roommate The townsfolk
Beer
Homecooked meals
Grass
"Grass"
Rare crystals
"Rare crystals"
@CharlieHess
CharlieHess / app-store-builds.ts
Created July 11, 2019 00:39
Proof of concept for making App Store Connect requests
/* tslint:disable: no-console */
import * as fs from 'fs-extra';
import { sign } from 'jsonwebtoken';
import { memoize, take } from 'lodash';
import fetch from 'node-fetch';
import * as path from 'path';
const KEY_ID = 'XXXXSECRET';
const ISSUER_ID = 'secret-xxxx-xxxx-xxxx-secret';
@CharlieHess
CharlieHess / index.html
Created September 5, 2019 15:24
Proxy BrowserWindow with allowed methods
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,