This file contains 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
#!/bin/bash | |
# crontab: | |
# */10 * * * * tzupdate.sh | |
# @reboot doesn't fit because of network connection delay. | |
# Get external IP | |
IP=$(curl ifconfig.me) | |
# Request to geolocation web service (https://ipgeolocation.io/documentation/timezone-api.html). |
This file contains 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
-- Proof that even powers of integers are natural. | |
{-@ powEven :: {a:Int | a /= 0} -> {b:Nat | b mod 2 = 0} -> Nat / [b] @-} | |
powEven :: Int -> Int -> Int | |
powEven a 0 = 1 | |
powEven a b = a * a * powEven a (b - 2) | |
{-@ powOdd :: {a:Int | a /= 0} -> {k:Nat | k mod 2 == 1} -> Int / [k] @-} | |
powOdd :: Int -> Int -> Int | |
powOdd a 1 = a | |
powOdd a b = a * a * powOdd a (b - 2) |
This file contains 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 DataKinds, TypeOperators, TypeApplications #-} | |
module Main where | |
import Control.Concurrent (threadDelay, forkIO) | |
import Control.Monad (when, mapM_) | |
import qualified Data.ByteString.Lazy as BSL | |
import qualified Data.ByteString.Lazy.Char8 as BSLC | |
import Data.HashMap.Strict (HashMap, singleton) |
This file contains 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 GHC.Conc (atomically) | |
import System.Exit (exitSuccess) | |
import Control.Concurrent.STM.TVar (TVar, readTVarIO, newTVarIO, modifyTVar') | |
import Control.Concurrent (forkIO, threadDelay) | |
import Control.Exception (bracket_) | |
import Control.Monad (void, when, forever) |
This file contains 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 Control.Monad | |
-- Directly composing morphisms as if we were not in End_{Hask}. | |
regular :: (->) Int Int | |
regular = (+) 1 . (+) 1 . (+) 1 . (+) 1 | |
-- Actually the same, but explicitly using action of Hom-functor on arrows. | |
functorial :: (->) Int Int |
This file contains 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
type Order = Integer | |
type Element = Integer | |
order :: Order -> Element -> Order | |
order p elem = order' p elem elem 1 | |
where | |
order' _ 1 _ ord = ord | |
order' p power elem ord = order' p (power*elem `mod` p) elem (ord+1) | |
-- Searching any generator of cyclic subgroup of order d. |
This file contains 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 Data.List (sort, nub) | |
type Power = Int | |
type IndexCode = Int | |
type Flag = Int | |
type Orbit = [Power] | |
type Roots = [Power] | |
type P = Int | |
type N = Int |
This file contains 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
type Order = Integer | |
type Element = Integer | |
order :: Order -> Element -> Order | |
order p elem = order' p elem elem 1 | |
where | |
order' _ 1 _ ord = ord | |
order' p power elem ord = order' p (power*elem `mod` p) elem (ord+1) | |
elemsOfOrder :: Order -> Order -> [Element] |
This file contains 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 Data.List (sort, nub) | |
type Power = Int | |
type IndexCode = Int | |
type Flag = Int | |
type Orbit = [Power] | |
type Roots = [Power] | |
type P = Int | |
type N = Int |
This file contains 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 Data.List ((\\), union, sort) | |
type Mono = Int | |
multMonomials :: Mono -> Mono -> Mono | |
multMonomials = (+) | |
divMonomial :: Mono -> Mono -> Mono | |
divMonomial a b = if a > b | |
then a - b |
OlderNewer