Skip to content

Instantly share code, notes, and snippets.

View pxwise's full-sized avatar
🌎
[object Object], NaN

Shawn Stedman pxwise

🌎
[object Object], NaN
View GitHub Profile
@jsoverson
jsoverson / intercept.js
Created February 19, 2019 21:28
Intercept responses with chrome and puppeteer
const puppeteer = require('puppeteer');
const prettier = require('prettier');
const atob = require('atob');
const btoa = require('btoa');
const scriptUrlPatterns = [
'*'
]
const requestCache = new Map();
@vkarpov15
vkarpov15 / promise1.js
Created April 5, 2018 12:38
Write Your Own Node.js Promise Library from Scratch, Part 1
class MyPromise {
constructor(executor) {
if (typeof executor !== 'function') {
throw new Error('Executor must be a function');
}
// Internal state. `$state` is the state of the promise, and `$chained` is
// an array of the functions we need to call once this promise is settled.
this.$state = 'PENDING';
this.$chained = [];
@miguelmota
miguelmota / rev.sh
Created February 22, 2018 03:20
Bash get first n characters of git commit hash
git rev-parse HEAD | cut -c1-7
/* global mapboxgl */
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Immutable from 'immutable';
import { clickMap, setStyle } from '../actions/index';
import diffStyles from '../utilities/diff.js';
@stella-yc
stella-yc / dijkstra.js
Last active August 24, 2023 20:46
Dijkstra's Algorithm in Javascript using a weighted graph
const problem = {
start: {A: 5, B: 2},
A: {C: 4, D: 2},
B: {A: 8, D: 7},
C: {D: 6, finish: 3},
D: {finish: 1},
finish: {}
};
const lowestCostNode = (costs, processed) => {
@m99coder
m99coder / server.js
Last active December 2, 2022 12:30
Node.js: Proxy multipart/form-data file upload to application/octet-stream REST API call
#!/usr/bin/env node
// dependencies
const https = require('https');
const express = require('express');
const multer = require('multer');
// app
const app = express();
const storage = multer.memoryStorage();
@daveriedstra
daveriedstra / loadModules.ts
Last active January 13, 2017 23:51
A way to guess and load modules before bootstrapping angular
/**
This module exports one function, loadModules, which guesses then downloads the modules
which need to be loaded before bootstrapping the application. loadModules() returns an
array of Promises which can be waited on using Promise.all.
The guessing process can handle
- normal loader as route.loadChildren
- redirect as route.redirectTo
- nested lazy loaders using route.data.alsoLoad*
@Directive({
selector: '[universalAd],[universal-ad]'
})
class UniversalAd {
constructor(
@Attribute('id') public id: string,
public adRegistry: MyAdRegistry,
public elementRef: ElementRef,
public cdRef: ChangeDetectorRef) {
@dimitardanailov
dimitardanailov / .zshrc
Last active February 23, 2024 01:34
My personal zsh and tmux configurations
# Path to your oh-my-zsh installation.
export ZSH=/Users/dimitar.danailov/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# ZSH_THEME="robbyrussell"
ZSH_THEME="agnoster"
<script>
window.Promise || document.write('<script src="https://unpkg.com/es6-promise@3.2.1/dist/es6-promise.min.js"><\/script>');
window.fetch || document.write('<script src="https://unpkg.com/whatwg-fetch@1.0.0/fetch.js"><\/script>');
</script>