Skip to content

Instantly share code, notes, and snippets.

@jgrar
jgrar / f.c
Created August 4, 2012 03:49
project euler 20 solution
/* cc -of f.c -lgmp */
#include <stdlib.h>
#include <stdio.h>
#include <gmp.h>
void factorize (mpz_t r, mpz_t n)
{
mpz_t x;
#include <stdlib.h>
#include <stdio.h>
#include <gmp.h>
int main (int argc, char *argv[])
{
mpz_t n, x, f;
if (argc < 2)
exit(EXIT_FAILURE);
@jgrar
jgrar / avrserial.c
Created October 20, 2012 11:12
thinking about changing it up
#include <avr/io.h>
#include <stdio.h>
#include <stdint.h>
#define BAUD 19200
#define important_magic_number F_CPU/16/BAUD-1
int32_t main{
begin(important_magic_number);
/* need to figure out which ports /registers/pins to use*/
package main
import (
"bytes"
"fmt"
)
type Message2 struct {
Prefix string
Command string
@jgrar
jgrar / irc.c
Last active December 25, 2015 19:29
An rfc compliant irc parser in C.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
enum symbols { NEWLINE, SPACE, COLON };
#define SYMBOLS { '\n', ' ', ':', '\0'};
char line[32][256];
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <get_irc_message.h>
#define INIT_BUFFER_MAX 256
@jgrar
jgrar / mask.c
Created November 4, 2013 15:26
irc masking, * (zero or more any), ? (single char), with escapes
#include <stdlib.h>
#include <string.h>
/*
* Hint: scroll down to match()
*/
/**********************************************************************/
typedef struct {
char *p;
size_t len, cap;
SELECT
sum(Total) AS Total, State
FROM (
SELECT
State, Total
FROM
WorkOrders
INNER JOIN
Customers ON CID = ID
WHERE Type != "Warranty"
#/bin/sh
ssh jgr@mindlock.us 'find ~/irclogs/ -type f ! -empty | grep -v ".*/$(date "+%Y")/[^/]*/.*\.$(date "+%m")-$(date "+%d")\.log" | sed "s|$HOME/irclogs/||"' > targets
cat targets | while read line
do
mkdir -p ~/irclogs/$(echo $line | sed -e 's|/[^/]*$||')
scp -B -C -p jgr@mindlock.us:'~/irclogs/'$line ~/irclogs/$line
done
ssh jgr@mindlock.us "sed 's|.*|$HOME/irclogs/&|' | xargs rm -f" < targets
@jgrar
jgrar / ndb.diff
Created February 5, 2014 02:51
ndb line patch
diff --git a/ndb.go b/ndb.go
index 4d1f5b6..9dc3f69 100644
--- a/ndb.go
+++ b/ndb.go
@@ -27,7 +27,7 @@ type Tuple struct {
// A NDB record, which may contain multiple tuples,
// and may span multiple lines in the file.
-type Record []Tuple
+type Record [][]Tuple