Skip to content

Instantly share code, notes, and snippets.

View iansinnott's full-sized avatar

Ian Sinnott iansinnott

View GitHub Profile
@iansinnott
iansinnott / node-basic-server.js
Last active April 5, 2019 07:58
A basic barebones server implementation in node. Zero dependencies.
const http = require('http');
const app = (req, res) => {
req.setEncoding('utf8');
let body = '';
req.on('data', chunk => {
body += chunk;
});

Keybase proof

I hereby claim:

  • I am iansinnott on github.
  • I am iansinnott (https://keybase.io/iansinnott) on keybase.
  • I have a public key ASCSnic_j82MSgJflY5T9BVoYf7wkId9syrJugHnaeqtlQo

To claim this, I am signing this object:

@iansinnott
iansinnott / .block
Created August 30, 2017 21:11
Bar Chart
license: gpl-3.0
@iansinnott
iansinnott / figlet_fonts.txt
Created July 16, 2017 00:25
Examples of using different figlet fonts. Just meant as a quick reference. Commands to generate each section is also listed.
figlet -f 3-d 'hello and welcome'
** ** ** **
/** /** /** /**
/** ***** /** /** ****** ****** ******* /**
/****** **///** /** /** **////** //////** //**///** ******
/**///**/******* /** /**/** /** ******* /** /** **///**
/** /**/**//// /** /**/** /** **////** /** /**/** /**
/** /**//****** *** ***//****** //******** *** /**//******
// // ////// /// /// ////// //////// /// // //////
**
@iansinnott
iansinnott / actions.js
Created June 20, 2017 18:39
epic testing
// actions.js
export const FETCH = 'someModule/FETCH';
export const FETCH_SUCCESS = 'someModule/FETCH_SUCCESS';
export const FETCH_FAILURE = 'someModule/FETCH_FAILURE';
export const fetch = () => ({ type: FETCH });
@iansinnott
iansinnott / rx-file-reader.js
Created June 5, 2017 19:36
A simple Rx abstraction over the FileReader API
/**
* Read the text contents of a File or Blob using the FileReader interface.
* This is an async interface so it makes sense to handle it with Rx.
* @param {blob} File | Blob
* @return Observable<string>
*/
const readFile = (blob) => Observable.create(obs => {
if (!(blob instanceof Blob)) {
obs.error(new Error('`blob` must be an instance of File or Blob.'));
return;
@iansinnott
iansinnott / app.js
Last active June 12, 2017 05:40
Amazing Epic Server
const http = require('http');
const { createApp, send } = require('epic-server');
/**
* Create your epics.
* type Epic = (req$: Observable<Request>, ...dependencies: any) => Observable<Response>
* type of Request and Response TBD. Will related to nodes (req, res) objects
* passed to the handler in createServer.
*/
@iansinnott
iansinnott / docker-compose.yml
Last active December 8, 2017 21:52
quick-wordpress-docker-compose
version: '3'
services:
wordpress:
image: wordpress:4.9
ports:
- "127.0.0.1:8080:80"
volumes:
- ./wp-content/themes:/var/www/html/wp-content/themes
@iansinnott
iansinnott / inject.js
Last active January 11, 2017 20:07
Inject common scripts into the browser
((global) => {
var dict = {
ramda: '//cdnjs.cloudflare.com/ajax/libs/ramda/0.23.0/ramda.min.js',
rxjs: 'https://unpkg.com/@reactivex/rxjs/dist/global/Rx.js',
'lodash/fp': 'https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js', // Exposed as `_`
};
// Returns the script tag
global.inject = (src) => {
var script = document.createElement('script');
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
class SvgBackground extends React.Component {
render() {
return (
<svg xmlns='http://www.w3.org/2000/svg' width={100} height={100}>
<rect width={100} height={100} fill='#269' />
<g fill='#6494b7'>
<rect width={100} height={1} y={20} />