Skip to content

Instantly share code, notes, and snippets.

View inakianduaga's full-sized avatar

Inaki Anduaga inakianduaga

View GitHub Profile
@inakianduaga
inakianduaga / docker_commands.sh
Last active August 29, 2015 14:18
Docker extended commands w/ autocompletion for bash
#!/usr/bin/env bash
# Docker extended commands
#
# `./docker` bash command wrapper to add additional functionality to the docker command, w/ autocompletion support (docker v1.6)
#
# Installation: Add this directly to `~/.bashrc` (or whatever your bash startup file is called) or save to a file and
# source it within `~/.bashrc`.
#
# Usage:
# docker wipe <container(s)/id(s)>: Gracefully stops and removes a container(s)
#!/usr/bin/perl
#
# Json Wrapper: Wraps Stdin input into json template for logging purposes.
#
# The idea is to use this script to wrap logs from cli commands so they can be used
# for rsyslog @cee log processing.
#
# Author: Inaki Anduaga <inaki@inakianduaga.com>
#
# Usage: <COMMAND> | ./jsonWrap.pl <MODE> <CHANNEL> <KEY1:VAL1> <KEY2:VAL2> ...
@inakianduaga
inakianduaga / IWebhook.ts
Created October 29, 2015 22:01
Github webhook events typescript types
/**
* Github Webhook event types
* https://developer.github.com/v3/activity/events/types/
*/
module IWebhook {
interface IUser {
login: string,
id: number,
avatar_url: string,
@inakianduaga
inakianduaga / Main.scala
Created April 20, 2016 23:57
Coursera Scala Functional Programming 1st Week balance brackets
/**
* Criteria: Every closing parenthesis ) must have a unique opening ( parenthesis before it
*
* For every closing parenthesis, we search for the first opening parenthesis and remove it, and keep going
*/
def balance(chars: List[Char]): Boolean =
(chars.indexOf(')'), chars.indexOf('(')) match {
case (leftMostClosing, leftMostOpening) if leftMostClosing == -1 && leftMostOpening != -1 => false // no closing / some opening => fail
case (leftMostClosing, leftMostOpening) if leftMostClosing == -1 && leftMostOpening == -1 => true // no closing or opening => ok
case (leftMostClosing, leftMostOpening) if leftMostClosing != 1 && leftMostOpening == -1 => false // closing but no opening => fail
@inakianduaga
inakianduaga / mapReduce.scala
Last active April 27, 2016 22:58
Coursera Scala Functional Programming 3rd Week factorial generalization
/**
* 1. Write a product function that calculates the product of the values of a function for the points on a given interval
*/
def product(f: Double => Double)(a: Double, b: Double): Double = {
def loop(a: Double, acc: Double): Double =
if(a > b) acc else loop(a+1, f(a) * acc)
loop(a, 1)
}
@inakianduaga
inakianduaga / TypescriptIntro.html
Created February 1, 2017 09:52
Typescript 5 min intro
<!DOCTYPE html>
<html>
<head>
<title>Typescript Intro</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
@inakianduaga
inakianduaga / dom.test.ts
Last active August 14, 2018 17:07
Redux for vanillaJS Medium.com article - Dom test example
import "jest";
describe("DOM image manipulation", () => {
test("applies class to image on applyFilterToImage", () => {
document.body.innerHTML = `
<div id="some-dom-id">
<div class="image-wrapper">
<img class="image selected" src="testImage">
<img class="image" src="testImage2">
<img class="image" src="testImage3">
@inakianduaga
inakianduaga / dom.ts
Last active August 16, 2018 16:57
Redux for vanillaJS Medium.com article - DOM bridge
// Some CSS styles for our component
import "./gallery.scss";
/**
* DOM mutations. Include all DOM manipulation for this component here
*/
export const mutations = {
select: (index: number) => {
mutations.clearSelected();
const images = elements.images();
@inakianduaga
inakianduaga / filestructure.md
Created August 14, 2018 16:10
Redux for vanillaJS Medium.com article - File structure
ui/src/
      /entrypoints/main.ts
      /store/configureStore.ts
            /rootReducer.ts
      /components/gallery/
                         /actions.ts
                         /gallery.scss
                         /dom.ts
 /middleware.ts