This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var groupBy = function(data, key) { // `data` is an array of objects, `key` is the key (or property accessor) to group by | |
// reduce runs this anonymous function on each element of `data` (the `item` parameter, | |
// returning the `storage` parameter at the end | |
return data.reduce(function(storage, item) { | |
// get the first instance of the key by which we're grouping | |
var group = item[key]; | |
// set `storage` for this instance of group to the outer scope (if not empty) or initialize it | |
storage[group] = storage[group] || []; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const path = require("path"); | |
function newItem(name, url) { | |
return { name, url }; | |
} | |
const bookmarkPath = path.join( | |
process.env.HOME, | |
"/Library/Application Support/Google/Chrome/Default/Bookmarks" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Install 'module-name' as a dependency, then: | |
function init () { | |
return new Promise ((resolve, reject) => { | |
const injectScript = (src, callback) => { | |
const script = document.createElement('script'); | |
document.head.appendChild(script); | |
script.onload = callback; | |
script.src = src; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const merge = require('merge-img'); | |
const pageUrl = ''; // REPLACE ME | |
const pageElement = '#svgcanvas'; // REPLACE ME | |
(async() => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto(pageUrl); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Updated version of script by Todd Linkner | |
// This script is for Photoshop CS6. It outputs Android icons of the | |
// xxxhdpi - ldpi from a source PSD at least 512px x 512px | |
/* | |
// BEGIN__HARVEST_EXCEPTION_ZSTRING | |
<javascriptresource> | |
<name>$$$/JavaScripts/OutputAndroidIcons/MenuAlt=Output Android Icons</name> | |
<category>mobile</category> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.experimental.CommonPool | |
import kotlinx.coroutines.experimental.channels.Channel | |
import kotlinx.coroutines.experimental.launch | |
import okhttp3.* | |
import okio.ByteString | |
import kotlin.coroutines.experimental.suspendCoroutine | |
/** | |
* Created by omarmiatello on 17/06/17. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Author: Ming Wen ([email protected]) | |
When resolving conflicts on a merge or rebase, this script | |
automates `git add/rm` and `git checkout` with --ours or --theirs | |
for a large batch of changes. | |
Usage: `python3 git_batch_resolver.py` in your git repository. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Setup the client | |
OkHttpClient client = new OkHttpClient.Builder() | |
.cookieJar(new CookieJar() { | |
@Override | |
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) { | |
} | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://astexplorer.net/#/BICnPGGYdU/4 | |
export default function ({types: t}) { | |
return { | |
visitor: { | |
FunctionDeclaration(path) { | |
if (path.node.generator) { | |
path.node.async = true | |
path.node.generator = false | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xxx | |
import android.content.Context | |
import android.graphics.Bitmap | |
import android.graphics.PixelFormat | |
import android.hardware.display.DisplayManager | |
import android.hardware.display.VirtualDisplay | |
import android.media.ImageReader | |
import android.media.projection.MediaProjection | |
import android.util.Log |