Skip to content

Instantly share code, notes, and snippets.

View danielsz's full-sized avatar

Daniel Szmulewicz danielsz

View GitHub Profile
(ns node-test.core
(:require [cljs.nodejs :as nodejs]))
(nodejs/enable-util-print!)
(def cp (.-spawn (nodejs/require "child_process")))
(defn run-cmd [cmd args call-back]
(let [child (cp cmd args)]
(.on (.-stdout child) "data" call-back)
(.on (.-stdout child) "end" #(println (str cmd " process ended")))))
@danielsz
danielsz / com.apple.locate.plist
Created July 13, 2012 20:30
com.apple.locate.plist
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>15</integer>
</dict>
@danielsz
danielsz / pubdate_original.rb
Created August 11, 2012 06:05
def is my stub framework
## original code
describe "#pubdate" do
describe "before publishing" do
it "is blank" do
@it.pubdate.must_be_nil
end
end
describe "after publishing" do
before do
@danielsz
danielsz / canonical_el-get.el
Created October 3, 2012 08:38
Towards a declarative dependency management solution for emacs
;; canonical list
(defvar my-packages
'(ack haskell-mode ruby-mode coffee-mode deft expand-region
gist inf-ruby magit yaml-mode)
"Canonical list of packages.")
(el-get-cleanup my-packages)
(el-get 'sync my-packages)
@danielsz
danielsz / gist:4017605
Created November 5, 2012 15:00
Concurrent Hello world in ruby with Celluloid, an actor library
require 'celluloid'
class Hello
include Celluloid
def say_hello
@danielsz
danielsz / 1_Note.md
Created November 5, 2012 15:00
Concurrent "Hello, world" with Celluloid, an actor library for Ruby

The premise of this exercise is contained in Daniel Himelein's quote:

"The first thing I always do when playing around with a new software platform is to write a concurrent "Hello World" program. The program works as follows: One active entity (e.g. thread, Erlang process, Goroutine) has to print "Hello " and another one "World!\n" with the two active entities synchronizing with each other so that the output always is "Hello World!\n". Here is the concurrent Hello World program in Go, Erlang and in C++ using the Mindroid framework."

Original post

Here is a Hello World example in Ruby/Celluloid. Five, actually.

@danielsz
danielsz / workflow
Last active December 21, 2015 01:59
Pairing on Clojure repl-based workflow
Stuart Sierra has written an article describing how he works with Clojure interactively using the REPL, tools.namespace, and Leiningen.
http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded
Commentary on Hacker News: https://news.ycombinator.com/item?id=5819487
The process described there constitute best practices with a very broad application field. It is so fundamental, in fact, that most Clojure applications would probably benefit from adopting this model.
I'm interested to provide a fleshed out example of that workflow to benefit new users/beginners. The blog post, while eye-opening, still isn't enough to get started for a whole range of users. I'm saying this because I'm struggling myself.
I would like the example to be web oriented. I was thinking to use liberator to provide a REST API with one resource that can be created/edited/updated/deleted, and db persistence. DB would be either datomic or mongodb.
@danielsz
danielsz / guidelines.txt
Last active January 3, 2016 01:29
Israel Clojure user group gathering: Dojo I, instructions and guidelines.
The task of this Dojo is to play a tune with Overtone, namely "In the Summertime" by Mungo Jerry.
http://www.youtube.com/watch?v=wvUQcnfwUUM
http://www.youtube.com/watch?v=yG0oBPtyNb0
Wifi password: Elc0Campus
The instructions on how to set up a working overtone environment are detailed in this excellent guide:
http://bzg.fr/emacs-org-babel-overtone-intro.html
@danielsz
danielsz / germain.clj
Last active January 3, 2016 23:29
Sophie Germain primes
(require '[clojure.math.numeric-tower :refer [sqrt]])
(defn smallest-divisor [n]
(find-divisor n 2))
(defn divides? [a b]
(= (mod b a) 0))
(defn find-divisor [n test-divisor]
(cond (> (sqrt test-divisor) n) n
@danielsz
danielsz / pushState.cljs
Last active July 15, 2016 15:13
PushState (via Html5History from google closure) with secretary, a client-side routing library for clojurescript. Allows to map absolute urls with routes without the hash-bang hackery.
(def history (Html5History.))
(.setUseFragment history false)
(.setPathPrefix history "")
(.setEnabled history true)
(let [navigation (listen history EventType/NAVIGATE)]
(go
(while true
(let [token (.-token (<! navigation))]
(secretary/dispatch! token)))))