Skip to content

Instantly share code, notes, and snippets.

@max630
max630 / InlineDoBind.hs
Last active April 18, 2016 20:38
syb based implementation of InlineDoBind
{-# 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 / mktest.sh
Created November 5, 2016 08:40
pr3436 vs submodules
#!/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 / T1.hsc
Created December 15, 2016 23:54
getting HANDLE name
{-# 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 / TryOptions.lhs
Created January 25, 2017 21:40
optparse-applicative question
> {-# 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 / gist:2872656
Created June 5, 2012 04:34
Russian phonetic layout for MS Keyboard Layout Creator
KBD RU2 "Russian Phonetic"
COPYRIGHT "(c) 2011 "
COMPANY "Max"
LOCALEID "00000419"
VERSION 1.0
@max630
max630 / BitbucketServer_FirstParentsOnly.user.js
Last active June 10, 2017 05:09
Greasemonkey script to show only first parents in bitbucket server's commit list
// ==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 / MainCLI.hs
Last active February 8, 2018 18:15
testing prime speed
module Main where
import System.Environment(getArgs)
import qualified Prime
main :: IO ()
main = do
a <- getArgs
Prime.main (a !! 0) (read (a !! 1))
@max630
max630 / SoTrans.hs
Created May 5, 2018 06:31
"Properly" call callbacks inside IO with transformers
-- 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
#!/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]