Skip to content

Instantly share code, notes, and snippets.

View guillemcanal's full-sized avatar

Guillem CANAL guillemcanal

View GitHub Profile
@guillemcanal
guillemcanal / Microsoft.PowerShell_profile.ps1
Last active February 23, 2022 22:14
Boxstarter Install Script
# Styling
# Import-Module posh-git
# Import-Module oh-my-posh
# Set-Theme Robbyrussell
# See: https://github.com/felixrieseberg/windows-development-environment
# Increase history
$MaximumHistoryCount = 10000
@guillemcanal
guillemcanal / disney.ts
Last active May 5, 2020 01:46
disney.ts
const pipe = (...fns: Function[]) => (x: any) =>
fns.reduce((v: any, f: Function) => f(v), x);
const chunker = (n: number) => (acc: any[], c: any, i: number): any[][] => {
(acc[(i / n) | 0] = acc[(i / n) | 0] || []).push(c);
return acc;
};
const multiplyBy = (n: number) => (x: number[]): number[] =>
x.map((v) => v * n);
@guillemcanal
guillemcanal / glibc-install.sh
Created March 27, 2020 13:07
glibc compat for alpine linux
#!/usr/bin/env sh
set -e
get_latest_release_version() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
}
package_installed() {
apk info -vv | grep "$1" 1> /dev/null
@guillemcanal
guillemcanal / i3-azerty.config
Created September 16, 2019 12:06
Config I3WM for AZERTY keyboard
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# theme
## Base16 Material Palenight
@guillemcanal
guillemcanal / puppeteer.js
Created April 2, 2019 22:05
control a chrome instance running on you Mac using a containerized puppeteer script
// First, run a Chrome instance on your Mac:
// /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 &> /dev/null &; disown
const puppeteer = require('puppeteer-core');
const axios = require('axios');
const getBrowserWSEndpoint = async (baseUrl) => {
const response = await axios.get(`http://${baseUrl}/json/version`);
return response.data.webSocketDebuggerUrl;
@guillemcanal
guillemcanal / sse.go
Created November 21, 2018 00:48 — forked from schmohlio/sse.go
Example SSE server in Golang
// v2 of the great example of SSE in go by @ismasan.
// includes fixes:
// * infinite loop ending in panic
// * closing a client twice
// * potentially blocked listen() from closing a connection during multiplex step.
package main
import (
"fmt"
"log"
@guillemcanal
guillemcanal / context.test.php
Last active July 19, 2018 09:10
Extract typed values from a context class using a callable.
<?php
declare(strict_types=1);
/**
* A Context class that holds typed values
* which can be extracted using a callable
*
* @see http://php.net/manual/fr/language.types.callable.php
*/
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "Swagger API Team",
"email": "apiteam@swagger.io",

Apply:

git stash apply

Unapply:

git stash show -p|git apply --reverse

@guillemcanal
guillemcanal / main.go
Last active February 26, 2018 07:19
Listen to docker container events. Handle reconnection when Docker goes away.
package main
import (
"context"
"fmt"
"io"
"time"
"github.com/cenk/backoff"
"github.com/docker/docker/api/types"