Skip to content

Instantly share code, notes, and snippets.

View techieshark's full-sized avatar

Peter W techieshark

View GitHub Profile
@techieshark
techieshark / objectValues.js
Created February 22, 2019 04:10
Flow-typed version of Object.values()
// @flow
// Flow-typed version of Object.values()
// @see: problem - https://github.com/facebook/flow/issues/2221
// @see: this solution - https://stackoverflow.com/a/51757027/1024811
export default function objectValues<A, B>(obj: {[key: A]: B}): Array<B> {
return ((Object.values(obj): any): Array<B>);
}
@techieshark
techieshark / pick.js
Created February 22, 2019 04:09
simple pick.js implementation
// @flow
/**
* Returns new object made of the picked paths.
* Native implementation of lodash `pick`.
* Shaves 1-2kb off download size: https://bundlephobia.com/result?p=lodash.pick@4.4.0.
* @see https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_pick
* @see https://lodash.com/docs/#pick
* @return {Object}
*/
@techieshark
techieshark / copy-into-browser.js
Last active November 9, 2018 12:14
jquery-and-lodash-in-console
// For quickly trying things out in the browser, jQuery and Lo-Dash (like Underscore.js) are great.
// Read the code below (never copy & paste code you don't trust),
// then you can copy & paste it into the browser console to load jQuery & lodash.
(function () {
var jq = document.createElement('script');
jq.src = 'https://code.jquery.com/jquery-2.1.4.js';
@techieshark
techieshark / add_remove_class.js
Created May 24, 2018 21:31
add/remove class without jQuery (just Vanilla JS)
/**
* Remove a CSS class from an HTML element.
* @param {HTMLElement} el The HTML element to modify.
* @param {string} className The class to remove.
* @returns null
* @see http://youmightnotneedjquery.com/#remove_class
*/
function removeClass(el, className) {
if (el.classList)
el.classList.remove(className);

Keybase proof

I hereby claim:

  • I am techieshark on github.
  • I am techieshark (https://keybase.io/techieshark) on keybase.
  • I have a public key ASAGfHHdWMNLxRSipw5fj5uzzNELExUqoXtBuY0RPYw41go

To claim this, I am signing this object:

# Contributor License Agreement
The following terms are used throughout this agreement:
* You - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any entity that controls or is controlled by the legal entity, or is under common control with it.
* Project - School Finder project located at https://github.com/CodeforAustralia/school-finder
* Contribution - any type of work that is submitted to a Project, including any modifications or additions to existing work.
* Submitted - conveyed to a Project via a pull request, commit, issue, or any form of electronic, written, or verbal communication with GitHub, Code for Australia, Peter W, contributors or maintainers.
1. Grant of Copyright License.
@techieshark
techieshark / gist:33950a2b88652fde21415c50a42a3d80
Created February 18, 2017 22:59
Enable Chrome Distill mode
open -a "/Applications/Google Chrome.app" 'https://grist.org/politics/trumps-environmental-assault-continues-and-now-hell-have-pruitt-as-a-henchman/' --args --enable-dom-distiller
# Now go to Menu -> Distill Page (on an article page, like the example above)
@techieshark
techieshark / documentation.json
Created July 15, 2016 06:28
Elm documentation example file
[
{
"name": "Data",
"comment": "Data module overview.\n\n#Single items\n\n\n@docs getItem\n\n",
"aliases": [],
"types": [],
"values": [
{
"name": "getItem",
"comment": "Get item from app data store.",
# want to quickly see how large (in bytes) a file is after we gzip it, without actually gzipping it
# on command line, running the following does the trick: gzip -c file.js | wc -c
# we can add this little bit to our .bashrc so we can instead just type gsize file.js
gzipSize() {
gzip -c $1 | wc -c
}
alias gsize=gzipSize
# Git
alias ga='git add'
alias gbs='git bisect'
alias gbl='git blame'
alias gb='git branch'
alias gco='git checkout'
alias gc='git commit'
alias gcl='git clone'
alias gcp='git cherry-pick'
alias gd='git diff'