class Functor m => Monad m where
pure :: a -> m a
join :: m (m a) -> m a
-- or
bind :: (a -> m b) -> m a -> m b
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
// playground for ternary arithmetic | |
// {-1, 0, 1} are represented by {0b10, 0b00, 0b01} respectively | |
// 0b11 is unused. | |
use prettytable::table; | |
use rand::seq::SliceRandom; | |
fn main() { | |
test_add_1(); | |
test_add_32(1000); |
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
use std::{fs::File, io::Read, path::Path}; | |
use pathfinding::prelude::dijkstra; | |
const PART1_MAX_STRAIGHT: usize = 3; | |
const PART2_MIN_STRAIGHT: usize = 4; | |
const PART2_MAX_STRAIGHT: usize = 10; | |
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | |
enum Dir { |
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
defmodule Structural do | |
@moduledoc """ | |
This module is build around this invariance, which I call | |
"reconstruction property": | |
for all m_1, m_2: maps, let m_common = intersect(m_1, m_2), | |
then merge(m_common, diff(m_1, m_common)) == m_1, | |
and merge(m_common, diff(m_2, m_common)) == m_2. | |
This allows us to efficiently store a list of [m_1, m_2, ..., m_K] |
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
try do | |
Mix.Project.get() | |
catch | |
:exit, _ -> | |
Mix.install([ | |
{:nanoid, "~> 2.0.5"}, | |
{:jason, "~> 1.3.0"}, | |
{:timex, ">= 0.0.0"} | |
]) | |
end |
To use this script, you need to install the openai
package using pip. You also need to set the OPENAI_API_KEY
environment variable to your OpenAI API key.
For example, to ask a natural language question, you can pipe the output of ls -al
to the script like this:
ls -al | ./gpt "What are the permissions of the files?"
The script will use the OpenAI GPT-3 model to generate a response to your question with a temperature of 0.2. The response will be printed to the console.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
defmodule Manager.Util.Structural do | |
@moduledoc """ | |
This module is build around this invariance, which I call | |
"reconstruction property": | |
for all m_1, m_2: maps, let m_common = intersect(m_1, m_2), | |
then merge(m_common, diff(m_1, m_common)) == m_1, | |
and merge(m_common, diff(m_2, m_common)) == m_2. | |
This allows us to efficiently store a list of [m_1, m_2, ..., m_K] |
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/sh | |
# this script is only written for gentoo | |
# if you're using other distro, modify part of it as needed | |
# | |
# please run this script run once, as su | |
sh dns.sh | |
iptables-save > /etc/iptables-local | |
cat > /etc/local.d/iptables-restore <<<EOF | |
#!/bin/sh |
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
#lang racket | |
;;; global states | |
(define task-queue '()) | |
(define joiners '()) | |
(define curr-task-handle 'main) | |
(define halt (lambda () (display "not started yet"))) | |
;;; queue-related functions |
NewerOlder