Skip to content

Instantly share code, notes, and snippets.

@whackashoe
whackashoe / gist:ffa7aea78467ecc73abc
Last active February 26, 2016 21:52
radial-2 neighborhood 1d ca
var ca = (function(rule, grid_size) {
var radius = 5;
var ruleset = _.map(_.range(1 << radius), function(i) { return (rule >> i) & 1; });
var grid = _.times(grid_size, _.random.bind(_, 0, 1));
for(var i=0; i<10; i++) {
grid = _.map(
_.zip.apply(_, _.map(_.range(-Math.floor(radius/2), Math.floor(radius/2)), _.partial(_.arr.rotate, grid, _))),
function(m) { return ruleset[_.foldl(m, function(a, b, i) { return a + (b * (1 << i)); })]; }
);
@whackashoe
whackashoe / imlcaptchaform.php
Created October 15, 2012 01:48
Verify IMLCaptcha Full Code
<?php
require_once('imlcaptcha/IMLCaptchaReader.php');
$captcha = new IMLCaptchaReader();
$errors = array();
$success = False;
if(isset($_POST['submit'])) {
$captcha->validate($_POST['imlclookup'], $_POST['imlcinput']);
@whackashoe
whackashoe / imlcaptchaform.php
Created October 15, 2012 01:47
IMLCaptcha success
if(!$captcha->checkSuccess()) //The verification failed
@whackashoe
whackashoe / imlcaptchaform.php
Created October 15, 2012 01:40
Verify IMLCaptcha
$captcha->validate($_POST['imlclookup'], $_POST['imlcinput']);
@whackashoe
whackashoe / imlcaptchaform.html
Created October 15, 2012 01:36
A form with IMLCaptcha added in
<form name="contact" action="" method="post">
<label for="name">Name</label>
<input type="text" name="name" id="name" />
<br/>
<label for="email">Email Address</label>
<input type="text" name="email" id="email" class="email" />
<br/>
<label for="message">Message</label>
<textarea name="message" id="message" rows="8" cols="40"></textarea>
<br/>
@whackashoe
whackashoe / imlcaptchaform.php
Created October 15, 2012 01:28
drawing captcha to screen
<?=$captcha?>
@whackashoe
whackashoe / imlcaptchaform.html
Created October 15, 2012 01:26
Loading stylesheets and javascript for IMLCaptcha
<html>
<head>
<!-- IE Fix for HTML5 Tags -->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="stylesheet" media="screen" href="imlcaptcha/default.css" />
</head>
<body>
@whackashoe
whackashoe / IMLCaptchaReader.php
Created October 15, 2012 01:18
Adding AppId to IMLCaptcha
<?php
class IMLCaptchaReader {
private $appid = "0"; //change this line
private $appid = "97063e821b852033ad9f4d3effc10e1c"; //to the equivalent of this
@whackashoe
whackashoe / initimlcaptcha.php
Created October 15, 2012 01:12
Initializing IMLCaptcha
<?php
require_once('imlcaptcha/IMLCaptchaReader.php');
$captcha = new IMLCaptchaReader();
?>