Skip to content

Instantly share code, notes, and snippets.

@jbedo
jbedo / unind
Created November 18, 2012 22:58
Acme script for unindenting one tab
#!/usr/bin/env rc
. 9.rc
exec sed 's/^ //'
@jbedo
jbedo / ind
Created November 18, 2012 22:58
Acme script for indenting one tab
#!/usr/bin/env rc
. 9.rc
exec awk '{print " " $0}'
@jbedo
jbedo / com
Created November 18, 2012 22:56
Acme script for adding/removing comments (from 9fans)
#!/usr/bin/env rc
fn f {
n=$1
if(! cat $f | cut -c1-$n | 9 grep -v '^[ ]+$' >/dev/null){
x=`{f `{expr $n + 1}}
echo '.'$"x
}
}
@jbedo
jbedo / reddit.c
Created July 18, 2012 19:54
reddit client
#include<u.h>
#include<libc.h>
#include<json.h>
#include<bio.h>
#include<String.h>
const char url[] = "http://www.reddit.com/.json?feed=ffffffffffffffffffffffffffffffffffffffff&user=jbedo";
/* Does the webfs query */
String *
@jbedo
jbedo / rer-d
Created March 27, 2012 18:21
Fetches next train times for RER D line to/from Paris and Evry Courcouronnes and displays minutes remaining
#!/bin/rc
urlfrom='http://www.transilien.mobi/TempReelSaisieSubmit.do?debutDepart=chatelet&debutArrivee=evry+courcouronnes'
urlto='http://www.transilien.mobi/TempReelSaisieSubmit.do?debutDepart=evry+courcouronnes&debutArrivee=chatelet'
url=$urlfrom
for(i) switch $i {
case -t
url=$urlto
}
@jbedo
jbedo / solar.c
Created March 25, 2012 20:06
Local solar time clock
#include<u.h>
#include<libc.h>
#define MIN /60.0
#define DEG * 2 * PI / 360.0
#define RAD * 360.0 / (2 * PI)
double longitude = 2.0 + 20.0 MIN;
const double Eccentricity = 0.0167;
@jbedo
jbedo / hilbert.c
Created November 30, 2011 01:08
Matrix multiplication with Hilbert space-filling curves
#include<u.h>
#include<libc.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
/* Hilbert curve functions (from Wikipedia) */
/* rotate/flip a quadrant appropriately */
void rot(int n, int *x, int *y, int rx, int ry)
{
@jbedo
jbedo / tempmon.c
Created July 1, 2011 10:37
ATI temperature controller
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<math.h>
#include<string.h>
#include<limits.h>
#define NADAPTERS 4
static const int MAXCLOCK = 950;
static const int MINCLOCK = 500;
@jbedo
jbedo / gist:888244
Created March 26, 2011 12:33
S3Venti port to plan 9
diff -Naur old/mkfile new/mkfile
--- old/mkfile Mon Feb 11 04:27:13 2008
+++ new/mkfile Sat Mar 19 16:34:15 2011
@@ -1,6 +1,4 @@
-<$PLAN9/src/mkhdr
-
-MKSHELL=rc
+</$objtype/mkfile
CFLAGS=$CFLAGS
@jbedo
jbedo / relevel.c
Created March 20, 2011 09:35
Adjusts image contrast
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <memdraw.h>
static double Ptop = 0.995;
static double Pbot = 0.01;
typedef struct range range;
struct range{