Skip to content

Instantly share code, notes, and snippets.

View kennethlynne's full-sized avatar

Kenneth Lynne kennethlynne

View GitHub Profile
import { action } from '@storybook/addon-actions';
import React from 'react';
import { Button } from '~components';
export default {
title: 'Button',
};
export const primary = () => (
<Button onPress={action('clicked')} title={'Hello'} variant={'primary'} />
@kennethlynne
kennethlynne / isPortAvailable.ts
Last active November 9, 2019 20:03
Check if a port is available
import net from 'net';
export const isPortAvailable = (port: number): Promise<boolean> => {
return new Promise(resolve => {
const server: net.Server = net
.createServer()
.once('error', err => resolve(false))
.once('listening', () => {
server.once('close', () => resolve(true));
server.close();
@kennethlynne
kennethlynne / Primes.ts
Created October 3, 2019 16:22
Prime number tools
import bigInt = require('big-integer');
let lookupTable: boolean[] = [];
export function sieve(table: boolean[], max: number): boolean[] {
console.time('generate lookup table');
table.length = 0;
table[0] = false;
table[1] = false;
@kennethlynne
kennethlynne / CURL FCM Push notification.txt
Last active May 30, 2018 11:00
Create push notifications through FCM from the command line with curl
curl --request POST \
--header 'Content-type: application/json' \
--header 'Authorization: key=<server key>' \
--data '
{
"to":"<receiver token>",
"notification": {
"title":"Title of your notification",
"body":"content of your notification"
},
@kennethlynne
kennethlynne / Dockerfile
Last active February 9, 2018 11:09
Multi-stage docker for node apps
# ---- Base image ----
FROM node:8.9.4 AS base
RUN JOBS=MAX npm set progress=false && npm config set depth 0
WORKDIR /workdir
COPY /package*.json .
COPY /.npmrc .
# ---- Build ----
FROM base AS build
@kennethlynne
kennethlynne / wallaby.js
Created January 26, 2018 10:13
wallaby monorepo config
const path = require('path');
module.exports = function (wallaby) {
process.env.NODE_PATH += path.delimiter + path.join(wallaby.projectCacheDir, 'packages');
return {
files: [
{
pattern: "packages/**",
@kennethlynne
kennethlynne / find_replace
Created January 4, 2018 16:08 — forked from alobato/find_replace
Find and replace text in multiple files
# Find and replace text in multiple files
# http://www.24hourapps.com/2009/03/linux-tips-17-find-and-replace-text-in.html
# Multiple file find and replace is a rarely used, but an extremely time saving, ability of
# Linux that I cannot live without. It can be achieved by chaining a few commands together
# to get the list of files you want to change (find), make sure the files contain the strings
# you want to replace (grep), and do the replacements (sed).
# Lets say we have a lot of code that uses the function registerUser that was implemented when
# there was only one class of users, but now another class of users need to access the system
@kennethlynne
kennethlynne / decorateWithSequenceId.js
Created December 8, 2017 11:00
Sequence id on pubnub
const db = require('kvstore');
const console = require('console');
export default (request) => {
const {channels} = request;
const queue = channels
.map((channelName) => {
console.debug(`Get counter for channel "${channelName}"`);
@kennethlynne
kennethlynne / Delay.tsx
Created October 3, 2017 09:39
Component to delay rendering
import * as React from 'react';
interface IProps {
children: JSX.Element;
delay?: number;
}
interface IState {
wait: boolean;
}
@kennethlynne
kennethlynne / config.cfg
Last active July 22, 2017 15:12
-novid -tickrate 128 -nojoy -lv -freq 144 -high +exec autoexec.cfg
cl_crosshairalpha "255"
cl_crosshaircolor "5"
cl_crosshaircolor_b "50"
cl_crosshaircolor_r "50"
cl_crosshaircolor_g "250"
cl_crosshairdot "1"
cl_crosshairgap "0"
cl_crosshairsize "5"
cl_crosshairstyle "4"
cl_crosshairusealpha "1"