View test_psycopg2_isolation_level.py
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 psycopg2 | |
dsn = "postgresql://user:password@localhost:5432/" | |
db_name = "test_db" | |
conn = psycopg2.connect(dsn) | |
try: | |
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) | |
with conn.cursor() as cur: |
View turtle_loop_vs_nondet.hs
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 Control.Monad | |
import Turtle | |
main :: IO () | |
main = sh $ | |
forM_ [(1::Int)..2] $ \i -> do | |
j <- select [(1::Int)..3] | |
liftIO $ print (i, j) | |
{- |
View QueryInterface.hs
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 ConstraintKinds #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE TypeApplications #-} | |
module QueryInterface where | |
-- Maybe (GHC.Exts.DictBox a) | |
data QueryIntefaceResult a where |
View RWLock.hs
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
{-# OPTIONS_GHC -Wall #-} | |
----------------------------------------------------------------------------- | |
-- | | |
-- Module : RWLock | |
-- Copyright : (c) Masahiro Sakai 2023 | |
-- License : BSD-3-Clause | |
-- | |
-- Simple implement of various variants of RWLocks. | |
-- |
View FairLock.hs
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
{-# OPTIONS_GHC -Wall #-} | |
----------------------------------------------------------------------------- | |
-- | | |
-- Module : FairLock | |
-- Copyright : (c) Masahiro Sakai 2023 | |
-- License : BSD-3-Clause | |
-- | |
-- Simple Lock implemented using STM. | |
-- When multiple threads are blocked on a Lock, they are woken up in FIFO order. |
View Main.hs
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 (main) where | |
import Control.Concurrent.Async | |
import Control.Concurrent | |
import Control.Exception | |
import Control.Monad | |
import Data.IORef | |
import Foreign.C | |
import System.Random.MWC |
View list_ext_modules.py
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 sys | |
for mname, m in sys.modules.items(): | |
fname = getattr(m, '__file__', None) | |
if fname is not None and fname.endswith('.so'): | |
print(f"{mname}: {fname}") |
View FermatsFactorizationMethod.hs
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 FermatsFactorizationMethod where | |
import Control.Monad | |
import Data.List (sort) | |
import Math.NumberTheory.Roots -- https://hackage.haskell.org/package/integer-roots | |
factor :: Integer -> [Integer] | |
factor = sort . g | |
where | |
g 1 = [] |
View ruby-puzzles-2022.rb
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
# coding: utf-8 | |
def answer1(n) | |
n + 1 | |
end | |
def answer2(str) | |
str.upcase | |
end | |
def answer3(n) |
View SecantMethod.hs
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
-- | | |
-- | |
-- * [Secant method](https://en.wikipedia.org/wiki/Secant_method) | |
-- | |
-- * [割線法](https://ja.wikipedia.org/wiki/%E5%89%B2%E7%B7%9A%E6%B3%95) | |
module SecantMethod where | |
secantMethod :: (Eq a, Fractional a) => (a -> a) -> a -> a -> [a] | |
secantMethod f x0 x1 = map fst xs | |
where |
NewerOlder