Skip to content

Instantly share code, notes, and snippets.

@ibdknox
ibdknox / socket.clj
Created October 31, 2010 06:48
compojure with websockets
(ns wl.core
(:use compojure.core, aleph.core, aleph.http, hiccup.core, hiccup.page-helpers)
(:require [compojure.route :as route])
(:gen-class))
(def broadcast-channel (channel))
(defn chat-handler [ch handshake]
(receive ch
(fn [name]
@ibdknox
ibdknox / server.sh
Created August 4, 2011 06:13
example daemon for lein processes
#!/bin/bash
name=webnoir
pidfile=/var/run/$name.pid
if [ -f "$pidfile" ]; then
pid=`cat $pidfile`
running=`ps p $pid |wc -l`
if [ $running -eq 1 ]; then
pid=
(defpartial error-item [[first-error]]
[:p.error first-error])
(defpartial user-fields [{:keys [firstname lastname]}]
(vali/on-error :firstname error-item)
(label "firstname" "First name: ")
(text-field "firstname" firstname)
(vali/on-error :lastname error-item)
(label "lastname" "Last name: ")
(text-field "lastname" lastname))
@ibdknox
ibdknox / EchoHandler.java
Created May 10, 2011 22:24
Socket.IO-netty example
import com.ibdknox.socket_io_netty.INSIOClient;
import com.ibdknox.socket_io_netty.INSIOHandler;
public class EchoHandler implements INSIOHandler {
@Override
public void OnConnect(INSIOClient client) {
System.out.println("A user connected :: " + client.getSessionID());
}
@ibdknox
ibdknox / behaviors.cljs
Created October 21, 2013 20:24
My behaviors file
{:+ {:app [(:lt.objs.style/set-skin "dark")
(:lt.objs.app/run-on-init :window.fullscreen)
(:lt.plugins.vim/map-keys {"-" "$",
"0" "^",
"<BS>" "<PageUp>",
"<Space>" "<PageDown>",
"j" "gj",
"k" "gk"})
(:lt.objs.files/file.ignore-pattern "(^\\..*)|\\.class$|target/|svn|cvs|\\.git|\\.pyc|~|\\.swp|\\.jar|.DS_Store|_site/|_cache/|__pycache__")
:lt.objs.intro/show-new-file
@ibdknox
ibdknox / chevrotain.d.ts
Created April 28, 2017 04:37
chevrotain typings
/*! chevrotain - v0.28.1 */
export as namespace chevrotain;
declare class HashTable<V>{}
/**
* The type of custom pattern matcher functions.
* Matches should only be done on the start of the text.
* Note that this is similar to the signature of RegExp.prototype.exec
*
* This should behave as if the regExp match is using a start of input anchor.
* So: for example if a custom matcher is implemented for Tokens matching: /\w+/

Breaking Down Tic-tac-toe

Last week, @RubenSandwich posted an interactive demo on the mailing list capable of playing and scoring tic-tac-toe matches. He provided some great feedback about the issues he ran into along the way. Now that the language is becoming more stable, our first priority is seeing it used and addressing the problems which surface. To that end, his troubles became our guide to making Eve a little friendlier for writing interactive applications in general and tic-tac-toe in specific.

This analysis (and future breakdowns) will be written inline in Eve to make the discussion flow more naturally. Since our blog is capable of rendering Markdown, we can provide a pleasant reading experience directly from the source code. At the moment, Eve's syntax only lends itself to a subset of Markdown, but we plan to make some small changes in the near future to become fully compatible with [GFM][2

-----------------
Handle Events
-----------------
click on a restaurant or pin, show a restaurant
app = [@app]
[#click element]
choose
element = [#yelp-restaurant-list-element restaurant]
or
@ibdknox
ibdknox / deafult.behaviors.clj
Created December 6, 2013 16:36
default behaviors for Light Table
{
:+
{:app
#{:lt.objs.clients.local/startup-with-local-client
:lt.objs.settings2/load-behaviors
:lt.objs.settings2/load-keys
:lt.objs.settings2/create-user-settings
:lt.objs.proc/set-path-OSX
:lt.objs.workspace/reconstitute-last-workspace
:lt.objs.sidebar.command/init-commands
@ibdknox
ibdknox / eveInstall.sh
Created September 10, 2015 19:01
Eve install
./install-multirust.sh
brew install node
pushd . &> /dev/null
cd ui
npm install
popd &> /dev/null
./run.sh