TypeScript supports Pick
to allow you to get a "subset" object type of a given type, but there is no built-in Pick
for deeper nested fields.
If you have a function that takes a large object as argument, but you don't use all of its fields, you can use Pick
, Pick2
, Pick3
, etc to narrow down the input type to be only just what you need. This will make it easier to test your function, because when mocking the input object, you don't need to pass all fields of the "large" object.
import { createCipheriv, createDecipheriv, randomBytes } from "crypto"; | |
const ENCRYPTION_KEY: string = process.env.ENCRYPTION_KEY || ""; // Must be 256 bits (32 characters) | |
const IV_LENGTH: number = 16; // For AES, this is always 16 | |
/** | |
* Will generate valid encryption keys for use | |
* Not used in the code below, but generate one and store it in ENV for your own purposes | |
*/ | |
export function keyGen() { |
import { parse, visit, print } = from 'graphql/language'; | |
/** | |
* Combine the fields of two or more AST nodes, does no error checking! | |
* @param types An array with types to combine. | |
* @returns {*} | |
*/ | |
export function combineASTTypes(types) { | |
return types.reduce((p, n) => Object.assign(p, n, { fields: n.fields.concat(p.fields || []) }), {}); | |
} |
import flatMap from 'lodash/flatMap'; | |
import keys from 'lodash/keys'; | |
import get from 'lodash/get'; | |
import identity from 'lodash/identity'; | |
import isArray from 'lodash/isArray'; | |
import isDate from 'lodash/isDate'; | |
import isFunction from 'lodash/isFunction'; | |
import isObject from 'lodash/isObject'; | |
import map from 'lodash/map'; | |
import zipObject from 'lodash/zipObject'; |
Copyright (c) 2016 Jens Bissinger | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all |
brew update | |
brew cask install java | |
brew cask install jce-unlimited-strength-policy | |
export JAVA_HOME=`/usr/libexec/java_home -v 1.8` |
:: Trim from 2″ for 3 seconds, and encode into a "Twitter friendly" format. | |
ffmpeg -i source.mp4 -pix_fmt yuv420p -an -ss 2 -t 3 temp.mp4 | |
:: Make a palette for GIF. | |
ffmpeg -i temp.mp4 -vf palettegen=max_colors=24 palette.png | |
:: Make a GIF with the palette. | |
ffmpeg -i temp.mp4 -i palette.png -filter_complex "scale=400:-1:flags=lanczos[x];[x][1:v]paletteuse" -r 30 out.gif |
{"collected":["glasses-1","glasses-2","glasses-3","glasses-4","hat-1","hat-2","hat-3","hat-4","hat-5","hat-6","hat-7","hat-8","toy-1","toy-2","toy-3","toy-4","toy-5","toy-6","toy-7","toy-8"],"active":{"hat":"hat-8","toy":"toy-3","glasses":"glasses-3"},"unseen":[],"shuffle":false} |
This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.
The Atom documentation is excellent. It's highly worth reading the flight manual.