Skip to content

Instantly share code, notes, and snippets.

@curiousleo
curiousleo / NASA Picture-Of-The-Day Wallpaper Script
Created December 28, 2011 18:21 — forked from JoshSchreuder/NASA Picture-Of-The-Day Wallpaper Script
A BASH script to download NASA's picture of the day (http://apod.nasa.gov/apod/astropix.html) automatically saving and setting as wallpaper and saving optional description of image to text.
#!/bin/bash
# Copyright (c) 2011 Josh Schreuder
# http://www.postteenageliving.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@curiousleo
curiousleo / normal.sml
Created October 10, 2012 16:49
Convert propositions to NNF, CNF, DNF
type atom = char
type interpretation = atom -> bool
datatype literal = Yes of atom | No of atom
datatype proposition = Literal of literal
| Not of proposition
| And of proposition * proposition
| Or of proposition * proposition
@curiousleo
curiousleo / L1.lhs
Created April 20, 2013 20:55
A toy interpreter for a simple imperative language using GADTs and monad transformers.
Haskell L1 Interpreter
======================
This is a simple interpreter for L1, with two little twists: It uses
monad transformers to represent state and erroneous computations, and
generalised algebraic datatypes (GADTs) for implicit type checking.
Extensions and Imports
----------------------
@curiousleo
curiousleo / scramble.cc
Created December 8, 2014 09:19
Scramble challenge entry
// scramble.cc
// Leonhard Markert
//
// This program finds words in a character matrix. The words are read from a
// `dictionary` file and the character matrix from a `scramble` file.
//
// Compile with
// $ clang++ -std=c++11 -DNDEBUG -O3 -Wall -W -Werror -o scramble scramble.cc
//
// Run as
#!/usr/bin/env python
from bs4 import BeautifulSoup
from pocket import Pocket
import requests
from urllib.parse import urljoin
consumer_key = '44711-81de59a4a614b97a4b76dc9a'
access_token = 'XXX' # put your access token here
module BasicGates where
open import Level
open import Algebra.FunctionProperties.Core using (Op₁; Op₂)
import Data.Bool as B
open B using (Bool; true; false)
open import Data.Product using (_×_)
open import Data.String

Consider the following two Standard ML functions for computing the sum of a list of integers:

fun nsum n =
    if n=0 then 0
           else n + nsum (n-1);

fun summing (n,total) =
    if n=0 then total
 else summing (n-1, n + total);
@curiousleo
curiousleo / muhttp.cpp
Last active April 24, 2018 19:57
Oversimplified HTTP server in C++
#include <netdb.h>
#include <sys/socket.h>
#include <unistd.h>
#include <algorithm>
#include <cerrno>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <string_view>
@curiousleo
curiousleo / convert.py
Created April 8, 2018 14:33
Convert IUPAC to SMILES and vice versa
import urllib.error
import urllib.parse
import urllib.request
SMILES_URL_TEMPLATE = 'http://cactus.nci.nih.gov/chemical/structure/{}/smiles'
IUPAC_URL_TEMPLATE = 'http://cactus.nci.nih.gov/chemical/structure/{}/iupac_name'
def retrieve(url):
with urllib.request.urlopen(url) as f:
return f.read()
@curiousleo
curiousleo / denkrate.nix
Last active January 5, 2019 14:26
NixOS server experiment
{ config, lib, pkgs, ... }:
with lib;
let
kibanaPort = 5601;
netdataPort = 19999;
oauthProxyPort = 4180;
innerNginxPort = 8080;
in