Skip to content

Instantly share code, notes, and snippets.

View madoke's full-sized avatar
🐵

David Simão madoke

🐵
View GitHub Profile
@madoke
madoke / simplerules.ts
Created March 12, 2023 13:57
Simple Rules Engine
// The engine
type Rule<T> = (input: T) => boolean;
const All =
<T>(...rules: Rule<T>[]) =>
(input: T) =>
rules.every((r) => r(input));
const Some =
const crypto = require('crypto');
const fs = require('fs');
const hash = (block) => {
const json = JSON.stringify(block);
const hash = crypto.createHash('sha256');
hash.update(json);
return hash.digest('hex');
}
@madoke
madoke / keybase.md
Created November 28, 2018 13:22
keybase.md

Keybase proof

I hereby claim:

  • I am madoke on github.
  • I am madoke (https://keybase.io/madoke) on keybase.
  • I have a public key ASDxZ8TcoYw1xy5hY5z8MHl3iQF9ZYG9iAAcond26efEDQo

To claim this, I am signing this object:

@madoke
madoke / bash-webtail
Last active December 15, 2015 17:49
Tails a remote file via HTTP. Polls the HTTP Headers, via curl, and when "Content-Length" has changed, fetches the remaining difference
#!/bin/bash
POLLING_INTERVAL=2
CONTENT_LENGTH=0
while true
do
FETCH_CONTENT_LENGTH=`curl -s -r 0-0 -I $1 | egrep -i "Content-Range" | cut -d/ -f2 | awk -F"\r" '{print $1}'`
TMP_CONTENT_LENGTH=$FETCH_CONTENT_LENGTH
@madoke
madoke / pfam-parser.sh
Last active October 3, 2015 09:58
Pfam database parser
#!/bin/bash
echo "Super Mega Hyper Pfam database parser started. Sit back and relax :)"
echo "Begin parsing " $1 " file.."
#remove old output
rm -rf parser_output
mkdir parser_output
#parse command line arguments
@madoke
madoke / XSSRequestWrapper.java
Created April 9, 2012 22:23 — forked from ulinkwo/XSSRequestWrapper.java
Stronger Anti Cross-Site Scripting (XSS) Filter for Java Web Apps
package pt.impresa.iweb.filters.request;
import java.io.IOException;
import java.text.Normalizer;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
@madoke
madoke / resign.sh
Created April 9, 2012 22:08
Bash script to replace CodeSignature on an Ad-Hoc / Apple IPA bundle
#!/bin/bash
EXPECTED_ARGS=3
E_BADARGS=-1
CERTIFICATE_NAME="iPhone Distribution: MY_CERTIFICATE_NAME"
#verify correct usage
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` file_to_resign provisioning_profile package_name"
exit $E_BADARGS