This file contains hidden or 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
#!/usr/bin/env elixir | |
Mix.install([{:cas, git: "https://github.com/ckampfe/cas"}]) | |
defmodule M do | |
alias Cas.Atom | |
def main_cas do | |
atom = Atom.new(1) |
This file contains hidden or 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
(ns ckampfe.protocol | |
(:require [clojure.java.io :as io])) | |
(defrecord BulkString [s]) | |
(defrecord SimpleError [s]) | |
(defmacro as-byte [s] | |
`(byte (first ~s))) | |
(declare decode) |
This file contains hidden or 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 SpecTest do | |
require Integer | |
use ExUnit.Case | |
doctest Spec | |
test "valid?/2" do | |
assert Spec.valid?(&Integer.is_even/1, 2) | |
refute Spec.valid?(&Integer.is_even/1, 1) | |
assert Spec.valid?(MapSet.new([1, 2, 3]), 1) | |
refute Spec.valid?(MapSet.new([1, 2, 3]), 9) |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>net.clojars.ckampfe</groupId> | |
<artifactId>fp</artifactId> | |
<version>0.1.0-SNAPSHOT</version> | |
<name>ckampfe/fp</name> | |
<description>FIXME: my new application.</description> | |
<url>https://github.com/ckampfe/fp</url> | |
<licenses> |
This file contains hidden or 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 const_format::formatc; | |
use serde::de::DeserializeOwned; | |
use sqlx::{Acquire, Pool, Sqlite, SqliteConnection}; | |
use std::fmt::Debug; | |
use std::str::FromStr; | |
use thiserror::Error; | |
use tokio::task::JoinError; | |
use worker::Worker; | |
mod worker; |
This file contains hidden or 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
# A demonstration of the SQLite `database is locked` error, and its fix. | |
# For more detail see | |
# | |
# to see the error, run: | |
# `python lock.py` | |
# | |
# and to see the fix, run: | |
# `python lock.py correct` | |
import logging |
This file contains hidden or 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 sqlx::sqlite::SqliteQueryResult; | |
use sqlx::{Executor, SqliteConnection}; | |
use std::future::Future; | |
use std::ops::{Deref, DerefMut}; | |
pub(crate) trait SqliteConnectionExt { | |
fn begin_immediate(&mut self) -> impl Future<Output = sqlx::Result<Transaction>>; | |
} | |
impl SqliteConnectionExt for SqliteConnection { |
This file contains hidden or 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
#!/usr/bin/env awk | |
BEGIN { | |
print "principal", "interest_rate", "term", "monthly_payment", "total_paid", "interest_paid" | |
} | |
NR == 1 && NF == 0 { | |
print "use:" | |
print "\tawk -f amortize" |
This file contains hidden or 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
CREATE TABLE f (id integer primary key, value text, inserted_at default current_timestamp); | |
INSERT INTO f VALUES(1,'{"a":1}','2022-05-16 04:24:48'); | |
INSERT INTO f VALUES(2,'{"a":2}','2022-05-16 04:25:11'); | |
INSERT INTO f VALUES(3,'{"a":2, "b":3}','2022-05-16 04:25:15'); | |
INSERT INTO f VALUES(4,'{"a":2, "b":99}','2022-05-16 04:25:18'); | |
INSERT INTO f VALUES(5,'{"a":3}','2022-05-16 04:25:32'); |
This file contains hidden or 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
g = :digraph.new() | |
v1 = :digraph.add_vertex(g, "v1") | |
v2 = :digraph.add_vertex(g, "v2") | |
v3 = :digraph.add_vertex(g, "v3") | |
v4 = :digraph.add_vertex(g, "v4") | |
:digraph.add_edge(g, v2, v1) | |
:digraph.add_edge(g, v3, v2) | |
:digraph.add_edge(g, v4, v2) |
NewerOlder