Skip to content

Instantly share code, notes, and snippets.

View boutros's full-sized avatar

Petter Goksøyr Åsen boutros

  • Oslo Public Library
  • Oslo
View GitHub Profile
(ns example.errors)
(defn clean-address [params]
"Ensure (params :address) is present"
(if (empty? (params :address))
[nil "Please enter your address"]
[params nil]))
(defn clean-email [params]
"Ensure (params :email) matches *@*.*"
@boutros
boutros / queue.go
Created March 22, 2014 19:12 — forked from scttnlsn/queue.go
package main
import (
"bufio"
"flag"
"fmt"
"net"
"strconv"
"strings"
"time"
package main
import (
"net"
"os"
)
const (
RECV_BUF_LEN = 1024
)
(ns xn.test
(:require-macros [cljs.core.async.macros :refer [go alts!]]
(:require [xn.core :as xn]
[xn.util :as u]
[cljs.core.async :refer [<! take!]]
[xn.xhr :refer [request-body request-records chain-req]]))
(def sample-app
(reify
xn/Application
@boutros
boutros / upload.go
Created October 27, 2013 20:38 — forked from mattn/upload.go
package main
import (
"crypto/sha1"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
"path/filepath"
@boutros
boutros / sortmap.go
Created October 26, 2013 14:20 — forked from ikbear/sortmap.go
package main
// sort a map's keys in descending order of its values.
import "sort"
type sortedMap struct {
m map[string]int
s []string
}
package main
import (
"fmt"
"math"
"flag"
"strings"
)
type Ngrams struct {
@boutros
boutros / capture.js
Created September 27, 2013 15:12 — forked from leplatrem/capture.js
var casper = require("casper").create({
viewportSize: {width: 1600, height: 1200},
//verbose: true,
//logLevel: 'debug',
onError: function(self, m) { // Any "error" level message will be written
console.log('FATAL:' + m); // on the console output and PhantomJS will
self.exit(); // terminate
},
});

CasperJS Google Suggest

The script:

/*global casper:true*/
var casper = require('casper').create();
var suggestions = [];
var word = casper.cli.get(0);
package main
import (
"net"
"log"
"time"
)
func Ping(proto, addr string, out chan<- string) {
c, err := net.Dial(proto, addr)