Skip to content

Instantly share code, notes, and snippets.

Avatar

Alba Mendez mildsunrise

View GitHub Profile
@mildsunrise
mildsunrise / README.md
Created May 25, 2014
Building Flash utilities from Flex Falcon under Linux
View README.md

Building Flash utilities from Flex Falcon, under Linux

Falcon is the next compiler for the Flex framework. The Flash part has interesting utilities that allow for deep parsing of SWFs. We're going to (partially) build Falcon in order to get the JARs containing the utilities.
It's a tricky process, and involves a 180MB download.

We'll need Git, the JDK, Ant and JFlex, so get them:

sudo apt-get install git openjdk-7-jdk ant jflex
@mildsunrise
mildsunrise / notes.coffee
Last active Aug 29, 2015
Playing with notes and frequencies...
View notes.coffee
# Get the frequency, in Hertz, from an octave number.
# `0` corresponds to A0, `1` to A1, etc.
frequencyOf = (octaves) ->
27.5 * Math.pow(2, octaves)
# Parse a note string into its corresponding octave number.
# Note: this cannot parse sharp (#) notes yet.
parseNote = (string) ->
point = string.charCodeAt(0) - 65
offset = point * 2
@mildsunrise
mildsunrise / derivative.coffee
Last active Aug 29, 2015
Fast derivative evaluator for polynomials
View derivative.coffee
derivative = (coefficients, point, k) ->
return 0 if k >= coefficients.length
result = 0
factor = 1
# Initial factor (k factorial)
for i in [1..k]
factor *= i
# Calculate result
@mildsunrise
mildsunrise / searcher.c
Last active Aug 29, 2015
Simple, fast binary searcher for huge files.
View searcher.c
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#define LOOKAHEAD 8
#define START 0
@mildsunrise
mildsunrise / encode.c
Last active Aug 29, 2015
Asynchronous signal encoding
View encode.c
/**
* Reads four bytes at `i`, and wraps them with
* start bits and stop bits as appropiate to
* produce a typical UART 8N1 signal.
*
* The resulting five bytes are written at `o`.
*
* Author: Xavier Mendez
* This code is in the public domain.
**/
@mildsunrise
mildsunrise / proxy.coffee
Last active Oct 2, 2015
Fast, simple, extensible Node.JS direct proxy.
View proxy.coffee
http = require 'http'
util = require 'util'
url = require 'url'
server = http.createServer (req, res) ->
request = url.parse req.url
request.headers = req.headers
request.method = req.method
@mildsunrise
mildsunrise / gcd.styl
Last active Oct 11, 2015
Greatest Common Divisor comes to Stylus!
View gcd.styl
gcd(a,b)
unless b
return a
gcd(b, a%b)
mcm(a,b)
a*b / gcd(a,b)
@mildsunrise
mildsunrise / test.c
Last active Oct 22, 2015
VMIN=0 + select(), possible kernel bug?
View test.c
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/select.h>
int main() {
// 1. Retrieve current terminal attributes
View keybase.md

Keybase proof

I hereby claim:

  • I am jmendeth on github.
  • I am jmendeth (https://keybase.io/jmendeth) on keybase.
  • I have a public key whose fingerprint is B256 B287 DA4B 6D5D 48E5 4C75 D453 8FF0 C567 D130

To claim this, I am signing this object:

@mildsunrise
mildsunrise / gcd.groovy
Created Mar 1, 2012
Greatest Common Divisor (GCD), compressed
View gcd.groovy
gcd={a,b->b?gcd(b,a%b):a}
mcm={a,b->a*b/gcd(a,b)}