Skip to content

Instantly share code, notes, and snippets.

@runexec
runexec / Clojure Does Objects Better.clj.md
Last active June 17, 2020 03:47
Clojure Does Objects Better

Clojure does Objects Better

A hopefully short and concise explanation as to how Clojure deals with Objects. If you already write Clojure, this isn't for you.

You know what an Interface is if you write/read Java or PHP 5+. In Clojure it might be called defprotocol.

user> (defprotocol IABC
        (also-oo [this])
        (another-fn [this x]))

IABC

@stackia
stackia / homebrew.mxcl.aria2.plist
Last active October 13, 2023 04:50
aria2c daemon start at boot. Put this file into /Library/LaunchDaemons, them 'chmod 600' and 'chown root'. Remember to fill placeholders below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.aria2</string>
@arctouch-shadowroldan
arctouch-shadowroldan / brew
Last active July 27, 2020 21:28
Brew install all the apps
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew update
brew install wget
brew install watch
brew install mobile-shell
brew install mysql --client-only
brew install git
brew install gnu-sed
brew install graphicsmagick
@ryanwersal
ryanwersal / example.clj
Created October 21, 2014 04:18
msgpack based websocket communication between clojure and python
(ns example.core
(:gen-class)
(:require [immutant.web :as web]
[immutant.web.websocket :as ws]
[ring.middleware.resource :refer [wrap-resource]]
[ring.util.response :refer [redirect]]
[msgpack.core :as msgpack]))
(defn -main
[& args]
@afolarin
afolarin / docker-log-gist.md
Last active March 16, 2023 13:02
docker-logs
@ptaoussanis
ptaoussanis / transducers.clj
Last active December 8, 2024 03:24
Quick recap/commentary: Clojure transducers
(comment ; Fun with transducers, v2
;; Still haven't found a brief + approachable overview of Clojure 1.7's new
;; transducers in the particular way I would have preferred myself - so here goes:
;;;; Definitions
;; Looking at the `reduce` docstring, we can define a 'reducing-fn' as:
(fn reducing-fn ([]) ([accumulation next-input])) -> new-accumulation
;; (The `[]` arity is actually optional; it's only used when calling
;; `reduce` w/o an init-accumulator).
@MichaelDrogalis
MichaelDrogalis / gist:bc620a7617396704125b
Last active May 22, 2018 14:26
The Anatomy of an Onyx Program

The Anatomy of an Onyx Program

In this tutorial, we'll take an in-depth view of what's happening when you execute a simple Onyx program. All of the code can be found in the Onyx Starter repository if you'd like to follow along. The code uses the development environment with HornetQ and ZooKeeper running in memory, so you don't need additional dependencies to run the example for yourself on your machine.

The Workflow

At the core of the program is the workflow - the flow of data that we ingest, apply transformations to, and send to an output for storage. In this program, we're going to ingest some sentences from an input source, split the sentence into individual words, play with capitalization, and add a suffix. Finally, we'll send the transformed data to an output source.

Let's examine the workflow pictorially:

@tom-galvin
tom-galvin / prim.clj
Created August 10, 2014 12:45
Implement's Prim's algorithm in Clojure
; Input via stdin
; Formatted as described in reddit.com/r/dailyprogrammer/comments/20cydp/14042014_challenge_152_hard_minimum_spanning_tree/
(defn with-index [coll]
(map-indexed vector coll))
(defn get-adjacency []
(with-index (map with-index
(repeatedly (read-string (read-line))
#(map read-string (clojure.string/split (read-line) #", *"))))))
@sebmarkbage
sebmarkbage / transferring-props.md
Last active September 27, 2024 00:10
Deprecating transferPropsTo

Deprecating transferPropsTo

It's a common pattern in React to wrap a component in an abstraction. The outer component exposes a simple property to do something that might have more complex implementation details.

We used to have a helper function called transferPropsTo. We no longer support this method. Instead you're expected to use a generic object helper to merge props.

render() {
 return Component(Object.assign({}, this.props, { more: 'values' }));