Skip to content

Instantly share code, notes, and snippets.

View smerrill's full-sized avatar
🤖
Attention is all you need

Steven Merrill smerrill

🤖
Attention is all you need
View GitHub Profile
val alphabet = "abcdefghijklmnopqrstuvwxyz"
def train(text:String) = {
"[a-z]+".r.findAllIn(text).foldLeft(Map[String, Int]() withDefaultValue 1) {(a, b) => a(b) = a(b) + 1}
}
val NWORDS = train(scala.io.Source.fromFile("big.txt").getLines.mkString.toLowerCase)
def known(words:Set[String]) = {println("Known invocation: %s" format words); Set.empty ++ (for(w <- words if NWORDS contains w) yield w)}
<?php
/**
* @file
* Test case for Drupal tests using a given install profile.
*
* Based on work that is copyright 2008-2009 by Jimmy Berry ("boombatower", http://drupal.org/user/214218)
*/
class ProvisionWebTestCase extends DrupalWebTestCase {
protected function getProfileName() {
svn log -r{2009-12-09}:HEAD | grep '#[0-9]' | awk '{print $1;}' | sed 's/[^0-9]//g' | awk '{ x[$1]++; if (x[$1] == 1) { print $1; } }'
svn st | grep "C ht" | sed 's/!//g' | awk '{system(sprintf("svn resolve --accept working %s", $2))}'
<?php
// $Id$
$info = array(
// Available colors and color labels used in theme.
'fields' => array(
'base' => t('Base color'),
'link' => t('Link color'),
'top' => t('Header top'),
'bottom' => t('Header bottom'),
/* $Id$ */
/**
* Styles and colors that the color module will modify.
*/
body,
#block-system-main {
color: #3b3b3b;
}
#header {
grep -r -n Cookie .
# Grep recursively (-r) for all files in this directory that
# contain Cookie (case-sensitive unless -i is used) and print
# their line numbers (-n). Outputs:
./pressplus.module:179: drupal_set_header('Vary', 'Cookie');
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
return (deliver);
}
#!/bin/bash
date=`date "+%Y-%m-%d"`
for i in /Applications/MAMP/db/mysql/*/; do
dbname=`basename $i`
/Applications/MAMP/Library/bin/mysqldump -uroot $dbname > ~/hdd-smerrill/Documents/Backups/$dbname-$date.sql
done
var sys = require("sys"),
http = require("http"),
growl = require("./node-growl/lib/growl"),
child_process = require("child_process");
function createClient() {
var i = http.createClient(80, website);
// Handle a connection error.
// Thanks to http://rentzsch.tumblr.com/post/664884799/node-js-handling-refused-http-client-connections.