Skip to content

Instantly share code, notes, and snippets.

View matchs's full-sized avatar

Mateus Chagas matchs

View GitHub Profile
@matchs
matchs / hashStringAsNumber.js
Created May 23, 2019 11:50
A numeric hash function that takes a string and outputs a number
function hashNumber(str) {
let hash = 0;
if (str.length === 0) return hash;
for (let i = 0; i < str.length; i += 1) {
const char = str.charCodeAt(i);
hash = (hash << 5) - hash + char; // eslint-disable-line
hash &= hash; // eslint-disable-line
}
return Math.abs(hash);
}
@matchs
matchs / 0-README.md
Last active January 4, 2021 14:15 — forked from Overbryd/0-README.md
Cloudflare Fragment Caching

Cloudflare fragment rendering/caching

This worker script will evaluate your origin response, and replace html comments marked as fragment:key with a respective prefetch defined in a X-Fragments response header.

Usage

Your origin must include the X-Fragments header, specifying the a comma separated list of prefetch requests to make for that response.

< HTTP/1.1 200 OK

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@matchs
matchs / example.html
Created January 7, 2015 13:53
small test of a nodejs push service made back in 2013
<!doctype html>
<html>
<head>
<title>Socket.io Test</title>
<script src="/socket.io/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
</head>
<body>
<script>
var socket = io.connect();
@matchs
matchs / gist:ccb74537785ba9efa278
Created October 12, 2014 03:41
Subtrator: Operador.php
<?php
echo "<html><head><title>Operador: Soma</title></head>";
echo "<html><head><title>Operador: Subtração</title></head>";
echo '<form method="post" action="operacoes.php">';
echo '<label for="a">Valor A:</label><input type="text" maxlength="5" name="a" /><br/>';
echo '+<br/>';
echo '-<br/>';
echo '<label for="b">Valor B:</label><input type="text" maxlength="5" name="b" /><br/>';
echo '<input type="submit" value="Somar!" />';
echo '<input type="submit" value="Subtrair!" />';
@matchs
matchs / gist:548167c0f10190a073a8
Created October 12, 2014 03:40
Somador: Operador.php
<?php
echo "<html><head><title>Operador: Soma</title></head>";
echo '<form method="post" action="operacoes.php">';
echo '<label for="a">Valor A:</label><input type="text" maxlength="5" name="a" /><br/>';
echo '+<br/>';
echo '<label for="b">Valor B:</label><input type="text" maxlength="5" name="b" /><br/>';
echo '<input type="submit" value="Somar!" />';
echo '</form>';
if(isset($_POST['a'])){
$a = $_POST['a'];
@matchs
matchs / subtrator.xml
Created October 12, 2014 03:31
subtrator.xml
<?xml version="1.0"?>
<product id='subtrator'>
<name>Subtrator</name>
<description>Efetua uma subtracao e apresenta resultado</description>
<featureset>
<feature id='F002.002'/>
<feature id='F002.003'/>
</featureset>
</product>
@matchs
matchs / somador.xml
Created October 12, 2014 03:30
somador.xml
<?xml version="1.0"?>
<product id='somador'>
<name>Somador</name>
<description>Efetua uma soma e mostra resultado</description>
<featureset>
<feature id='F002.001'/>
<feature id='F002.003'/>
</featureset>
</product>
@matchs
matchs / Operacoes.tpl
Created October 12, 2014 03:28
operacoes.tpl
@file_path operacoes
@file_ext php
@file_name Operadores
@file_langs php
<?php
@features F002.001
echo "<html><head><title>Operador: Soma</title></head>";
@features F002.002
73F87C91-A053-4D88-9647-C2BE6C28E7E5