Skip to content

Instantly share code, notes, and snippets.

View zv3's full-sized avatar

Diego Zacarías V. zv3

  • void0
  • Asunción, PY
  • 07:21 - 4h behind
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
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 July 21, 2025 17:36
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 March 20, 2025 17:17
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');
@idleberg
idleberg / Install-Mcrypt.md
Last active June 24, 2025 10:26
Install Mcrypt on macOS

Setup php-mcrypt on macOS (and versions of Mac OS X)

These steps should have been mentioned in the prerequisites of the Laravel Installation Guide, since I'm surely not the only person trying to get Laravel running on macOS.

Install

Install Mcrypt using Homebrew and PECL (comes with PHP)

# PHP 7.3