Skip to content

Instantly share code, notes, and snippets.

Avatar

Johan Steenkamp jsteenkamp

View GitHub Profile
@jsteenkamp
jsteenkamp / webWorker.js
Created Oct 25, 2020 — forked from vitkon/webWorker.js
Long polling with web workers
View webWorker.js
function workerFunction() {
this.addEventListener('message', (e) => {
console.log('log2: ', e);
fetchUrl(e.data);
})
const fetchUrl = (url) => {
fetch(url)
.then((response) => {
console.log(response);
@jsteenkamp
jsteenkamp / net.js
Created Nov 19, 2018 — forked from sid24rane/net.js
Simple TCP Client and Server in Node.js (Covering all useful Properties & Methods)
View net.js
var net = require('net');
// creates the server
var server = net.createServer();
//emitted when server closes ...not emitted until all connections closes.
server.on('close',function(){
console.log('Server closed !');
});
View App.js
import React, { Suspense, useState } from "react";
import { unstable_createResource as createResource } from "react-cache";
import {
Combobox,
ComboboxInput,
ComboboxList,
ComboboxOption
} from "./Combobox2.js";
function App({ tabIndex, navigate }) {
@jsteenkamp
jsteenkamp / ladder.md
Created Nov 11, 2018 — forked from jamtur01/ladder.md
Kickstarter Engineering Ladder
@jsteenkamp
jsteenkamp / README.md
Created Sep 4, 2018
Simple queue using async/await
View README.md

Queue using async/await

Implement a queue using async/await.

I created a single instance, easy enough to convert to a factory if you want multiple queues or add features like timeout with configuration object.

Although this solution is simple and does not require any additional libraries I do not think it is robust. For example retries after errors or timeouts is not supported. Rather than solve these issues it makes more sense to look at proven solutions such as message/task queues.

Usage

@jsteenkamp
jsteenkamp / foo.js
Last active Aug 27, 2018 — forked from ryanflorence/foo.js
Animation/transition using react spring
View foo.js
// Adds a lovely fade in of the modal
// and a gentle slide-down of the modal content
class Demo extends React.Component {
state = { showDialog: false };
render() {
return (
<div>
<button onClick={() => this.setState({ showDialog: true })}>
Show Dialog
</button>
@jsteenkamp
jsteenkamp / elevations.js
Created Jun 22, 2018
Google Material Design Elevations
View elevations.js
// Google Material Design 1-24dp elevations (shadows)
// https://github.com/material-components/material-components-web/blob/master/packages/mdc-elevation/_variables.scss
const umbraOpacity = '0.2';
const penumbraOpacity = '0.14';
const ambientOpacity = '0.12';
// map index are [0-24]
const elevationUmbraMap = [
@jsteenkamp
jsteenkamp / upload.cfc
Created Jul 30, 2011
ColdFusion code for Plupload file uploading including chunked transfers
View upload.cfc
<cfcomponent>
<cffunction name="upload" access="remote" returntype="struct" returnformat="json" output="false">
<cfscript>
var uploadDir = expandPath('.') & '/uploads/'; // should be a temp directory that you clear periodically to flush orphaned files
var uploadFile = uploadDir & arguments.NAME;
var response = {'result' = arguments.NAME, 'id' = 0};
var result = {};
// if chunked append chunk number to filename for reassembly
if (structKeyExists(arguments, 'CHUNKS')){
@jsteenkamp
jsteenkamp / index.js
Created Jun 14, 2016
React Stand Alone component with config
View index.js
// only entry point for CSS processed via webpack
import '../styles/main.scss';
import React from 'react';
import { render } from 'react-dom';
import { browserHistory } from 'react-router';
import configureStore from './store';
import root, { Root } from './root';
const store = configureStore(root.rootInitialState);
You can’t perform that action at this time.