Skip to content

Instantly share code, notes, and snippets.

View johnciacia's full-sized avatar
👋

John Ciacia johnciacia

👋
View GitHub Profile
@johnciacia
johnciacia / permute.lsp
Created December 15, 2010 23:47
Generate the permutations of a given list
* (load "permute.lsp")
; Loading #p"/home/john/permute.lsp".
T
* (p (list 'a 'b 'c 'd 'e))
((A B C D E) (A B C E D) (A B D C E) (A B D E C) (A B E C D) (A B E D C)
(A C B D E) (A C B E D) (A C D B E) (A C D E B) (A C E B D) (A C E D B)
(A D B C E) (A D B E C) (A D C B E) (A D C E B) (A D E B C) (A D E C B)
(A E B C D) (A E B D C) (A E C B D) (A E C D B) (A E D B C) (A E D C B)
@johnciacia
johnciacia / sierpinski.html
Created December 15, 2010 23:36
Sierpinski's Triangle IFS
<!DOCTYPE html>
<html>
<head>
<title>Sierpinski Triangle</title>
</head>
<body>
<canvas id="sierpinski">
Oops! Your browser does not support HTML5 Canvas.
@johnciacia
johnciacia / itoa.c
Created November 7, 2010 20:00
Convert an integer to an ASCII string
/* K&R2 60-63 */
char *itoa(int n, char s[])
{
int c, i, j, sign;
if((sign = n) < 0)
n = -n;
do {
s[i++] = n % 10 + '0';
@johnciacia
johnciacia / border.php
Created November 7, 2010 19:57
Add a border to text using GD
<?php
/**
* Writes the given text with a border into the image using TrueType fonts.
* @author John Ciacia
* @param image An image resource
* @param size The font size
* @param angle The angle in degrees to rotate the text
* @param x Upper left corner of the text
* @param y Lower left corner of the text
* @param textcolor This is the color of the main text
@johnciacia
johnciacia / ocr.php
Created November 7, 2010 19:56
This is a very basic optical character recognition script written in PHP. This is untested and serves merely a proof of concept. As noted in the comments, adjusting the sample size can improve results, since with a large sample size on a small image there
<?php
/* create a test image */
$im = @imagecreate(100, 20) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 1, 5, 5, "Hello, World!", $text_color);
/***
* Assumptions: