Skip to content

Instantly share code, notes, and snippets.

View oshyshko's full-sized avatar

Alex Shyshko oshyshko

View GitHub Profile
@oshyshko
oshyshko / DefaultKeyBinding.dict
Last active September 6, 2015 14:50
os x keyboard fixed pgup/pgdown + home/end
//
// Windows/Linux cursor movement keybindings for OS X
//
// Put this file to ~/Library/KeyBindings/DefaultKeyBinding.dict
// Read more at http://osxnotes.net/keybindings.html
//
{
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
@oshyshko
oshyshko / Atom + Haskell setup that behaves like IntelliJ.cson
Last active May 8, 2018 09:25
How to make your Atom + Haskell setup behave (almost) like IntelliJ
# # #
# How to make your Atom + Haskell setup to behave (almost) like IntelliJ:
# (by Oleksandr Shyshko @oshyshko <-- let me know if you want to contribute or have ideas)
#
# --------------------------------------------------------------------------
# 1. Install Stack (see http://docs.haskellstack.org/ for details)
#
# $ curl -sSL https://get.haskellstack.org/ | sh
# $ stack update
# $ stack setup
(ns whatever)
; loop + recur
(defn max-comparing
([f xs]
(when-let [[x & more] (seq xs)]
(loop [v x, k (f x), xs more]
(if-let [[x & xs] xs]
(let [k' (f x)]
(if (pos? (compare k k'))
module RWSMonads where
import Control.Monad.Reader (Reader, runReader, ask)
import Control.Monad.State (State, runState, evalState, get, put) -- also gets/modify
import Control.Monad.Writer (Writer, runWriter, tell)
getSetCount :: Reader String Int
getSetCount = do
endpoint <- ask
return $ length endpoint
@oshyshko
oshyshko / FDIO.hs
Last active December 31, 2018 07:10
#!/usr/bin/env stack
-- stack --resolver lts-13.0 --install-ghc runghc
-- see https://stackoverflow.com/questions/53978597/haskell-openfile-for-multiple-handles-wrrr-w-o-file-is-locked
module FDIO (Fd, open, read, write, seek, close, with) where
import Control.Exception (bracket)
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as C
#!/bin/sh
set -xue
# taken from https://stackoverflow.com/a/55445034/107341
brew leaves | xargs brew deps --installed --for-each | sed "s/^.*:/$(tput setaf 4)&$(tput sgr0)/"
#brew deps --tree --installed
#!/usr/bin/env stack
-- stack --resolver lts-16.4 script --package fsnotify --package directory --package filepath --package process
-- Usage
-- sync.hs <local-path> <remote-host> <remote-path>
--
-- $ ./sync.hs ./path/to 1.2.3.4 /home/joe/path/to
-- Syncing changes from: /Users/joe/path/to/
-- to: 1.2.3.4:/home/joe/path/to
-- ++ /home/joe/path/to/123/
#!/usr/bin/env stack
-- stack --resolver lts-16.4 script --package network --package bytestring --package split
-- A minimalistic UDP library
{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
module Udp ( withServer
, parseAddr
, Send
, Recv