Skip to content

Instantly share code, notes, and snippets.

@jmn
jmn / absurls.hs
Created April 27, 2018 14:11
absolute urls in haskell with hxt
import Text.XML.HXT.Core
import Data.Maybe
mkAbsRefs
:: ArrowXml a
=> String -> a XmlTree XmlTree
mkAbsRefs base =
processTopDown
(editRef "a" "href" -- (2)
>>>
@jmn
jmn / hs
Created April 12, 2018 14:46
Yesod.Lucid.hs
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- | Lucid support for Yesod.
--
-- Example Handler for a route, using Lucid to generate html,
-- including a rendered url:
--
@jmn
jmn / hs
Created March 7, 2018 15:49
Haskell CmdArgs optional positional arguments
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveDataTypeable #-}
module Main where
import Lib
import System.Environment (getArgs)
import Database.SQLite.Simple
import System.Console.CmdArgs
import Data.List
@jmn
jmn / Main.elm
Created October 3, 2017 12:16 — forked from anonymous/Main.elm
Untitled
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Http
import Json.Decode as Decode
main : Program Never Model Msg
main =
Html.program
@jmn
jmn / Button.elm
Created October 2, 2017 07:29
Increment Button click example
module Main exposing (..)
import Html exposing (..)
import Html.Events exposing (..)
type alias Model = Int
model : Model
model = 0
@jmn
jmn / tweet.elm
Created October 2, 2017 07:26
Elm 0.18 Add to list
module Main exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
type alias Model =
{ tweets : List String
, new_tweet : String
}
@jmn
jmn / django_pagination_bootstrap4
Created August 28, 2017 00:55
Django pagination controls for Bootstrap 4
{% if is_paginated %}
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-left">
{% if page_obj.has_previous %}
<li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">&laquo;</a></li>
{% else %}
<li class="page-item disabled"><a class="page-link" href="#"><span>&laquo;</span></a></li>
{% endif %}
{% for i in paginator.page_range %}
{% if page_obj.number == i %}
@jmn
jmn / crapbuster-irssi
Created July 12, 2017 16:07
irssi - remove superfluous join/leave/mode and other information with /crapbuster
https://codepoets.co.uk/2012/irssi-crapbuster-cleaning-up-the-irc-window/
install crapbuster.pl in ~/.irssi/scripts
configure it with:
/load crapbuster.pl
/set crapbuster_levels JOINS PARTS QUITS NICKS CLIENTCRAP CRAP MODE TOPICS KICKS
then run /crapbuster in the window you want to clean up.
export PATH="${PATH}:$HOME/bin:$HOME/.local/bin:$HOME/go/bin"
# on t420s
rmmod iwldvm
rmmod iwlwifi