Skip to content

Instantly share code, notes, and snippets.

View crosstyan's full-sized avatar

Crosstyan crosstyan

View GitHub Profile
@dino-
dino- / string-conversions.hs
Last active October 16, 2025 10:14
A handy illustration of converting between String, Text and ByteString in Haskell
#! /usr/bin/env stack
-- stack --resolver lts-18.8 script
{-# LANGUAGE OverloadedStrings #-}
{-
This is a handy illustration of converting between five of the commonly-used
string types in Haskell (String, ByteString, lazy ByteString, Text and lazy
Text).
@Adron
Adron / main.go
Created March 1, 2019 21:34
Getting min max for various types in Go
package main
import (
"fmt"
"math"
)
const(
MinUint uint = 0 // all zeroes
// Perform a bitwise NOT to change every bit from 0 to 1.
@kassane
kassane / Event_Loop.md
Created April 6, 2019 14:26
Explain Event Loop

Event Loop

In computer science, the event loop, message dispatcher, message loop, message pump, or run loop is a programming construct that waits for and dispatches events or messages in a program.

It works by making a request to some internal or external "event provider" (that generally blocks the request until an event has arrived), and then it calls the relevant event handler ("dispatches the event").

The event-loop may be used in conjunction with a reactor, if the event provider follows the file interface, which can be selected or 'polled' (the Unix system call, not actual polling).

The event loop almost always operates asynchronously with the message originator.

@slightfoot
slightfoot / trim_path.dart
Created April 24, 2019 15:00
Trim Path Flutter Dart - 5th February 2019
import 'dart:ui' show Path, PathMetric, Offset;
Path trimPath(Path source, double percentage) {
/// WARNING: computeMetrics returns a iterator that can only be used ONCE!
percentage = percentage.clamp(0.0, 1.0);
if (percentage == 0.0) return Path();
if (percentage == 1.0) return Path.from(source);
final dest = Path();
@MattPD
MattPD / cpp.std.coroutines.draft.md
Last active July 16, 2025 09:11
C++ links: Coroutines (WIP draft)
@lagenorhynque
lagenorhynque / elixir-from-a-clojurians-perspective.md
Last active December 23, 2023 11:19
ClojurianからみたElixir

ClojurianからみたElixir


(defprofile lagénorhynque
  :id           @lagenorhynque
 :reading "/laʒenɔʁɛ̃k/"
@raulqf
raulqf / Install_OpenCV4_CUDA12.6_CUDNN8.9.md
Last active December 3, 2025 20:43
How to install OpenCV 4.10 with CUDA 12 in Ubuntu 24.04

Install OpenCV 4.10 with CUDA 12.6 and CUDNN 8.9 in Ubuntu 24.04

First of all install update and upgrade your system:

    $ sudo apt update
    $ sudo apt upgrade

Then, install required libraries:

@dittmaraz
dittmaraz / mongo-cheatsheet.md
Last active March 5, 2024 19:21
MongoDB/Docker Cheatsheet

Mongo/Docker Cheatsheet

To download the latest image:

$ docker pull mongo:latest

To run a mongo container with detached mode(-p) and with ports mapped (-p 27017-27017:27017-27019) and named (--name mongodb):

$ docker run -d -p 27017-27017:27017-27019 --name mongodb mongo:latest

This is a bit of a thought exercise. I doubt it’s perfect and I’m hoping for opinions and corrections with the goal of a well reasoned practical approach.

Motivation...

One way to look at type declarations in a static language is as a test which picks up potential incompatible code paths. E.g. data passed is incompatible with code.

In static languages the effort to write the test is reduced by virtue of being declared inline with the code and inference allows a few annotations to permeate - having said that we can achieve a similar results in Clojure.

Quick scan of tools at hand...

Windows 10 - Using Git Bash With TMUX

Why Not Use WSL?

I tried the WSL and it isn't quite seamless enough for me. I ran in to problems when editing in VSCode and having watchers on my files (ng serve, dotnet watch run, etc.). In addition, I kept running in to problems that only manifest themselves when running in WSL. For example, this issue with doing production builds and the terser plugin has made many a developer rage-quit on using WSL. Just figuring out that it was an issue with the WSL took a lot of time.

That terser plugin issue was never resolved and I ended up having to keep a git bash window open in addition to my WSL console window so I could do production builds. To make matters worse, my npm packages were platform-dependent so I couldn't use the same project folder. So, my procedure was: commit whatever changes to test branch, push to repo, git pull on my "windows" project folder, and do a production build there