Skip to content

Instantly share code, notes, and snippets.

View mildsunrise's full-sized avatar
🦊
*rolls*

Alba Mendez mildsunrise

🦊
*rolls*
View GitHub Profile
@mildsunrise
mildsunrise / dabblet.css
Created September 29, 2013 11:54
Shadow effects
/**
Shadow effects
==============
Multiple text-shadows can be stacked to
create wonderful, realistic effects.
Oh, and CSS allows for expressiveness too.
Try zooming in and disabling some shadows!
@mildsunrise
mildsunrise / document.tex
Last active May 5, 2023 13:07
My boilerplate LaTeX source file.
\documentclass[LANGUAGE,OPTIONS]{CLASS}
% encoding
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{babel}
% formatting and fixes
\frenchspacing
@mildsunrise
mildsunrise / determinant.coffee
Last active December 25, 2015 17:19
Matrixes. Determinants. Coffeescript. Yeah, that's pretty much it.
determinant = (M) ->
k = M.length
return 1 unless k
# copy child matrix
N = []
for y in [1...k]
N.push M[y].slice 1
# recurse
@mildsunrise
mildsunrise / README.md
Created May 25, 2014 08:15
Building Flash utilities from Flex Falcon under Linux

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 August 29, 2015 14:04
Playing with notes and frequencies...
# 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 August 29, 2015 14:08
Fast derivative evaluator for polynomials
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 August 29, 2015 14:16
Simple, fast binary searcher for huge files.
#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 / README.md
Last active September 16, 2017 23:40
Modern way to bind a socket to a port

Simple function that takes a socket type and a port, and returns a new socket of that type, bound to that port on the wildcard address (on either IPv4 or IPv6).

This is the modern way to create a socket that will accept connections from other hosts. You use it like that:

int my_socket = bound_socket(SOCK_DGRAM, 8080);
if (my_socket == -1) {
@mildsunrise
mildsunrise / test.c
Last active October 22, 2015 11:31
VMIN=0 + select(), possible kernel bug?
#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
@mildsunrise
mildsunrise / sat-align.py
Created February 15, 2016 04:49
Program that tracks Dreambox's BER or SNR and emits MIDI notes
#!/usr/bin/python
import alsaseq, alsamidi, requests, time, math
from lxml import etree
INTERVAL = 70e-3
URL = "http://root:dreamboxx@10.139.205.104/xml/streaminfo"
alsaseq.client('sat-align', 0, 1, True)
map = lambda x, s, e: s + x * (e-s)
clamp = lambda x, s, e: max(min(x, e), s)