Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mudrd8mz
mudrd8mz / gist:2828474
Created May 29, 2012 13:49
Git pre-commit hook that does not allow committing a change containing DONOTCOMMIT text
$ cat .git/hooks/pre-commit
#!/bin/bash
FOUND=$(git diff-index --cached -U0 HEAD -- | grep DONOTCOMMIT | wc -l)
if [[ $FOUND -gt 0 ]]; then
echo "pre-commit hook: DONOTCOMMIT detected, commit not allowed"
exit 1
fi

Dumping Datomic data into a local (free) transactor

Create a database dump from the server running the transactor

bin/datomic backup-db "datomic:ddb://us-east-1/rest/of/url?aws_access_key_id=<ACCESS_KEY_ID>&aws_secret_key=<SECRET_KEY>" file:/home/ian/datomic-backup-`date +"%Y%d%m"`

Transfer the dump to your local machine

@martinklepsch
martinklepsch / README.md
Last active February 28, 2022 04:34
A very minimal Emacs configuration to get started with Emacs & Evil-mode

A Starting Point for using Emacs & Evil-mode

(I wrote a bit about why Emacs and Vim on my blog and thought it might be nice to give some starting point for people that want to try it.)

If you just want to play around with Emacs & Evil mode do the following:

  1. mkdir ~/.emacs.d/
  2. copy init.el into ~/.emacs.d/
  3. Download Emacs from http://emacsformacosx.com
@kordano
kordano / url-param.cljs
Last active September 12, 2022 12:14
URL parameter parsing with clojurescript
(defn parse-params
"Parse URL parameters into a hashmap"
[]
(let [param-strs (-> (.-location js/window) (split #"\?") last (split #"\&"))]
(into {} (for [[k v] (map #(split % #"=") param-strs)]
[(keyword k) v]))))
@TheBB
TheBB / loading.org
Last active June 22, 2023 11:53
Loading in Spacemacs

Emacs packages, features, files, layers, extensions, auto-loading, require, provide, use-package… All these terms getting you confused? Let’s clear up a few things.

Files

Emacs files contains code that can be evaluated. When evaluated, the functions, macros and modes defined in that file become available to the current Emacs session. Henceforth, this will be termed as loading a file.

One major problem is to ensure that all the correct files are loaded, and in the

@jeroenvandijk
jeroenvandijk / datomic.schema_dump.clj
Last active January 23, 2020 10:58
(A) method to dump a datomic database schema
(ns datomic.schema-dump
(:require
[datomic.api :as d]
[clojure.pprint]))
(defmethod clojure.pprint/simple-dispatch datomic.db.DbId [v] (pr v))
(defmethod clojure.pprint/simple-dispatch datomic.function.Function [v] (pr v))
(defn database-url [name]
(str "datomic:mem://" name))
@yang-wei
yang-wei / destructuring.md
Last active February 20, 2024 04:40
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
@moodysalem
moodysalem / promise-cancellable.js
Last active April 9, 2024 18:06
ES6 Cancellable Promise Wrapper
/**
* Returns a promise that has a cancelled method that will cause the callbacks not to fire when it resolves or rejects
* @param promise to wrap
* @returns new promise that will only resolve or reject if cancel is not called
*/
export default function cancellable(promise) {
var cancelled = false;
const toReturn = new Promise((resolve, reject) => {
promise.then(() => {
@john-doherty
john-doherty / javascript-promise-timeout.js
Last active December 17, 2021 02:06
Adds a timeout to a JavaScript promise, rejects if not resolved within timeout period (uses requestAnimationFrame for better accuracy)
(function () {
'use strict';
/**
* wraps a promise in a timeout, allowing the promise to reject if not resolve with a specific period of time
* @param {integer} ms - milliseconds to wait before rejecting promise if not resolved
* @param {Promise} promise to monitor
* @example
* promiseTimeout(1000, fetch('https://courseof.life/johndoherty.json'))
@metametadata
metametadata / react-bootstrap.cljs
Last active June 6, 2017 07:56
Fixing of caret/cursor jumps in text inputs of cljsjs.react-bootstrap
(ns app.components.react-bootstrap
(:require [cljsjs.react-bootstrap]
[reagent.core :as r]))
(def Alert (r/adapt-react-class (.-Alert js/ReactBootstrap)))
(def Button (r/adapt-react-class (.-Button js/ReactBootstrap)))
; ...
(def FormControl (r/adapt-react-class (.-FormControl js/ReactBootstrap))) ; WARNING: use FormControlFixed for text input controls instead
(defn FormControlFixed