Skip to content

Instantly share code, notes, and snippets.

@yurifrl
yurifrl / kube-port-foward
Last active October 15, 2018 19:57
A bash script for kubectl port-foward, copy of https://github.com/johanhaleby/kubetail
#!/bin/bash
readonly PROGNAME=$(basename $0)
default_since="10s"
default_namespace="default"
default_line_buffered=""
default_colored_output="pod"
line_buffered="${default_line_buffered}"
@yurifrl
yurifrl / chain.js
Last active April 12, 2017 21:33
Promise chaining
// TL;DR
// return arrays
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
// http://stackoverflow.com/questions/28250680/how-do-i-access-previous-promise-results-in-a-then-chain
// http://stackoverflow.com/questions/22892681/what-patterns-are-there-for-passing-state-through-a-chain-of-promises-in-javascr
// http://bluebirdjs.com/docs/api/spread.html
// You design your api like aways, put when you want to pass a value, you pass Promise.all, and you do this in
// process of chaining it, your api, doesn't need to be awere of promises
@yurifrl
yurifrl / sample.hs
Created March 24, 2017 06:59
Understanding "Haskell notations"
-- This that the function toInt takes a String and returns a Integer
toInt :: String -> Int
-- This means that the function run takes 'a' and returns a 'b'
run :: a -> b
-- https://www.fpcomplete.com/blog/2012/09/ten-things-you-should-know-about-haskell-syntax
-- http://stackoverflow.com/questions/5926826/what-does-double-colon-stand-for-in-haskell
@yurifrl
yurifrl / tail-to-browser.sh
Created March 2, 2017 03:22
tail -f to the web-browser
# https://medium.com/@joewalnes/tail-f-to-the-web-browser-b933d9056cc#.nzwlj0wp6
# Server
$ (echo -e ‘HTTP/1.1 200 OK\nAccess-Control-Allow-Origin: *\nContent-type: text/event-stream\n’ && tail -f /path/to/some/file | sed -u -e ‘s/^/data: /;s/$/\n/’) | nc -l 1234
# Browser
new EventSource("http://host:1234/").onmessage = function(e) {
console.log(e.data);
};
@yurifrl
yurifrl / install.sh
Created February 20, 2017 03:56
curl from github whiout knowing version
cd /tmp
repo="ginatrapani/todo.txt-cli"
url=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | sed -n -e '/"browser_download_url":/ s/^.*"\(.*\)".*/\1/p' | grep tar.gz)
wget $url -O latest.tar.gz
mkdir -p /usr/local/src/todo-txt
tar -xvzf latest.tar.gz -C /usr/local/src/todo-txt --strip-components 1
rm latest.tar.gz
cd /usr/local/src/todo-txt && find . -iname \*.sh | xargs chmod +x
cp /usr/local/src/todo-txt/*.sh /usr/local/bin/
mkdir -p "$TODO_ACTIONS_DIR"
@yurifrl
yurifrl / Dockerfile
Created February 1, 2017 22:04
Docker yarn
# https://github.com/containership/alpine-node-yarn/blob/master/Dockerfile
FROM node:alpine
# Add yarn to env
# Ember-cli need this TEMP https://github.com/stefanpenner/async-disk-cache/issues/31
ENV PATH /root/.yarn/bin:$PATH
ENV TMPDIR /tmp
#
RUN apk update && apk upgrade && \
@yurifrl
yurifrl / cm.yml
Created December 6, 2016 22:14
Kubernetes examples
apiVersion: v1
data:
proxy.conf: |
## Nginx Production Https Ember Server Configuration
## http redirects to https ##
server {
listen 443 ssl default deferred;
# @todo Check if the `server_name` is necessary
@yurifrl
yurifrl / docker-compose1.yml
Created December 12, 2016 23:10
Docker and Docker Compose examples
version: '2'
services:
web:
image: yurifl/node
command: npm run dev
working_dir: /app
ports:
- 8080:8080
- 9876:9876
volumes:
@yurifrl
yurifrl / TODO.md
Last active November 23, 2016 19:00
sample app todo

Demo Store process

current task:

todo:

  • [] <> . ?/?
  • the two is the previst pomodoro, and the interrogation is the spend pomodoros. 2/?
  • The first todo is to copy. 2/?

lorem lorem

  • [] lorem. 2/?
@yurifrl
yurifrl / pattern-matching.js
Created October 28, 2016 11:33
example of pattern maching
// taken from http://blog.mgechev.com/2013/01/21/functional-programming-with-javascript/
const $ = fun.parameter
const fact = fun(
[0, function () { return 1; }],
[$, function (n) { return n * fact(n - 1); }]
)