Skip to content

Instantly share code, notes, and snippets.

View Pet3ris's full-sized avatar
🎯
Focusing

Peteris Erins Pet3ris

🎯
Focusing
View GitHub Profile
In this gist we will first show that we can beat the arc challenge
(http://www.paulgraham.com/arcchallenge.html), and then build the library that
shows how we did it. This gist is Literate Haskell and is of course executable. The packages needed are happstack-server and applicative-extras, installable using cabal.
Let's start with some imports (for now, you can ignore these)
> {-# LANGUAGE GADTs, TypeSynonymInstances #-}
> module ArcChallenge where
>
> import Control.Applicative
diff --git a/example/server.js b/example/server.js
index 167fc43..db758a2 100644
--- a/example/server.js
+++ b/example/server.js
@@ -61,4 +61,16 @@ io.on('connection', function(client){
client.on('disconnect', function(){
client.broadcast({ announcement: client.sessionId + ' disconnected' });
});
-});
\ No newline at end of file
@joemccann
joemccann / bitly-node.md
Created October 26, 2010 13:59
Bitly shortening from the command line with node, motherfuckers.
@joemccann
joemccann / HTML5_Suggested_Boilerplates.md
Created January 18, 2011 22:39
A compendium of HTML5 related scripts, frameworks and templates/boilerplates alongside suggested best practices.
@joemccann
joemccann / turbo_stylesheet.less
Created January 23, 2011 16:19
A mirror of Jeffrey Way's CSS3 "Classes" Stylesheet
/* http://snipplr.com/view.php?codeview&id=47181 */
/* Credit: Jeffrey Way */
.border-radius( @radius: 3px ) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
.outline-radius( @radius: 3px ) {
@jessykate
jessykate / Jekyll nd Octopress Liquid tag for MathJax.rb
Created February 18, 2011 23:37
A simple liquid tag for Jekyll/Octopress that converts {% m %} and {% em %} into inline math, and {% math %} and {% endmath %} into block equations, by replacing with the appropriate MathJax script tags.
module Jekyll
class MathJaxBlockTag < Liquid::Tag
def render(context)
'<script type="math/tex; mode=display">'
end
end
class MathJaxInlineTag < Liquid::Tag
def render(context)
'<script type="math/tex">'
end
@anildigital
anildigital / client.js
Created April 9, 2011 10:16
Twitter streaming API example twitter-node and socket.io
<!DOCTYPE HTML>
<head>
<title>Codesnippit NodeJS Twitter Tracker Client</title>
</head>
<body>
<ul></ul>
<script>
(function() {
var script = document.createElement("script");
script.src = "http://code.jquery.com/jquery.min.js";
;; peteris's solution to http://4clojure.com/problem/31
#(let [[elt cnt]
(let [v (vec %), n (count %)]
(loop [i 1, elt [(first v)], cnt [1]]
(if (= i n)
[elt cnt]
(recur (inc i)
(if (= (v i) (v (dec i)))
elt
@jColeChanged
jColeChanged / gist:938272
Created April 23, 2011 04:16
A Nifty Clojure Function
(defn fn-and
"Takes a set of functions and returns a fn which returns whether
every item in the juxtaposition of those functions is true."
([& fns]
(let [juxted-fns (apply juxt fns)]
(fn [& args] (every? true? (apply juxted-fns args))))))
;; peteris's solution to http://4clojure.com/problem/50
#(loop [s %, acu {}]
(if (= '() s)
(map reverse (vals acu))
(recur (rest s)
(if (nil? (find acu (type (first s))))
(assoc acu (type (first s)) (list (first s)))
(assoc acu (type (first s)) (cons (first s) (get acu (type (first s)))))))))