Skip to content

Instantly share code, notes, and snippets.

View lfranchi's full-sized avatar

Leo Franchi lfranchi

View GitHub Profile
- latest.each do |article|
= render( 'article_embedded', :item => article, :extended => true ) { article.compiled_content( :snapshot => :pre ) }
(ns fj
(:import [java.util.concurrent RecursiveTask
ForkJoinPool]))
(set! *warn-on-reflection* true)
;; -----------------------------------------------
;; Helpers to provide an idiomatic interface to FJ
(defprotocol IFJTask
(deftype Foo [something]
ISomeInterface
([self other-Foo]
; How do I get other-Foo's something object here?
))
# A list is either () or (head, list).
# list = () | (head, list)
def make_list(xs): return (xs[0], make_list(xs[1:])) if xs else ()
L = make_list('abcd')
## L
#. ('a', ('b', ('c', ('d', ()))))
- author = @item[:author] || "Leo Franchi"
#article
#article-header
%h1#title
%a{href:permalink_for_article(@item)}
= @item[:title]
#date
%time{datetime:@item[:created_at].strftime("%Y-%m-%d"), pubdate:"pubdate"}
= @item[:created_at].strftime("%A, %B %d %Y")
#article-body
(defn zipper
[]
[() ()])
(defn insert-at-cursor
[zipper newchar]
[(cons newchar (first zipper)) (second zipper)])
(defn get-at-cursor
[zipper]
(defn item<?
[{patha :path} {pathb :path}]
(loop [patha patha
pathb pathb]
(let [{l :branch l-disamb :disamb} (first patha)
{r :branch r-disamb :disamb} (first pathb)]
(cond
(nil? l) (= r 1)
(nil? r) (= l 0)
(= l r) (if (and (= 1 (count patha)) (= 1 (count pathb)))
@lfranchi
lfranchi / phonon-vlc-optimize-debug
Created November 18, 2012 15:29
Do not needlessly construct debug objects if no debug is shown
diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp
index 6fac78f..adefeee 100644
--- a/src/utils/debug.cpp
+++ b/src/utils/debug.cpp
@@ -173,7 +173,7 @@ Block::Block( const char *label )
: m_label( label )
, m_color( s_colorIndex )
{
- if( !debugEnabled() )
+ if( !debugEnabled() || DEBUG_INFO < s_debugLevel)
>>> from contextlib import contextmanager
>>> @contextmanager
... def foobar(baz):
... print "Before"
... yield
... print "After"
...
>>> with foobar(0):
... print "Doing stuff"
... raise Exception
(use 'gloss.io 'gloss.core)
;; Support
(def flags {:RAW 1
:JSON 2
:FRAGMENT 4
:COMPRESSED 8
:DBOP 16
:PING 32