Skip to content

Instantly share code, notes, and snippets.

View akahn's full-sized avatar

Alex Kahn akahn

View GitHub Profile
module Cellular where
import System.Random
import Data.List.Split
import Data.Maybe
isWall False = '.'
isWall True = '#'
mapWithIndex :: (Enum a, Num a) => (a -> b -> c) -> [b] -> [c]
@akahn
akahn / gist:b52d42b82437dfd02786
Created June 22, 2015 15:17
Sequel errors added in after_validation don't prevent save
# Validations added in an instance hook:
model.after_validation_hook { model.errors.add("random_attribute", 'Unrecognized attribute') }
# Later:
> model.valid?
=> false
> model.errors
=> {"random_attribute"=>["Unrecognized attribute"]}
print "partay!!"
function my_garland_preprocess_views_view__principles(&$vars) {
$vars['test'] = 'Hi!!!';
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>untitled</title>
<style type="text/css">
require 'rubygems'
require 'scrubyt'
photos = Scrubyt::Extractor.define :agent => :firefox do
fetch 'http://alexanderkahn.deviantart.com/gallery'
link_title "//a[@class='t']", :write_text => true do
link 'href', :type => :attribute
end
function sti_migrate_import($options, &$context) {
// For node_object_prepare()
module_load_include('inc', 'node', 'node.pages');
module_load_include('inc', 'filefield', 'field_file');
$query = 'SELECT * FROM {sti_stories} ORDER BY imagefile DESC';
$context['sandbox']['progress'] = 0;
$context['sandbox']['results'] = array();
$context['sandbox']['max'] = $options['count'];
$(document).ready(function(){
$('#edit-taxonomy-3-wrapper select').change(function() {
if ($('option:selected',this).html() == 'Other...') {
$('#edit-field-i-am-other-0-value-wrapper').slideDown('fast');
}
else {
$('#edit-field-i-am-other-0-value-wrapper').slideUp('fast');
}
});
});
/**
* Zips must be 5-digit integers and email addresses must be valid.
*/
function email_zip_validate($form, &$form_state) {
if (!is_numeric((int)$form_state['values']['zip']) || strlen($form_state['values']['zip']) != 5) {
form_set_error('zip', t('The zip code you entered was not valid. Please try entering it again.'));
}
if (!valid_email_address($form_state['values']['email'])) {
form_set_error('email', t('The email address you entered was not valid. Please try entering it again.'));
}
for (i = 0; i++; i < 10) {
$('.view-featurebox').after('hi');
}