Skip to content

Instantly share code, notes, and snippets.

View munen's full-sized avatar

Zen Monk Alain M. Lafon munen

View GitHub Profile
@AnotherKamila
AnotherKamila / screen.sh
Created December 1, 2019 12:31
some silly screen setup script
View screen.sh
#!/bin/sh
MYSCREEN='eDP-1' # the laptop's built-in display
screens=` xrandr | grep ' connected' | grep -v $MYSCREEN | cut -d\ -f1`
notscreens=`xrandr | grep 'disconnected' | grep -v $MYSCREEN | cut -d\ -f1`
for s in $notscreens; do
xrandr --output $s --off
done
@stuarthalloway
stuarthalloway / clojure_spec_missing_piece.clj
Created March 17, 2017 01:11
Clojure spec's missing piece
View clojure_spec_missing_piece.clj
;; clojure.spec's missing piece, work in progress
;; this is only halfway done, somebody else will need to do the other 95%
(require
'[clojure.spec :as s]
'[clojure.spec.test :as test])
(defn naive-english-explain
"Copy and paste this into your app. Figure out what it does by
trying it in production."
@reborg
reborg / rich-already-answered-that.md
Last active February 23, 2024 13:09
A curated collection of answers that Rich gave throughout the history of Clojure
View rich-already-answered-that.md

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@krstffr
krstffr / debounced-redux-thunk-action.js
Created December 16, 2016 12:04
Debouncing redux thunk actions.
View debounced-redux-thunk-action.js
// A common redux pattern when dealing with async functions is to use thunk.
// This usually means your action returns a new function instead of an action object,
// and the thunk middleware will make it all work. Example:
const asyncAction = () => dispatch => setTimeout(() => dispatch(someOtherAction()), 10000);
// Now: maybe that async stuff going on is calling some API which you don't want to overload
// with request, and that's what debounce is for.
// This is an example of a debounced function which will only be calleable once every second.
import { debounce } from 'lodash';
const debouncedFn = debounce(() => callApi(), 1000, { leading: true, trailing: false });
@peyerluk
peyerluk / example
Last active September 20, 2020 14:05
Format swiss phone number
View example
# validating samples:
# 783268674
# 0783268674
# 0410783268674
# 00410783268674
# +410783268674
# 041783268674
# 0041783268674
# +41783268674
# ++41783268674
@jbonney
jbonney / spotify_keybindings
Created June 9, 2013 13:22
Spotify - Linux key bindings. From XFCE / Ubuntu keyboard shortcuts configuration, assign the control command to their key. http://shkspr.mobi/blog/2011/12/linux-spotify-keybindings/
View spotify_keybindings
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious
@jcasimir
jcasimir / friendly_urls.markdown
Created September 11, 2011 15:48
Friendly URLs in Rails
View friendly_urls.markdown

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.