Skip to content

Instantly share code, notes, and snippets.

View kevgathuku's full-sized avatar

Kevin Gathuku kevgathuku

View GitHub Profile
@kevgathuku
kevgathuku / docker_kill.sh
Created February 13, 2018 09:43 — forked from evanscottgray/docker_kill.sh
kill all docker containers at once...
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt
@kevgathuku
kevgathuku / uuid_url64.py
Created February 7, 2018 11:55 — forked from mattupstate/uuid_url64.py
Generate unique, URL friendly ID's based on UUID with Python
import re
import uuid
import base64
def uuid_url64():
"""Returns a unique, 16 byte, URL safe ID by combining UUID and Base64
"""
rv = base64.b64encode(uuid.uuid4().bytes).decode('utf-8')
return re.sub(r'[\=\+\/]', lambda m: {'+': '-', '/': '_', '=': ''}[m.group(0)], rv)
object Main {
def main(args: Array[String]): Unit =
println("Hello, Scala developer!")
}
@kevgathuku
kevgathuku / requestAnimationFrame.js
Created August 17, 2017 19:47 — forked from jacob-beltran/requestAnimationFrame.js
React Performance: requestAnimationFrame Example
// How to ensure that our animation loop ends on component unount
componentDidMount() {
this.startLoop();
}
componentWillUnmount() {
this.stopLoop();
}

Rect - this.ref.getAbsolutePosition() - Returns position of top left corner of Rect
Circle - this.ref.getAbsolutePosition() - Returns position of center of Circle

;; try this form-by-form at a REPL
(require '[clojure.spec.alpha :as s])
;; create an inline DSL to describe the FizzBuzz world
(defmacro divides-by
[nm n]
`(s/def ~nm (s/and pos-int? #(zero? (mod % ~n)))))
;; specify FizzBuzz
(divides-by ::fizz 3)
@kevgathuku
kevgathuku / ID.js
Created August 14, 2017 22:40
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
(require 'hello)

Requires the user-defined hello namespace, typically defined in src if using boot

(require :reload 'hello)

Reloads the latest code from the hello namespace. This is in case this was already required and some new code has been added.

import React from 'react';
import { Layer, Rect, Stage, Line, Circle, Group } from 'react-konva';
import Konva from 'konva';
import compose from 'recompose/compose';
import { connect } from 'react-redux';
import { addRectangle } from 'vclub/redux/club/whiteboard';
const enhance = compose(
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Elm from 'react-elm-components';
import { Main } from './Buttons.js';
class App extends Component {
render() {
return (