Skip to content

Instantly share code, notes, and snippets.

View anastasop's full-sized avatar

Spyros Anastasopoulos anastasop

View GitHub Profile
@anastasop
anastasop / routes.lisp
Created April 26, 2021 10:27
A tree-search for a first grade puzzle
#!/usr/bin/sbcl --script
(defparameter routes `((A B C)
(B A C D)
(C A B D E)
(D B C E)
(E)))
(defparameter start 'A)
(defparameter finish 'E)
@anastasop
anastasop / Puzzle.java
Last active April 26, 2021 11:31
A DFS search for a first grade puzzle
import java.util.*;
import java.util.function.Consumer;
public class Puzzle {
static record Move(int pos1, int pos2, int score) {
@Override
public String toString() {
return String.format("%d <-> %d", pos1, pos2);
}
}
@anastasop
anastasop / shortener.go
Created February 24, 2016 20:30
A very simple url shortener
package main
import (
"bufio"
"bytes"
"crypto/sha1"
"flag"
"fmt"
"io/ioutil"
"net/http"
@anastasop
anastasop / httpd.go
Created January 16, 2015 12:11
A web server for a single directory with content sniffing
import (
"flag"
"log"
"net/http"
)
var addr = flag.String("-h", ":8080", "host:port")
var dir = flag.String("-d", ".", "directory to serve")
@anastasop
anastasop / convopml
Created August 4, 2013 14:54
Transform an outline file in opml format to a nice html for viewing
#!/usr/bin/python
from __future__ import print_function
import sys, xml.parsers.expat, sys
import pystache
if len(sys.argv) != 3:
print('usage: convopml.py <opml file> <html file>', file = sys.stderr)
sys.exit(2)
@anastasop
anastasop / beq.py
Created June 16, 2013 16:17
A simple python script that unifies bookmark files exported from chrome and firefox. Useful for old backups but pretty useless in the cloud age. It uses BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/) for html parsing and jinja2 (http://jinja.pocoo.org/docs/) for templating. Tested with python 2.7.3 on ubuntu 64bit 12.04 LTS. The c…
#!/usr/bin/python
# create the union of a set of mozilla bookmarks files
# usage: ./beq.py bookmarks-20110501.html bookmarks-20120101.html > bookmarks.html
#
# license: the code is in the public domain
from bs4 import BeautifulSoup
from jinja2 import Template
import sys
@anastasop
anastasop / IncreasingBlabla.java
Created November 20, 2012 14:30
A toy program that generates sentences in english where the first word in one letter long, the second word 2 letters and so on.
/*
An Amazing sentence in English from
https://plus.google.com/photos/117176908342196183611/albums/5812811361700087857/5812811362489240738
> I do not know where family doctors acquired illegibly
> perplexing handwriting; nevertheless, extraordinary
> pharmaceutical intellectuality counterbalancing
> indecipherability transendentalizes intercommunication's
> incomprehensibleness
@anastasop
anastasop / smiley.c
Created September 17, 2012 20:25
smiley.c
// the smiley program demonstrated by Russ Cox at http://research.swtch.com/acme
// it shows that the plan9 compiler http://plan9.bell-labs.com/sys/doc/comp.html fully supports UTF-8
// i tried to compile it with a recent version of the plan9 compiler running on vmware but it failed.
// it seems that older versions of the compiler supported sizeof(void) == 0
// anyway you get the idea
#include <u.h>
#include <libc.h>
@anastasop
anastasop / board.go
Created July 7, 2012 15:32
Describe a chess position in FEN and get the image
/*
A simple Go program, http://golang.org, i wrote to demonstrate the
language. It converts chess FEN notation to images or html tables.
Uses the public domain pieces from http://www.crockford.com/chess/pieces.html
The program is small in size but not in functionality. It includes
http client and server, html templates, image processing, strings, io
and demonstrates the expressiveness of Go
See http://blog.golang.org/2011/12/from-zero-to-go-launching-on-google.html
@anastasop
anastasop / tx.go
Created July 7, 2012 15:26
A key-value REST web service in Go that demonstrates the database/sql package
package main
/*
Implements a key-value REST web service in go (http://golang.org)
It uses
github.com/bmizerany/pat A sinatra style pattern muxer
github.com/bmizerany/pq A pure Go postgres driver
The urls are