Skip to content

Instantly share code, notes, and snippets.

@alllex
alllex / Tail
Created November 9, 2012 14:04
Program outputs last lines of input file
/*
Math-Mech 2012-171
Semin A
Tail
*/
#include <stdio.h>
#include <malloc.h>
#include "logList.h"
#include <stdlib.h>
@alllex
alllex / tail.c
Created November 9, 2012 14:07
Program outputs last lines of input file
/*
Math-Mech 2012-171
Semin A
Tail
*/
#include <stdio.h>
#include <malloc.h>
#include "logList.h"
#include <stdlib.h>
import Control.Concurrent.STM
import Control.Concurrent.STM.TSkipList -- cabal install tskiplist
import Prelude hiding(minimum, maximum)
main :: IO ()
main = do
pq <- atomically $ new
atomically $ insert 8 80 pq -- insert the only item
atomically $ delete 8 pq -- remove it from skip list
(_, v) <- atomically $ minimum pq -- must be an error!!!
print v -- prints 80
@alllex
alllex / stm-data-test.cabal
Created October 22, 2015 11:20
Cabal file for stm-data-collection-test
name: stm-data-test
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10
executable stm-data-test
main-is: Main.hs
build-depends: base >=4.8 && <4.9, stm >=2.4 && <2.5, stm-data-collection == 0.1.0.0
default-language: Haskell2010
@alllex
alllex / Main.hs
Created October 22, 2015 11:23
Main file for stm-data-collection-test
import Control.Monad ( forM_ )
import Control.Concurrent.STM
import qualified Data.STM.Bag as Bag
import qualified Data.STM.PriorityQueue as PQ
pqTest :: IO ()
pqTest = do
putStrLn "Start priority queue test"
pq <- atomically $ (PQ.new :: STM (PQ.Impl Int Int))
@alllex
alllex / stm-data-collection-test.sh
Created October 22, 2015 11:39
Script for setting up example of stm-data-collection usage
#!/bin/sh
dir=stm-data-collection-test
libdir=stm-data-collection
testdir=stm-data-test
cd /tmp
mkdir $dir
cd $dir
@alllex
alllex / noutm-bookmarket.js
Created April 16, 2021 11:09
A bookmarketlet, that remote any query parameters starting with `utm_` from the current URL.
javascript:
(function () {
const oldSearch = window.location.search;
let newSearch =
oldSearch.replace(/&?utm_[^=]*?=[^&]*?(?:&|$)/ig, "");
if (newSearch === "?") {
newSearch = "";
}
window.location.href =
window.location.protocol + "//" +
val myStaks = object : StaksParser<List<Triple<String, String, String>>() {
val a = tagText("a")
val b = tagText("b")
val c = tagText("c")
val lst = list("el") { Triple(a(), b(), c()) } // list function now accepts the lamda that does the parsing directly
}
val lst = myStaks.lst(inp)
@alllex
alllex / blank.html
Created January 7, 2022 20:20
"This page intentionally left blank"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Blank</title>
<link href="data:image/x-icon;base64,AAABAAEAEBAQAAAAAAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAsC8qAP+EAACzh1cAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAACAAAAAAAAACAAAAAAAAEiAAAAADAAAiAAAAAAMzAiAAAAAAAAMzAAAAAAAAAiMzMAAAAAAAADAzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA" rel="icon" type="image/x-icon" />
@alllex
alllex / obsidian-style-tweaks.css
Last active February 23, 2024 17:35
Drop-in style tweaks for Obsidian making Live Preview as close as possible to the rendered Preview.
/* Obsdian styles */
/* Tested on v0.14.2 */
/*
Partially based on:
- https://github.com/Dmitriy-Shulha/obsidian-css-snippets
*/
/* tags */
/* ---- */