diff --git a/src/drafts/haskell-design-pattern-in-clojure/index.org b/src/drafts/haskell-design-pattern-in-clojure/index.org new file mode 100644 index 0000000..bc14dcc --- /dev/null +++ b/src/drafts/haskell-design-pattern-in-clojure/index.org @@ -0,0 +1,34 @@ +#+TITLE: Haskell Design Pattern in Clojure +#+SUBTITLE: Some classical haskell tricks equivalent in Clojure +#+AUTHOR: Yann Esposito +#+EMAIL: yann@esposito.host +#+DATE: [2019-11-07 Thu] +#+KEYWORDS: programming +#+DESCRIPTION: LISP to simulate Haskell +#+OPTIONS: auto-id:t + +#+begin_notes +TL;DR: Some clever Haskell trick can in fact be simulated quite efficiently +with Clojure. +#+end_notes + +* Monads +:PROPERTIES: +:CUSTOM_ID: monads +:END: + +#+begin_src haskell + fullName :: Maybe Text -> Maybe Text -> Maybe Text + fullName firstName lastName = do + x <- firstName + y <- lastName + result <- return (x <> y) + + ask :: IO (Maybe Text) + ask = do + l <- readLine + return $ if null l then Nothing else Just l + + askName <- fullName <$> ask "What is your first name?" + <*> ask "What is your last name?" +#+end_src diff --git a/src/posts/0007-switch-iterm-profile-catalina/index.org b/src/posts/0007-switch-iterm-profile-catalina/index.org new file mode 100644 index 0000000..ea28281 --- /dev/null +++ b/src/posts/0007-switch-iterm-profile-catalina/index.org @@ -0,0 +1,71 @@ +#+TITLE: Catalina iTerm Theme switch +#+AUTHOR: Yann Esposito +#+EMAIL: yann@esposito.host +#+DATE: [2019-11-10 Sun] +#+KEYWORDS: self-hosting, chat, irc +#+DESCRIPTION: Small script to change the profile of iTerm in sync with macOS preferences +#+OPTIONS: auto-id:t toc:t + +* The script +:PROPERTIES: +:CUSTOM_ID: the-script +:END: + +For the script to work you need to have two iTerm profiles, one named +=Dark= and the other one =Light=. Just go to =Preferences= then =Profiles= then +=Duplicate profile=. + +I use =fish= but you can easily adapt that in your =.bashrc=, +=.bash_profile= etc... + +Here is what I have in my =~/.config/fish/config.fish=: + +#+begin_src fish + function setItermProfile + echo -ne "\033]50;SetProfile=$argv\a" + end + + function sync_appearance + + set -x MacOSThemeAutoSwitch \ + (defaults read -g AppleInterfaceStyleSwitchesAutomatically 2>/dev/null) + test -z $MacOSThemeAutoSwitch; and set -x MacOSThemeAutoSwitch 0 + + set -x MacOSTheme (defaults read -g AppleInterfaceStyle 2>/dev/null) + test -z $MacOSTheme; and set -x MacOSTheme 'nil' + + # for debug purpose only + # echo $MacOSThemeAutoSwitch + # echo $MacOSTheme + + if test -n $ITERM_PROFILE # check if we are using iTerm2 + switch $MacOSThemeAutoSwitch + case 1 + switch $MacOSTheme + case 'nil' + setItermProfile Light + case '*' + setItermProfile Dark + end + case 0 + switch $MacOSTheme + case 'Dark' + setItermProfile Dark + case 'Light' + setItermProfile Light + case 'nil' + setItermProfile Light + end + end + end + end + + if status --is-login + if status --is-interactive + sync_appearance + end + end +#+end_src + +If the appearance change, you can call =sync_appearance= function in your +shell to sync with the OS dark/light appearance.