Skip to content

Instantly share code, notes, and snippets.

View omartell's full-sized avatar
🚀
Shipping

Oliver Martell Núñez omartell

🚀
Shipping
  • London, United Kingdom
View GitHub Profile
(defn partition-2
([n col]
(partition-2 n col [] []))
([n col result current-partition]
(let [element (first col)]
(if (empty? col)
result
(recur n
(rest col)
(if (or (empty? (rest col)) (= (count current-partition) n))
@omartell
omartell / index.clj
Created January 24, 2018 08:57
Vanilla Search Index
(ns swiftype.core
(:require [clojure.string :as string]))
(def document-db (atom {}))
(def index (atom {}))
(defn add [id document]
(let [result (swap! document-db assoc id document)
keywords (string/split document #"\s")
@omartell
omartell / sudoku.clj
Created January 16, 2018 23:42
Sudoku Check
(defn sudokuCheck [rows]
(let [digits (set (range 1 10))
all-digits? (fn [col]
(every? (comp empty? #(clojure.set/difference digits (set %)))
col))
columns (for [index (range 0 9)]
(for [row rows]
(get row index)))
squares (for [gx (partition 3 (range 0 9))
gy (partition 3 (range 0 9))]
@omartell
omartell / spacemacs.el
Created October 20, 2017 11:07
Spacemacs
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(set-face-italic 'font-lock-comment-face nil)
(set-face-bold 'font-lock-comment-face nil)
(set-face-bold-p 'bold nil)
(defun osx/pre-init-exec-path-from-shell ()
(use-package exec-path-from-shell

Things that programmers don't know but should

(A book that I might eventually write!)

Gary Bernhardt

I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel. For comparison, articles in large papers like the New York Times average about 1,200 words. Each topic gets whatever level of detail I can fit into that space. For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.

@omartell
omartell / gist:bf01bf499e5b917035d0b1ad70b6dfb5
Last active June 1, 2016 16:23 — forked from telent/gist:9742059
12 factor app configuration vs leaking environment variables
App configuration in environment variables: for and against
For (some of these as per the 12 factor principles)
1) they are are easy to change between deploys without changing any code
2) unlike config files, there is little chance of them being checked
into the code repo accidentally
3) unlike custom config files, or other config mechanisms such as Java
@omartell
omartell / gist:f3a3840e7a4bffe5581956d9d9cc1656
Created May 18, 2016 18:52 — forked from mattdenner/gist:dd4cfde3f355ff6b7be8
From imperative to functional: functors, applicatives, monads & other link bait

I’ve been writing a load of Swift code recently for work and this has lead me into the world of typed functional programming. The app needs to build certain objects from a comma separated string, and this lead me to applicative functors, which lead me to brain ache but enlightenment. So here’s my thoughts on how I got to understand these a little better.

All of the code is in Swift, so less clean than Haskell. I’m also only a about 6 weeks into Swift development so I probably haven’t got all of the idioms right. I’ve avoided the optional shorthand wherever possible here, preferring Optional<Type> over Type? because I believe the latter is hiding something that helps understand this code in the context of other generic classes.

It’s also long! I think it’s probably the longest blog post I’ve ever written but I found it interesting and useful, for myself, to write. If you’re one of those people who skip to the end of a book to find out whodunit then I’ve included

 __      _______ __  __            _____ _       _
 \ \    / /_   _|  \/  |    _     / ____| |     (_)
  \ \  / /  | | | \  / |  _| |_  | |    | | ___  _ _   _ _ __ ___
   \ \/ /   | | | |\/| | |_   _| | |    | |/ _ \| | | | | '__/ _ \
    \  /   _| |_| |  | |   |_|   | |____| | (_) | | |_| | | |  __/
     \/   |_____|_|  |_|          \_____|_|\___/| |\__,_|_|  \___|
                                               _/ |
                                              |__/
@omartell
omartell / atom_clojure_setup.md
Created April 30, 2016 09:05 — forked from jasongilman/atom_clojure_setup.md
This describes how I setup Atom for Clojure Development.

Atom Clojure Setup

This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

Install Atom

Download Atom

The Atom documentation is excellent. It's highly worth reading the flight manual.

@omartell
omartell / Brewfile
Last active March 30, 2016 21:39
🍺
autoconf emacs-mac kafkacat netcat rbenv the_silver_searcher
automake ffind leiningen node rcm tmux
boot-clj fish libevent openssl readline tree
brew-cask fzf libffi pcre rlwrap vim
cask gdbm librdkafka pkg-config ruby-build wget
chruby-fish git libsass planck ruby-install xz
ctags heroku-toolbelt libyaml postgresql sassc z
emacs hub lzlib python sqlite zookeeper