Skip to content

Instantly share code, notes, and snippets.

View zv3's full-sized avatar

Diego Zacarías V. zv3

  • void0
  • Asunción, PY
  • 03:44 (UTC -04:00)
View GitHub Profile
import invariant from "tiny-invariant";
class AmalgoBox extends HTMLElement {
get input() {
return this.querySelector("input") as HTMLInputElement;
}
get button() {
return this.querySelector("button") as HTMLButtonElement;
}
@hamg26
hamg26 / rate_limited_api.js
Created January 4, 2022 22:32
Rate limited API consumption (FIFO)
const https = require('https')
const HOST = "";
const PATH = ""
const TOKEN = ""
const RATE_LMIT = 10;
const RATE_INTERVAL = 1000; //ms
const post = (phone, code) => new Promise((resolve, reject) => {
node_modules

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@m-sanders
m-sanders / api.media.example.com.crt
Created November 20, 2015 20:41
guardian/grid config for OS X
# Location: /usr/local/etc/nginx/certs/api.media.example.com.crt
-----BEGIN CERTIFICATE-----
MIICQTCCAaoCCQCggawqROCieTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQGEwJB
VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
cyBQdHkgTHRkMR4wHAYDVQQDExVhcGkubWVkaWEuZXhhbXBsZS5jb20wHhcNMTUx
MTE2MjMwNzE5WhcNMTUxMjE2MjMwNzE5WjBlMQswCQYDVQQGEwJBVTETMBEGA1UE
CBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRk
MR4wHAYDVQQDExVhcGkubWVkaWEuZXhhbXBsZS5jb20wgZ8wDQYJKoZIhvcNAQEB
BQADgY0AMIGJAoGBALS2YyA9wksORUyeuN1i3ZJDInxdM0ezxpMpzI40zYQQV7Eu
In Application.scala:
object MyServer extends AutowirePlayServer[Api] {
override def routes(target: Api) = route[Api](target)
override def createImpl(autowireContext: AutowireContext): Api = new ServerImpl(autowireContext)
}
object Application extends Controller {
def api = PlayAutowire.api(MyServer)_
}
@mkotsbak
mkotsbak / PlayAutowire.scala
Last active May 20, 2016 18:41
Play server wiring to get Autowire to work with extra request information like IP-addresses and authentication. See how to use it here: https://gist.github.com/mkotsbak/122940aa003db9708093
package controllers
import play.api.http.{ContentTypes, ContentTypeOf}
import upickle.Js
import upickle.default._
import play.api.mvc._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@taufik-nurrohman
taufik-nurrohman / php-html-css-js-minifier.php
Last active February 23, 2024 04:30
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/x.minify>
namespace x\minify\_ { // start namespace
$n = __NAMESPACE__;
\define($n . "\\token_boolean", '\b(?:true|false)\b');
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+');
@demisx
demisx / gulpfile.js
Last active July 14, 2022 16:06
Gulp 4 gulpfile.js
// Gulp 4
var gulp = require('gulp');
var using = require('gulp-using');
var grep = require('gulp-grep');
var changed = require('gulp-changed');
var del = require('del');
var coffee = require('gulp-coffee');
var less = require('gulp-less');
var coffeelint = require('gulp-coffeelint');
var sourcemaps = require('gulp-sourcemaps');