Skip to content

Instantly share code, notes, and snippets.

Terry Appleby tappleby

Block or report user

Report or block tappleby

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tappleby
tappleby / gist:327c91bb8ec875120a71
Created Nov 17, 2015
jq '.result.sources[] | [.source.artist, .source.name] | map(select(. != null)) | join(" - ")' ~/rdio-history.json -r | sort | uniq -c | sort -r
View gist:327c91bb8ec875120a71
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 Aug 21, 2015
Destructuring vs manual access
View a.js
function foo(...args) {
const [state, action] = args;
}
function bar(...args) {
const state = args[0];
const action = args[1];
}
@tappleby
tappleby / 0_example.js
Created Aug 10, 2015
redux request middleware using superagent and es6 promises.
View 0_example.js
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 Jul 7, 2015
Redux => To web worker
View 0_concept.js
const composedCreateStore = compose(
applyMiddleware(
thunkMiddleware,
dispatchIdMiddleware,
webWorkerMiddleware('/build/worker.js'),
() => promiseMiddleware,
loggerMiddleware
),
createStore
);
@tappleby
tappleby / 0_usage.js
Last active Apr 5, 2018
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
View 0_usage.js
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 Jun 11, 2015
search_api_elasticsearch + search_api_et integration
View gist:fb491c2b7598b664a219
<?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';
}
}
View TranslatableTrait.php
<?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 Mar 5, 2015
Example session actions, store and cache w/ flummox.
View SessionActions.js
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 Mar 14, 2014
Cross compile JQ for windows
View build-jq.sh
#!/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
@tappleby
tappleby / edit_data_bag.rb
Last active Dec 16, 2015 — forked from aaronjensen/edit_data_bag.rb
Edit data bag when using chef solo. Changed to automatically write empty data bag if none exists.
View edit_data_bag.rb
#!/usr/bin/env ruby
Dir.chdir File.join(__FILE__, "../..")
unless ENV['EDITOR']
puts "No EDITOR found. Try:"
puts "export EDITOR=vim"
exit 1
end
unless ARGV.count == 2
You can’t perform that action at this time.