Skip to content

Instantly share code, notes, and snippets.

Max A.K. max630

View GitHub Profile
View test chan+exec
#!/usr/bin/env tclsh
package require Tk
pack \
[button .send -text Send -command {puts [lindex $pIn 1] $inData}] \
[entry .b -textvariable inData] \
[text .a]
set pIn [chan pipe]
@max630
max630 / SoTrans.hs
Created May 5, 2018
"Properly" call callbacks inside IO with transformers
View SoTrans.hs
-- https://stackoverflow.com/questions/50166215/how-to-modify-a-state-monad
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module SoTrans where
import Control.Concurrent.MVar
import Control.Monad
@max630
max630 / BitbucketServer_FirstParentsOnly.user.js
Last active Jun 10, 2017
Greasemonkey script to show only first parents in bitbucket server's commit list
View BitbucketServer_FirstParentsOnly.user.js
// ==UserScript==
// @name BitbucketServer_FirstParentsOnly
// @namespace http://max630.net
// @include https://example.com/projects/FOO/repos/BAR/commits*
// @version 1
// @grant none
// @run-at document-idle
// ==/UserScript==
function HandleContent() {
@max630
max630 / TryOptions.lhs
Created Jan 25, 2017
optparse-applicative question
View TryOptions.lhs
> {-# LANGUAGE TupleSections #-}
> import Control.Applicative
> import Data.List (isPrefixOf)
> import Options.Applicative
> prefixReader expect = eitherReader $ prefixReader' expect
> prefixReader' expect s = if expect `isPrefixOf` s
> then Right s
> else Left ("not(\"" ++ s ++ "\" `isPrefixOf` \"" ++ expect ++ "\")")
@max630
max630 / T1.hsc
Created Dec 15, 2016
getting HANDLE name
View T1.hsc
{-# LANGUAGE TypeFamilies #-}
module T1 where
import qualified Graphics.Win32.Misc as WM
import qualified System.Win32.Types as WT
import qualified System.Win32.File as WF
import Data.Int
import Data.Word
import Foreign.Ptr(Ptr())
@max630
max630 / mktest.sh
Created Nov 5, 2016
pr3436 vs submodules
View mktest.sh
#!/bin/sh
set -e
mkdir -p /tmp/pr3436/sub_origin
cd /tmp/pr3436/sub_origin
git init /tmp/pr3436/sub_origin
mkdir subdir
seq 1 10 >subdir/f
git add subdir/f
@max630
max630 / InlineDoBind.hs
Last active Apr 18, 2016
syb based implementation of InlineDoBind
View InlineDoBind.hs
{-# LANGUAGE FlexibleContexts, TemplateHaskell, TupleSections #-}
module InlineDoBind where
import Data.Data (Data, gmapM)
import Data.Generics.Aliases (extM)
import Language.Haskell.TH (Exp(DoE,AppE,VarE,InfixE),Stmt(BindS),Pat(VarP))
import Language.Haskell.TH.Syntax (Quasi,qNewName)
import Control.Monad.Trans.Writer.Strict (runWriterT,WriterT)
import Control.Monad.Trans.Class (lift)
@max630
max630 / MonadStateIO.hs
Created Feb 8, 2016
Monad.Trans.State replacement which uses IORef and keeps state across exceptions
View MonadStateIO.hs
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
module MonadStateIO (evalStateT,execStateT) where
import Data.Tuple (swap)
import qualified Control.Applicative as App
import qualified Control.Monad.Catch as MC
import qualified Control.Monad.Trans as MT
@max630
max630 / Foo.hs
Last active Jan 10, 2016
attempt to use DataKinds
View Foo.hs
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE UndecidableInstances #-}
@max630
max630 / .Xdefaults
Created May 30, 2015
urxvt keyboard selection
View .Xdefaults
URxvt.perl-lib: /home/max/configs/rxvt
URxvt.perl-ext-common: default,keyboard-selection,selection-popup
URxvt.keysym.C-Tab: perl:keyboard-select:activate
URxvt.keysym.M-v: perl:keyboard-select:activate
URxvt.utmpInhibit: false
You can’t perform that action at this time.