Skip to content

Instantly share code, notes, and snippets.

Ben Styles benadamstyles

Block or report user

Report or block benadamstyles

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
View keybase.md

Keybase proof

I hereby claim:

  • I am benadamstyles on github.
  • I am benadamstyles (https://keybase.io/benadamstyles) on keybase.
  • I have a public key ASCoqtUtnEKNadbubzwnDKTw-1hG6Da4ULe2g2-GU-wgZgo

To claim this, I am signing this object:

@benadamstyles
benadamstyles / rapt-example-1.js
Last active Feb 18, 2018
Examples for Rapt Medium story
View rapt-example-1.js
import {Map} from 'immutable'
// without Rapt
const processUser = user => {
log(user)
let userMap = Map(user)
if (emailHasBeenVerified) {
userMap = userMap.set('verified', true)
}
syncWithServer(userMap)
@benadamstyles
benadamstyles / flow-utility-type-functions.js
Last active Sep 24, 2017
Flow Utility Type Functions
View flow-utility-type-functions.js
// Below are some useful Flow utility type functions, some I've written and some I've found on the web.
// All contributions welcome!
// Extracting a data type from a maybe type, e.g. getting `string` from `?string`
type _ExtractFromMaybe<T, M: ?T> = T
export type ExtractFromMaybe<M> = _ExtractFromMaybe<*, M>
// FROM https://hackernoon.com/redux-flow-type-getting-the-maximum-benefit-from-the-fewest-key-strokes-5c006c54ec87
// Extracting the type of a function's return value
type _ExtractReturn<R, F: (...args: any[]) => R> = R
View keybase.md

Keybase proof

I hereby claim:

  • I am leeds-ebooks on github.
  • I am benstyles (https://keybase.io/benstyles) on keybase.
  • I have a public key whose fingerprint is 9551 FCA3 0E1C E683 6ADF 9001 5FFB B35C 8695 F553

To claim this, I am signing this object:

View Hyperlinkify.jsx
var uuidCount = 0
function uuid() {
return uuidCount++
}
function arrayFrom(arrayLike) {
var array = []
for (var i = 0; i < arrayLike.length; i++) {
array.push(arrayLike[i])
@benadamstyles
benadamstyles / CreateCrosslink.jsx
Created Nov 23, 2015
InDesign: CreateCrosslink
View CreateCrosslink.jsx
@benadamstyles
benadamstyles / CreateHyperlinkDestinationsFromParagraphStyles.jsx
Created Nov 23, 2015
InDesign: CreateHyperlinkDestinationsFromParagraphStyles
View CreateHyperlinkDestinationsFromParagraphStyles.jsx
var uuidCount = 0
function uuid() {
return uuidCount++
}
function process(doc, paraStyle) {
app.findTextPreferences = NothingEnum.nothing
app.changeTextPreferences = NothingEnum.nothing
View toKeypath.js
const keypaths = [];
const values = [];
const mapper = (input, keypath = '') => {
if (!_.isObject(input)) {
keypaths.push(keypath);
values.push(input);
} else {
const isArray = Array.isArray(input);
@benadamstyles
benadamstyles / macros.js
Last active Aug 29, 2015
Sweet.js macros
View macros.js
// for rebuilding an array without reassignment
macro rebuild {
rule {$oldArr $newArr} => {
$oldArr.length = 0
$oldArr.push.apply($oldArr, $newArr)
}
}
rebuild arr newArr;
View smoothNativeScroll.js
smoothScroll = speed => {
var endPos, comp, step;
const goScroll = function goScroll() {
scrollBy(0, step);
if (comp(window.scrollY, endPos)) {
window.requestAnimationFrame(goScroll);
}
},
runner = end => {
endPos = end;
You can’t perform that action at this time.