Skip to content

Instantly share code, notes, and snippets.

View MattMorgis's full-sized avatar

Matt Morgis MattMorgis

View GitHub Profile
@MattMorgis
MattMorgis / request-stream-promise.js
Last active May 8, 2019 15:05
Request Stream as Promise
const request = require("request");
function requestPromiseStream(uri, requestOptions) {
return new Promise(function(resolve, reject) {
var req = request(uri, requestOptions);
req.on("error", reject);
req.on("response", function(res) {
// pause the stream so that it isn't flowing during the async promise hop
res.pause();
if (res.statusCode !== 200) {
@MattMorgis
MattMorgis / package.json
Last active May 26, 2022 15:17
Parse JSON with Async Iterator
{
"name": "async-iterator-with-json-stream",
"version": "0.1.0",
"description": "Use an async iterator or generator with streaming JSON.parse",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Matt Morgis",
"license": "MIT",
@MattMorgis
MattMorgis / bd3d4befe38185704bf0fc875e9deed6|configuration.json
Last active October 20, 2021 19:04
Visual Studio Code Settings Sync Gist
{"contents":{"launch":{"version":"0.2.0","configurations":[{"name":"Python: Current File (Integrated Terminal)","type":"python","request":"launch","program":"${file}","console":"integratedTerminal","cwd":"${workspaceFolder}/02"}]}},"overrides":[],"keys":["launch.version","launch.configurations"]}
@MattMorgis
MattMorgis / iOS-iFrame-Fix.css
Created March 25, 2017 01:21
Fixes various scrolling issues with embedded iFrames on iOS
html, body {
height: 100%;
overflow: auto;
-webkit-overflow-scrolling: touch;
}
@MattMorgis
MattMorgis / random-ad.html
Last active May 8, 2019 15:06
Display Random Ad (WordPress or HTML)
<script type="text/javascript">
var total_images = 3;
var random_number = Math.floor((Math.random()*total_images));
var random_img = new Array();
random_img[0] = '<a href="http://google.com"><img src="http://domain.com/images/ad1.gif"></a>';
random_img[1] = '<a href="http://google.com"><img src="http://domain.com/images/ad2.gif"></a>';
random_img[2] = '<a href="http://google.com"><img src="http://domain.com/images/ad3.gif"></a>';
document.write(random_img[random_number]);
</script>