Skip to content

Instantly share code, notes, and snippets.

View mendaomn's full-sized avatar

Alessandro Menduni mendaomn

View GitHub Profile
@mendaomn
mendaomn / Dockerfile
Last active June 22, 2022 13:21
Nginx reverse proxy setup
FROM nginx:alpine
WORKDIR /etc/nginx
COPY ./default.conf ./conf.d/default.conf
EXPOSE 80
ENTRYPOINT [ "nginx" ]
CMD [ "-g", "daemon off;" ]
andys8.jest-snippets
bierner.lit-html
blanu.vscode-styled-jsx
dbaeumer.vscode-eslint
donjayamanne.githistory
eamodio.gitlens
esbenp.prettier-vscode
felixfbecker.php-debug
felixfbecker.php-intellisense
felixfbecker.php-pack
{
"atomKeymap.promptV3Features": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": false,
"git.autofetch": false,
"window.zoomLevel": 1,
"editor.tabSize": 2,
"html.format.indentInnerHtml": true,
"javascript.validate.enable": false,
"scss.validate": false,
@mendaomn
mendaomn / fake-axios.js
Last active April 20, 2020 07:40
An example of how one could mimic axios' API over standard Fetch.
const axios = {
commons: {
headers: {}
},
async _fetchWithCommons(url, options) {
const response = await fetch(url, {
...this.commons,
...options
@mendaomn
mendaomn / fromTimeout.js
Last active May 4, 2020 15:09
Create an Rx.Observable out of setTimeout/setInterval
import { Observable } from 'rxjs'
const fromTimeout = ts => Observable.create(observer => {
const handle = setTimeout(() => {
observer.next()
observer.complete()
}, ts)
return function dispose() {
observer.onComplete()
@mendaomn
mendaomn / observables-1.js
Created March 29, 2020 17:13
Naive implementation of an Observable. This is just an exercise to help me learning this pattern
class Observable {
static fromPublisher(publisher) {
return new Observable({
publisher
})
}
static fromObservable(observable, extentions) {
return new Observable({
...observable,
@mendaomn
mendaomn / Vagrantfile
Last active May 6, 2019 07:19
Local Kubernetes cluster setup with vagrant and ansible
IMAGE_NAME = "bento/ubuntu-16.04"
N = 2
Vagrant.configure("2") do |config|
config.ssh.insert_key = false
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
@mendaomn
mendaomn / classList.js
Last active October 18, 2018 06:45
Implementation of Elm's classList function. Allows to conditionally apply classes according to the current state
/**
* @fileOverview Implementation of Elm's classList function.
* Allows to conditionally apply classes according to the current state
* [source]{@link https://package.elm-lang.org/packages/evancz/elm-html/3.0.0/Html-Attributes#classList}
*
* @param {string[ [string, bool] ]} rules - An array of rules. Every rule has 2 elements:
* element.0: string, the class you want to apply
* element.1: bool, whether or not to apply the class
* @return {string} - The interpolated string of classes
*
@mendaomn
mendaomn / shopify-buy-button.js
Created August 7, 2018 09:16
Code used for embedding Shopify's buy button
ui.createComponent('product', {
id: theProductID,
node: myNode,
moneyFormat: '%E2%82%AC%7B%7Bamount_with_comma_separator%7D%7D',
options: {
"product": {
"variantId": "all",
"width": "100%",
"contents": {
"img": false,
@mendaomn
mendaomn / loadCSS.js
Created January 8, 2017 20:53
loadCSS.js minified code
!function(e){"use strict";var n=function(n,t,o){function i(e){return a.body?e():void setTimeout(function(){i(e)})}function r(){l.addEventListener&&l.removeEventListener("load",r),l.media=o||"all"}var d,a=e.document,l=a.createElement("link");if(t)d=t;else{var s=(a.body||a.getElementsByTagName("head")[0]).childNodes;d=s[s.length-1]}var f=a.styleSheets;l.rel="stylesheet",l.href=n,l.media="only x",i(function(){d.parentNode.insertBefore(l,t?d:d.nextSibling)});var u=function(e){for(var n=l.href,t=f.length;t--;)if(f[t].href===n)return e();setTimeout(function(){u(e)})};return l.addEventListener&&l.addEventListener("load",r),l.onloadcssdefined=u,u(r),l};"undefined"!=typeof exports?exports.loadCSS=n:e.loadCSS=n}("undefined"!=typeof global?global:this);