Skip to content

Instantly share code, notes, and snippets.

@guipn
guipn / gist:888789
Created March 27, 2011 00:30
Script to download from a webpage all files the extensions of which are among the ones listed by the user.
#
# Downloads all files directly linked within a webpage that are of a given list of extensions.
#
# The webpage in question is to be provided as the first argument for the program.
# The formats shall be specified as a single, second argument by the user, like so: "pdf txt tar.gz"
#
# If a third argument is given, it will be used as a target folder in which to save downloaded files.
#
# example: getfiles.pl http://google.com "gif js"
#
@guipn
guipn / rot13.pl
Created May 7, 2011 18:45
Perl: 13 line ROT-13
#
# Perl - ROT-13
#
# guidjos
use warnings;
use strict;
die "\n\n\t $0 [-e | -d] [text]\n" unless @ARGV > 1;
my $option = shift;
@guipn
guipn / SimpleBenchmark.java
Created May 7, 2011 20:39
Simple Java Benchmarking
class SimpleBenchmark
{
private Runnable task;
public Benchmark(Runnable target)
{
task = target;
}
public long perform()
@guipn
guipn / numeric_derivative.js
Created June 17, 2011 20:43
Numeric Derivative
function derivator(func, step) {
step = step || Number.MIN_VALUE;
return function (x) {
return (func(x + step) - func(x)) / step;
};
}
@guipn
guipn / uirndrng.c
Created March 9, 2012 21:05
Random integer within given range
#include <time.h>
unsigned int uirndrng(unsigned int low, unsigned int high)
{
static char randomized;
if (low >= high)
{
exit(EXIT_FAILURE);
}
@guipn
guipn / list.c
Created April 18, 2012 05:03
Not Haskell
// gcc -std=c99 -Wall -Wextra -pedantic list.c -o list
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
void *value;
struct node *tail;
} list_t;
@guipn
guipn / Poisson.hs
Created June 3, 2012 23:54
Haskell/Poisson
{-
- Some functionality related to Poisson Processes.
-
- gpn
-}
module Poisson (
Process(..)
, pNt
, eNt
@guipn
guipn / stripcomment.c
Created August 25, 2012 04:34
C Comment Stripper
/**
* Takes C source code as input and removes comments.
*
* gcc -std=c99 -Wall -Wextra -Wall -pedantic stripcomments.c -o sc
*/
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@guipn
guipn / qsort.js
Created September 22, 2012 04:17
Simple quicksort implementations
// The simplest implementation I can write.
function qsort(array) {
var lower, upper, pivot;
if (array.length <= 1) {
return array;
}
@guipn
guipn / roman.hs
Created October 8, 2012 02:26
Roman Notation
trivial :: [(Int, String)]
trivial = [
{- Bridge values -}
(1, "I"), (5, "V"), (10, "X"), (50, "L"),
(100, "C"), (500, "D"), (1000, "M"),
{- Subtractions -}
(4, "IV"), (9, "IX"), (40, "XL"), (90, "XC"),
(400, "CD"), (900, "CM")
]