Skip to content

Instantly share code, notes, and snippets.

@tappleby
tappleby / server.ts
Created April 8, 2023 02:06
Sample remix handler based on remix-architect that supports AWS Lambda Streaming - https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/
import { createRequestHandler } from "./streaming-lambda.ts";
import * as build from "@remix-run/dev/server-build";
export const handler = awslambda.streamifyResponse(
createRequestHandler({
build,
mode: process.env.NODE_ENV,
})
);
@tappleby
tappleby / gist:327c91bb8ec875120a71
Created November 17, 2015 03:06
jq '.result.sources[] | [.source.artist, .source.name] | map(select(. != null)) | join(" - ")' ~/rdio-history.json -r | sort | uniq -c | sort -r
217 Terry FM
170 AutoPlay
16 Machine Gun Kelly - General Admission
15 The Game - The Documentary 2.5
14 J. Cole - 2014 Forest Hills Drive
13 Grieves - Winter & The Wolves [Deluxe Version]
12 The Game - 100 (feat. Drake)
12 Joey Bada$$ - B4.DA.$$
10 Kenn Starr - Square One
9 The Weeknd - Kiss Land
@tappleby
tappleby / a.js
Created August 21, 2015 02:42
Destructuring vs manual access
function foo(...args) {
const [state, action] = args;
}
function bar(...args) {
const state = args[0];
const action = args[1];
}
@tappleby
tappleby / 0_example.js
Created August 10, 2015 01:22
redux request middleware using superagent and es6 promises.
import { createStore, applyMiddleware, compose } from 'redux';
import request from 'superagent-es6-promise';
import thunkMiddlware from 'redux-thunk';
import promiseMiddleware from 'redux-promise';
import logMiddleware from './middleware/log';
import requestMiddleware from './middleware/request';
// Create request middleware with our execute logic, return promise.
const executeRequestMiddleware = requestMiddleware((req, getState) => {
const { session: { token } } = getState();
@tappleby
tappleby / 0_concept.js
Created July 7, 2015 01:52
Redux => To web worker
const composedCreateStore = compose(
applyMiddleware(
thunkMiddleware,
dispatchIdMiddleware,
webWorkerMiddleware('/build/worker.js'),
() => promiseMiddleware,
loggerMiddleware
),
createStore
);
@tappleby
tappleby / 0_usage.js
Last active April 5, 2018 12:50
Experimental middleware + reducer which tracks performance of all dispatched actions in https://github.com/gaearon/redux >= 1.0.0. Supports async actions which follow pattern outlined here https://github.com/gaearon/redux/issues/99#issuecomment-112212639
import { createStore } from 'redux';
import { performanceMiddleware, performanceReducer, performancePrintTable } from './redux/util/performance';
import thunkMiddleware from 'redux/lib/middleware/thunk';
import promiseMiddleware from './redux/middleware/promiseMiddleware';
import * as reducers from './reducers/index';
// Util functions.
function asyncAction(promise, request, success, failure) {
return { types: [request, success, failure], promise };
}
@tappleby
tappleby / gist:fb491c2b7598b664a219
Created June 11, 2015 22:03
search_api_elasticsearch + search_api_et integration
<?php
/**
* Implements hook_search_api_elasticsearch_fields_updated_alter().
*/
function search_api_et_elasticsearch_search_api_elasticsearch_fields_updated_alter(SearchApiIndex $index, &$fieldsUpdatedProperties) {
if ($index->item_type === 'search_api_et_node') {
$fieldsUpdatedProperties['id']['type'] = 'string';
}
}
<?php
/*
* (C) Copyright 2015 76design Inc (https://76design.com) and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@tappleby
tappleby / SessionActions.js
Created March 5, 2015 01:36
Example session actions, store and cache w/ flummox.
var { Actions } = require('flummox');
var Promise = require('bluebird');
var assign = require('object-assign');
class SessionActions extends Actions {
constructor(api, flux) {
super();
this.api = api;
this.flux = flux;
}
@tappleby
tappleby / build-jq.sh
Created March 14, 2014 15:30
Cross compile JQ for windows
#!/bin/sh
# Modified version of: https://github.com/svnpenn/a/blob/e06ea1e/scripts/install-jq.sh
# up to date Windows native jq
# autoconf need for autoreconf
# automake need for autoreconf > aclocal
# libtool need for autoreconf > libtool
# bison need for make
# flex need for make