Skip to content

Instantly share code, notes, and snippets.

#include "wantcurve.h"
#include <err.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
wantcurve *read_wantcurve_from_path(char *path) {
FILE *fh;
if ( (fh = fopen(path, "rb")) == NULL )
sub read_curve_from {
my ($fn) = @_;
my $fh;
if ( $fn eq "-" ) {
$fh = \*STDIN;
} else {
open $fh, "<", $fn or die "Couldn't open $fn for reading: $!";
}
return read_curve_string(do { local $/; <$fh> });
sub make_wantcurve {
my ($sr,$size,$pts) = @_;
my @points = sort { $a->[0] <=> $b->[0] } @$pts;
my $want = [];
FREQ: for my $i ( 0 .. $size-1 ) {
my $f = $i/$size*$sr;
if ( $f > $sr/2 ) {
$f = $sr-$f; # ah, imaginary numbers, how i love you so
int pti = 0;
for (int i = 0; i < len; i++) {
float f = (float)i/len*sr;
if ( f < curve->pts[0].freq ) {
// before the first point
in[i].r = curve->pts[0].power;
} else if ( curve->pts[curve->ct-1].freq < f ) {
// after last point
in[i].r = curve->pts[curve->ct-1].freq;
} else {
- (void)loadImage {
NSURL *url = [db getImageURL:mnam node:nodeidx];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
[[URLHandler mainHandler] dataForURL:url sentTo:^(BOOL worked, NSData *data){
if ( !worked ) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Network Failure"
message:@"Couldn't download the comic. Make sure you're connected to a network."
#!/usr/bin/perl
use strict;
use warnings;
sub spawn {
if ( !fork ) {
system @_ and die;
exit 0;
}
}
#!/usr/bin/perl
use warnings;
use strict;
use AnyEvent;
use AnyEvent::Socket;
use Coro;
use Coro::Handle;
my %open;
@encryptio
encryptio / test.c
Created November 2, 2015 20:06
Floating point weirdness
// Compile and run in 32-bit mode:
// $ cc -Wall -m32 -o test test.c
// $ ./test
// false
//
// Contrast with 64-bit mode:
// $ cc -Wall -m64 -o test test.c
// $ ./test
// true
//
### Keybase proof
I hereby claim:
* I am encryptio on github.
* I am encryptio (https://keybase.io/encryptio) on keybase.
* I have a public key whose fingerprint is D72A 7DD7 B5E5 9821 8E15 37A6 2FBB F02B 4281 437B
To claim this, I am signing this object:
@encryptio
encryptio / bf-reql.js
Last active July 15, 2016 16:36
Brainfuck interpereter in ReQL
var charLookup = "??????????\n????????????????????? !?#$%&?()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[?]^_`abcdefghijklmnopqrstuvwxyz???~?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????";
var bailoutSteps = 60000;
r.expr({
program: "rot13 (from Wikipedia):"+
"-,+[ Read first character and start outer character reading loop"+
" -[ Skip forward if character is 0"+
" >>++++[>++++++++<-] Set up divisor (32) for division loop"+
" (MEMORY LAYOUT: dividend copy remainder divisor quotient zero zero)"+