Skip to content

Instantly share code, notes, and snippets.

View parkerproject's full-sized avatar

Parker parkerproject

View GitHub Profile
@parkerproject
parkerproject / widget.js
Created November 4, 2019 21:25 — forked from lukencode/widget.js
Starter template for creating jsonp embeddable widgets.
(function () {
var scriptName = "embed.js"; //name of this script, used to get reference to own tag
var jQuery; //noconflict reference to jquery
var jqueryPath = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js";
var jqueryVersion = "1.8.3";
var scriptTag; //reference to the html script tag
/******** Get reference to self (scriptTag) *********/
var allScripts = document.getElementsByTagName('script');
var iframe = document.createElement('iframe');
var html = '<body>Foo</body>';
iframe.src = 'data:text/html;charset=utf-8,' + encodeURI(html);
document.body.appendChild(iframe);
console.log('iframe.contentWindow =', iframe.contentWindow);
async function doSomething() {
await timeout(2000);
}
function timeout(ms) {
return new Promise((res,rej) => setTimeout(rej,ms));
}
Promise.race([
doSomething(),
timeout(1000)
@parkerproject
parkerproject / removeKeys.js
Created November 5, 2018 20:20 — forked from aurbano/removeKeys.js
Remove a property from a nested object, recursively
/**
* Remove all specified keys from an object, no matter how deep they are.
* The removal is done in place, so run it on a copy if you don't want to modify the original object.
* This function has no limit so circular objects will probably crash the browser
*
* @param obj The object from where you want to remove the keys
* @param keys An array of property names (strings) to remove
*/
function removeKeys(obj, keys){
var index;
@parkerproject
parkerproject / README.md
Created September 19, 2018 23:58 — forked from lukekarrys/ README.md
Node Crawler to find all domain links on a site and run a function on them

Node Crawler to find all domain links on a site and run a function on them

Linked to from http://lukecod.es/2012/11/18/random-problem-of-the-night/

What

This is a node.js crawler that will crawl an entire site (using crawl) to find all internal links in the entire site. It will then test each unique internal link for the presence of an optional string and then the query string into an object. All values with the same key from the query string will be pushed to an array for that key.

Usage

<html>
<head>
<style>
li{
list-style: none;
border-bottom: 1px solid #ccc;
}
.list span{
display: block;
padding: 5px 0;
@parkerproject
parkerproject / gulpfile.js
Created August 6, 2018 20:46 — forked from zwacky/gulpfile.js
Example gulpfile.js to get it going with LESS and AngularJS
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var rimraf = require('rimraf');
var paths = {
less: ['./less/*.less'],
js: ['./js/app/*.js', './js/app/**/*.js'],
jsView: ['./js/app/views/*.html'],
dist: {
css: './public/css/',
@parkerproject
parkerproject / ghost.js
Created June 26, 2018 20:32 — forked from aaronmfparr/ghost.js
A node script for making get requests of a Ghost blog's public API. Contains a function and configuration for a single blog.
// -----------------------------------------------------------------------------
// ghost.js
// Usage: node
// Send a get request to a ghost blog and return the response
// Ghost API: https://api.ghost.org/
// -----------------------------------------------------------------------------
//
// 'config' is not strictly necessary, as it is simply used to hold constants
const config = require('./config');
@parkerproject
parkerproject / HOC.js
Created April 5, 2018 05:17 — forked from Restuta/HOC.js
React HOC (Higher Order Component) Example
/* HOC fundamentally is just a function that accepts a Component and returns a Component:
(component) => {return componentOnSteroids; } or just component => componentOnSteroids;
Let's assume we want to wrap our components in another component that is used for debugging purposes,
it just wraps them in a DIV with "debug class on it".
Below ComponentToDebug is a React component.
*/
//HOC using Class
//it's a function that accepts ComponentToDebug and implicitly returns a Class
let DebugComponent = ComponentToDebug => class extends Component {
@parkerproject
parkerproject / index.js
Created March 23, 2018 19:43 — forked from srph/index.js
reactjs: an example of a high-order component useful for simple pagination.
import React, {PropTypes} from 'react';
import axios from 'axios';
/**
* This is a high-order component for Components
* for pages with pagination.
*
* #FEATURES:
* - Pages (list pages) are easier to test!
* - Fetching the data is a no-brainer