Skip to content

Instantly share code, notes, and snippets.

View greenmang0's full-sized avatar
😀

Abhishek Amberkar greenmang0

😀
View GitHub Profile
@blakesmith
blakesmith / gist:1587593
Created January 10, 2012 07:08
Simple pallet script
(ns pallet-test.core
(:use
[clojure.contrib.command-line])
(:require
[pallet.core :as core]
[pallet.compute :as compute]
[pallet.phase :as phase]
[pallet.crate.java :as java]
[pallet.crate.automated-admin-user :as automated-admin-user]))
@kapilreddy
kapilreddy / gist:2868961
Created June 4, 2012 15:10
Midje emacs functions
(remove-hook 'clojure-mode-hook 'clojure-test-maybe-enable)
(defun clojure-in-tests-p ()
(or (string-match-p "test\." (clojure-find-ns))
(string-match-p "/test" (buffer-file-name))))
(defun midje-test-for (namespace)
(let* ((namespace (clojure-underscores-for-hyphens namespace))
(segments (split-string namespace "\\."))
@alq666
alq666 / pgsnap.py
Created June 18, 2012 03:52
xfs-freeze + ebs snapshots
import boto
import logging
import os
import time
import subprocess
import sys
import urllib2
logger = logging.getLogger("pgbackup")
logger.addHandler(level=logging.INFO, logging.handlers.SysLogHandler(facility=logging.handlers.SysLogHandler.LOG_LOCAL0))
@kirikaza
kirikaza / fix-git-packfiles.sh
Created August 7, 2013 21:08
Fixes unaccessable packfiles in the git repo, i.e. errors like "packfile .git/objects/pack/pack-<hash>.pack cannot be accessed". If there are no such packfiles, the script just does "git gc". It is safe enough. See http://stackoverflow.com/a/14571150/421146
#!/bin/bash
packlist=`mktemp`
git gc 2>&1 |
grep '^warning: packfile .* cannot be accessed$' |
cut -d' ' -f3 |
sort -u > $packlist
packs_count=`wc -l < $packlist`
temp=`mktemp`
#!/usr/bin/env python3
#
# Dumb script to dump (some) of bcache status
# Copyright 2013 Darrick J. Wong. All rights reserved.
#
# This file is part of Bcache. Bcache is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@franklinjavier
franklinjavier / cVim-alfred.css
Last active June 4, 2019 15:43
cVim theme inspired by Yosemite Spotlight
#cVim-link-container, .cVim-link-hint, #cVim-command-bar, #cVim-command-bar-mode, #cVim-command-bar-input, #cVim-command-bar-search-results, .cVim-completion-item, .cVim-completion-item .cVim-full, .cVim-completion-item .cVim-left, .cVim-completion-item .cVim-right, #cVim-hud, #cVim-status-bar {
font-family: Helvetica, Helvetica Neue, Neue, sans-serif, Arial;
font-size: 9pt !important;
-webkit-font-smoothing: antialiased !important;
border-radius: 4px!important;
}
#cVim-link-container {
position: absolute;
pointer-events: none;

The thing that students have the hardest time on when learning functional programming is how to process a recursive structure while maintaining some sort of "state", the result if you will. I'll attempt here to demystify the process.

Functional programming languages almost always use a lot of recursively defined structures. Depending on the language those can be implemented in various ways, but in any case the end result is the same. A structure of this type is either an "atom", i.e. an irreducible thing, or a "compound" consisting of substructures of the same form.

For example a "list" is either an Empty/Nil list (the "atom") or it is formed as a Cons of a value and another list (compound form). That other "sublist" can itself be empty or another cons and so on and so forth. A tree is similar. It is either empty, or it consists of a triple of a value and two sub-trees, left and right.

Almost every problem we encounter is a question about doing something with all entries in a structure. To solve these prob

#!/usr/bin/env python3
#
# Dumb script to dump (some) of bcache status
# Copyright 2013 Darrick J. Wong. All rights reserved.
#
# This file is part of Bcache. Bcache is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@metamorph
metamorph / .spacemancs
Created May 8, 2015 09:08
Spacemacs - disable flyspell by default
;; Remove fly-spell for markdown and text-files.
(remove-hook 'text-mode-hook 'enable-flyspell-mode)
(remove-hook 'markdown-mode-hook 'enable-flyspell-mode)
@cszentkiralyi
cszentkiralyi / vim-sexp-cheatsheet.md
Last active November 10, 2023 10:05
vim-sexp cheatsheet

Prereqs

These are for the combined vim-sexp (https://github.com/guns/vim-sexp) and vim-sexp-mappings-for-regular-people (https://github.com/tpope/vim-sexp-mappings-for-regular-people) plugins. vim-sexp is neat on its own but Tim Pope makes common stuff much easier.

Note that some vim-sexp functionality depends on <LocalLeader> mappings. This is a different leader key than the global leader, and is the variable maplocalleader (instead of mapleader). To see if you have this set, use :echo maplocalleader; if it errors out you'll need to set it, otherwise it will echo the key. If you want to set your LocalLeader to <Space>, you'll need two commands in your .vimrc, since by default <Space> is bound to <Right> in normal mode:

nnoremap <Space> <Nop>
let maplocalleader=" "

TOC