Skip to content

Instantly share code, notes, and snippets.

View coffee-cup's full-sized avatar

Jake Runzer coffee-cup

View GitHub Profile
{
"last" : true,
"photos" : [
{
"version" : 0,
"upload_date" : "2015-01-21T23:09:28.390Z",
"mount" : "\/data",
"_id" : 301,
"type" : "image\/jpeg",
"photo_data" : [
private int[] stringToIntArray(String text) {
int[] array = new int[text.length()];
for (int i=0;i<text.length();i++) {
// maybe do check to see if charAt(i) is lower case character?
array[i] = (int) text.charAt(i) - (int) 'a';
}
return array;
}
@coffee-cup
coffee-cup / .csscomb.json
Last active May 17, 2017 21:41
CSSComb config for Axiom Zen
{
"always-semicolon": true,
"block-indent": " ",
"color-case": "upper",
"color-shorthand": false,
"element-case": "lower",
"eof-newline": true,
"leading-zero": false,
"quotes": "single",
"remove-empty-rulesets": true,
@coffee-cup
coffee-cup / keybase.md
Created October 5, 2017 06:19
Keybase Github Verification

Keybase proof

I hereby claim:

  • I am coffee-cup on github.
  • I am jakerunzer (https://keybase.io/jakerunzer) on keybase.
  • I have a public key ASDTrMY_EQHLlcJ212YVW-cxv3wYPthoxTDlu48BUDqdpwo

To claim this, I am signing this object:

@coffee-cup
coffee-cup / callback_to_promise.js
Created October 17, 2017 23:28
Turn a method that takes a callback into a promise
const callbackToPromise = method => (...args) => {
return new Promise((resolve, reject) => {
method(...args, (err, res) => {
if (err) reject(err);
resolve(res);
})
})
}
const callbackTimeout = (time, callback) => setTimeout(callback, time);
// src/store/chat/types.ts
export const SEND_MESSAGE = "SEND_MESSAGE";
export const DELETE_MESSAGE = "DELETE_MESSAGE";
interface SendMessageAction {
type: typeof SEND_MESSAGE;
payload: Message;
}
interface DeleteMessageAction {
// src/store/chat/reducers.ts
import {
ChatState,
ChatActionTypes,
SEND_MESSAGE,
DELETE_MESSAGE
} from './types'
const initialState: ChatState = {
messages: []
// src/thunks.ts
import { Action } from 'redux'
import { sendMessage } from './store/chat/actions'
import { AppState } from './store'
import { ThunkAction } from 'redux-thunk'
export const thunkSendMessage = (
message: string
): ThunkAction<void, AppState, null, Action<string>> => async dispatch => {
import * as firebase from "firebase/app";
import { AnyAction } from "redux";
import { ThunkAction } from "redux-thunk";
import { State } from "..";
import { Database } from "../../database";
export interface ThunkExtraArguments {
firebase: firebase.app.App;
reactReduxFirebase: any;
database: Database;
import * as React from "react"
import { connect } from "react-redux"
import { State } from "./types"
interface Props { /* ... */ }
interface EnhancedProps { /* ... */ }
const MyComponent: React.FC<Props & EnhancedProps> = props => (
/* ... */
)