Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE OverloadedStrings #-}
module Main where
import Text.Read ( reads )
import System.IO ( FilePath
, readFile
)
import System.Directory ( doesFileExist )
import Control.Monad ( forever )
import Control.Concurrent ( MVar
def async_read_cache(key, opts={}, &generate)
fetcher = lambda do
Thread.new do
res = { status: :success, data: generate.call }
Rails.cache.set(key, opts, res)
end
{status: :pending}
end
cached_result = Rails.cache.fetch(key, opts, fetcher)
if cached_result[:status] == :pending
#include <iostream>
#include <iomanip>
#include <sstream>
#include <gmpxx.h>
// Using the Babylonian method here, since it's generally good enough
// (with quadratic convergence in the worst case)
// \begin{align*}
// x_0 &= \text{some initial approximation} \\
@kuzux
kuzux / hex.py
Last active January 22, 2019 12:35
#!/usr/bin/env python3
# https://www.redblobgames.com/grids/hexagons is a nice reference
import math
import random
import collections
# importing gtk
import gi
@kuzux
kuzux / fragment.gl
Last active December 19, 2018 19:32
me following yet another OpenGL tutorial - this time in python
#version 330 core
in vec2 fragmentUV;
uniform sampler2D tex;
out vec3 color;
void main(){
color = texture(tex, fragmentUV).rgb;
{-# LANGUAGE OverloadedStrings, TupleSections #-}
module Main where
import System.Environment (getArgs)
import qualified Data.Text as T
import qualified Data.Text.Read as TR
import qualified Data.Text.IO as TIO
import qualified Data.Map.Strict as Map
@kuzux
kuzux / sat.hs
Last active November 4, 2018 14:22
{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
module Main where
import System.Environment (getArgs, getProgName)
import qualified Data.ByteString.Lazy.Char8 as BS
import Data.Maybe (fromJust)
import qualified Data.Set as Set
-- make them install haskell-platform
-- first show on ghci
-- numbers, arithmetic, comparison
-- booleans, logical operators
-- string literals, finding a type of sth
-- lists of integers
-- head and tail functions
-- succ function
-- map succ over some list
-- make them install haskell-platform
-- first show on ghci
-- numbers, arithmetic, comparison
-- booleans, logical operators
-- string literals, finding a type of sth
-- lists of integers
-- head and tail functions
-- succ function
-- map succ over some list
@kuzux
kuzux / Makefile
Last active August 16, 2018 06:00
CFLAGS := -I/usr/local/include -Iinclude/ -std=gnu11 -g -O0 -Wall -Werror -Wpedantic
LDFLAGS := -L/usr/local/lib -luv -lck
SRCS := $(wildcard src/*.c)
OBJS := $(addprefix dest/, $(notdir $(SRCS:%.c=%.o)))
DEPS := $(addprefix dest/, $(notdir $(SRCS:%.c=%.d)))
all: dest/server
.PHONY: clean