Skip to content

Instantly share code, notes, and snippets.

View mvarela's full-sized avatar
💭
The forecast is hacky, with high chance of parenthesis

Martín Varela mvarela

💭
The forecast is hacky, with high chance of parenthesis
View GitHub Profile
@jasoncodes
jasoncodes / gist:1223731
Created September 17, 2011 07:45
Installing Ruby 1.9.3 with rbenv on OS X
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
(ns net.cgrand.decay
"Exponentially decaying lists. See http://awelonblue.wordpress.com/2013/01/24/exponential-decay-of-history-improved/
for background and http://clj-me.cgrand.net/2013/02/12/decaying-lists-log-scale-for-lists/ for documentation")
;; PRNG, formulas straight from java.util.Random javadoc
(defn- seed ^long [^long n]
(bit-and (unchecked-multiply n 0x5DEECE66D)
(unchecked-dec (bit-shift-left 1 48))))
(defn- next-seed ^long [^long seed]
@giumas
giumas / Logging - SQLite handler
Last active February 15, 2023 02:23
A minimal SQLite handler for the python logging module
from __future__ import absolute_import, division, print_function, unicode_literals
import sqlite3
import logging
import time
__version__ = "0.1.0"
initial_sql = """CREATE TABLE IF NOT EXISTS log(
@sunng87
sunng87 / reflection.clj
Created November 20, 2015 10:04
clojure: access private field/method via reflection
(defn invoke-private-method [obj fn-name-string & args]
(let [m (first (filter (fn [x] (.. x getName (equals fn-name-string)))
(.. obj getClass getDeclaredMethods)))]
(. m (setAccessible true))
(. m (invoke obj args))))
(defn private-field [obj fn-name-string]
(let [m (.. obj getClass (getDeclaredField fn-name-string))]
(. m (setAccessible true))
(. m (get obj))))
@bishboria
bishboria / springer-free-maths-books.md
Last active June 8, 2024 06:39
Springer made a bunch of books available for free, these were the direct links
@jjmalina
jjmalina / debian-8-jessie-lenovo-x1-carbon-4th-gen.md
Last active July 6, 2021 17:45
Installing Debian 8.5 "jessie" on a Lenovo X1 Carbon 4th generation

Installing Debian 8.5 "jessie" on a Lenovo X1 Carbon 4th generation (20FB) - 2016

UPDATE 2018-02-24: I got a new Lenovo X1 Carbon 5th gen and tried to do the same setup with Debian 9.3.0. It was an utter failure because of some boot issues. I went with Xubuntu instead and everything works FLAWLESSLY. Xubuntu is beautiful.

I've had my mind on switching my development machine from a 13" MacBook Pro Retina to a Lenovo X1 Carbon running Linux for a while. The main reason is getting more familiar with Linux itself and also to have a more stable and minimal dev environment. So I finally got the machine and decided to install Debian 8.5 "jessie". Why Debian? Well, I tried installing Arch Linux once and couldn't get past getting wifi to work, and Ubuntu seemed like it added too much stuff. The choice was either Debian or Linux Mint. I went with Debian because it seems like it's the most stable.

Create a bootable USB stick

I followed the instructions at https://www.debian.org/releases/jessie/amd64/ch04s

@Airblader
Airblader / make_dock.sh
Created May 9, 2017 09:44
Turn any window into a dock for i3 (caution, dock windows do not take focus ever)
#!/usr/bin/env bash
# call like this:
# /path/to/this/script.sh <window_id> <dock height>
win="${1:-}"
height="${2:-}"
width=$(xrandr -q | head -n1 | awk '{print $8}')
xdotool windowunmap --sync ${win}
xdotool windowsize --sync ${win} ${width} ${height}
@borkdude
borkdude / text_xform.clj
Created September 1, 2017 13:07
Clojure text files transducer
(ns text-xform
(:require [clojure.java.io :as io]
[clojure.string :as str]
[cheshire.core :as json])
(:import [java.io BufferedReader]))
;;;; inspired by https://tech.grammarly.com/blog/building-etl-pipelines-with-clojure
(def db (atom 0))

How Clojure's documentation can leapfrog other languages

Summary

I made a documentation generator that cashes in on Clojure's dynamism. See the play-cljs docs (a ClojureScript game library) for an example of its output.

The Problem

Like many of you, I've often wondered what my final regret will be on my deathbed. My best guess came to me in a dream recently. I was walking across the charred earth of an apocalyptic future world, maneuvering around the remains of the less fortunate. I was startled to find a young girl, barely holding onto her life. She murmured something to me. I asked her to repeat it, and she said more loudly: "I...wish your Clojure projects didn't have such crappy documentation."

@pjstadig
pjstadig / transducers.md
Last active June 8, 2021 13:22
The secret feature of transducers that no one talks about!

The Pledge

One thing that always made me a little sad about transducers was how map lost its ability to iterate multiple collections in parallel. This is actually my favorite feature of map. For example:

(map + (range 5) (range 5 10))
=> (5 7 9 11 13)

One somewhat practical use of this is if you want to compare two sequences, pairwise, using a comparator. Though I wish that every? took multiple collections, this is an adequate substitute: