Skip to content

Instantly share code, notes, and snippets.

View supasympa's full-sized avatar
🎧
💻⌨️🖥 @barclaytweets

Lewis Barclay supasympa

🎧
💻⌨️🖥 @barclaytweets
  • Supa Sympa Ltd
  • London
View GitHub Profile
@supasympa
supasympa / git-file-changes.js
Created February 19, 2019 23:38
Analyse file changes across a git repo.
const gitlog = require('gitlog');
const {resolve} = require('path');
const changesToFiles = (opts = { repoPath: __dirname }) => {
const commitMap = gitlog({
repo: opts.repoPath
, number: opts.max || 1999999
, execOptions:
{
maxBuffer: 99999 * 1024
@supasympa
supasympa / functor.js
Last active January 23, 2019 08:58
Functor
const log = (i) => {
console.log(i);
return i;
};
const base = v => ({
valueOf: () => v,
toString: () => v.toString()
});
@supasympa
supasympa / dockerfile.dev
Last active December 6, 2018 23:56
Development environment
#
# Development environment
#
FROM node:10.14.1
@supasympa
supasympa / scrape_tweets_twitter_thread.js
Created November 27, 2018 20:27
Scrape all tweets in Twitter thread from browser.
JSON.stringify([].slice.call(document.querySelectorAll('.js-tweet-text-container')).map((e) => e.textContent))
@supasympa
supasympa / get-primes.js
Last active September 25, 2018 16:32
A function to get all prime numbers below a specified value.
function sieve(n){
let arr = new Array(n);
for(let i = 0; i< arr.length; i++){
arr[i] = true;
}
arr[0] = null;
arr[1] = null;
function setToFalseEvery(n){
@supasympa
supasympa / javascript_ioc.js
Last active August 22, 2018 21:11
Javascript IOC
/*
IOC ...
*/
const Bar = () => {
return {
hello: 'world'
};
};
@supasympa
supasympa / mocha--async-await.js
Created August 11, 2017 22:14
Simple Mocha async/await example
const chai = require('chai');
const expect = chai.expect;
describe('An async await test', () => {
it(`Should work.`, async () => {
const HELLO_WORLD = "Hello World!";
const run = Promise.resolve(HELLO_WORLD);
const message = await run;
expect(message).to.equal(HELLO_WORLD);
@supasympa
supasympa / simple-async-await-example.js
Created August 11, 2017 21:25
The simplest Javascript async / await I could come up with
const main = async () => console.log(await Promise.resolve("Hello World!"));
main();
@supasympa
supasympa / FizzBuzz.js
Created May 3, 2017 22:58
My JavaScript fizz buzz
console.log('fizzbuzz.js');
const checker = (mod) => (num) => num % mod === 0;
const isFizz = (num) => checker(3)(num) ;
const isBuzz = (num) => checker(5)(num) ;
const isFizzBuzz = (num) => isFizz(num) && isBuzz(num);
const fizzBuzzCheck = (num) => {
let fizzBuzz = num;
@supasympa
supasympa / compose.js
Created April 26, 2017 21:43
Functional Javascript compose example
const add = (...args) => {
console.log('add ', args)
return args.reduce((acc, n) => acc += parseInt(n), 0)
}
const exec = (fn, ...args) => {
console.log('exec ', fn, args)
return fn.apply(fn, args)
}