This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import ttk | |
import tkinter as tk | |
import functools | |
fp = functools.partial | |
class VerticalScrolledFrame(ttk.Frame): | |
""" | |
A pure Tkinter scrollable frame that actually works! | |
* Use the 'interior' attribute to place widgets inside the scrollable frame | |
* Construct and pack/place/grid normally |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Test.QuickCheck | |
import Data.List (intersperse) | |
split :: Char -> String -> [String] | |
split c [] = [] | |
split c xs = xs' : if null xs'' then [] else split c (tail xs'') | |
where xs' = takeWhile (/=c) xs | |
xs''= dropWhile (/=c) xs | |
unsplit :: Char -> [String] -> String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad | |
import Control.Applicative | |
import Data.List | |
type KnightPos = (Int, Int) | |
nextMoves c r = [(c+2,r-1), (c+2,r+1),(c-2,r-1),(c-2,r+1), | |
(c+1,r-2),(c+1,r+1),(c-1,r-2),(c-1,r+2)] | |
inField c r = (c `elem` [1..8] && r `elem` [1..8]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.ByteString.Char8 as B | |
import System.IO | |
import System.Hardware.Serialport | |
import Control.Monad.Loops | |
import Control.Monad | |
import Data.Char | |
stringToIntList :: String -> [Int] | |
stringToIntList line | |
| ((>2) . length) line = map ord line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Graphics.Rendering.Chart.Easy | |
import Graphics.Rendering.Chart.Gtk | |
import qualified Graphics.UI.Gtk as G | |
import qualified Graphics.Rendering.Cairo as C | |
import qualified Graphics.UI.Gtk.Gdk.Events as GE | |
import Graphics.Rendering.Chart.Renderable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
import System.FSNotify | |
import System.Directory | |
import Control.Applicative((<$>)) | |
import Control.Exception(throw) | |
import Control.Monad(when,forM_) | |
import System.FilePath ((</>)) | |
import Development.Shake.FilePath (splitPath, splitDirectories) | |
import Control.Concurrent (threadDelay) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | This function bridges gi-cairo with the hand-written cairo | |
-- package. It takes a `GI.Cairo.Context` (as it appears in gi-cairo), | |
-- and a `Render` action (as in the cairo lib), and renders the | |
-- `Render` action into the given context. | |
renderWithContext :: GI.Cairo.Context -> ReaderT Cairo IO a -> IO (a) | |
renderWithContext ct rendered = withManagedPtr ct $ \p -> runReaderT rendered (Cairo (castPtr p)) | |
activateRender :: (Int, Int) -> (Channel, DrawingArea) -> IO () | |
activateRender (width, height) (channel, cairoArea) = do | |
widgetSetSizeRequest cairoArea (fromIntegral width) (fromIntegral height) | |