Skip to content

Instantly share code, notes, and snippets.

View obengwilliam's full-sized avatar
🎯
Focusing

Obeng William obengwilliam

🎯
Focusing
View GitHub Profile
@obengwilliam
obengwilliam / gist:971f8fa4c6955b5499ca7d5685aad9b6
Created September 27, 2018 11:09 — forked from DanilloCorvalan/gist:9805138
Node test upload file multi part superagent plus supertest
var request = require('supertest');
var fs = require('fs');
var reqData = {
title: 'Rahh!',
fileName: 'test-image.jpeg'
};
var req = request(context.app) //context.app = your express object
.post('/v1/images')
@obengwilliam
obengwilliam / test.js
Created September 16, 2018 14:34 — forked from ndugger/test.js
import { execFile } from 'child_process';
import { JSDOM } from 'jsdom';
const { Promise } = global;
const options = { resources: 'usable', runScripts: 'dangerously' };
const server = execFile('node', [ './dist/server/index.js' ], { cwd: process.cwd() });
const browser = { };
beforeAll(async () => {
@obengwilliam
obengwilliam / curl.md
Created August 17, 2018 13:17 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@obengwilliam
obengwilliam / web-servers.md
Created May 26, 2018 15:38 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000

How you can help reduce node_modules bloat

This recent reddit thread reveals discontent among the web development community about the sheer volume of stuff in a typical node_modules dir. 140MB in this case!

Is it a design flaw in npm?

Opinions in the thread varied from "I'm surprised npm even works" to "everything is fine". I'm not going to offer an opinion, just these two observations:

  1. node_modules dirs typically do contain lots of stuff that doesn't need to be there.
  2. The latest version mitigates overall size by flattening the dependency tree, but some of the bloat is beyond npm's control.
@obengwilliam
obengwilliam / git-compressing-and-deltas.md
Created February 2, 2018 11:04 — forked from matthewmccullough/git-compressing-and-deltas.md
Git, Compression, and Deltas - An explanation

Git Compression of Blobs and Packfiles.

Many users of Git are curious about the lack of delta compression at the object (blob) level when commits are first written. This efficiency is saved until the pack file is written. Loose objects are written in compressed, but non-delta format at the time of each commit.

A simple run though of a commit sequence with only the smallest change to the image (in uncompressed TIFF format to amplify the observable behavior) aids the understanding of this deferred and different approach efficiency.

The command sequence:

Create the repo:

@obengwilliam
obengwilliam / nltk-intro.py
Created July 26, 2017 10:40 — forked from alexbowe/nltk-intro.py
Demonstration of extracting key phrases with NLTK in Python
import nltk
text = """The Buddha, the Godhead, resides quite as comfortably in the circuits of a digital
computer or the gears of a cycle transmission as he does at the top of a mountain
or in the petals of a flower. To think otherwise is to demean the Buddha...which is
to demean oneself."""
# Used when tokenizing words
sentence_re = r'''(?x) # set flag to allow verbose regexps
([A-Z])(\.[A-Z])+\.? # abbreviations, e.g. U.S.A.
@obengwilliam
obengwilliam / README.md
Created July 19, 2017 10:04 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@obengwilliam
obengwilliam / copy-k8s-resources-across-namespaces.sh
Created June 29, 2017 08:33 — forked from simonswine/copy-k8s-resources-across-namespaces.sh
Copying kubernetes resources accross namespaces
kubectl get rs,secrets -o json --namespace old | jq '.items[].metadata.namespace = "new"' | kubectl create-f -