Skip to content

Instantly share code, notes, and snippets.

View Soft's full-sized avatar

Samuel Laurén Soft

View GitHub Profile
@Soft
Soft / .emacs
Last active May 30, 2018 18:49
My Emacs configuration
;; -*- mode: Emacs-Lisp; lexical-binding: t; -*-
;; Samuel Laurén 💗 2014-2015
;; # TODO
;; - Support tags
(setq gc-cons-threshold 50000000)
(require 'cl-lib)
@Soft
Soft / hacker-news-new-comments.user.js
Last active August 29, 2015 14:06
Script for highlighting new comments on Hacker News
// ==UserScript==
// @name Hacker News new comments
// @match *://news.ycombinator.com/item*
// @match *://hackerne.ws/item*
// @author Samuel Laurén
// @description Script for highlighting new comments on Hacker News
// ==/UserScript==
function findComments() {
return Array.prototype.slice.call(document.querySelector("table:nth-of-type(2)").querySelectorAll("table"), 0);
function! AlignAssignments() range
let l:max = -1
for n in range(a:firstline, a:lastline)
let l:line = getline(n)
let l:pos = match(line, "=")
if pos > max
let l:max = pos
endif
endfor
@Soft
Soft / wikipedia-modern.css
Last active August 29, 2015 13:58
User style for Wikipedia
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("wikipedia.org"), domain("wikibooks.org"), domain("wiktionary.org") {
.mw-headline, .firstHeading, #mw-content-text p, #mw-content-text>ul>li, #mw-content-text>ol>li {
font-family: "EB Garamond", Crimson, Georgia, serif !important;
text-rendering: optimizelegibility !important;
font-feature-settings: "kern", "liga", "dlig", "clig", "hlig", "calt";
}
@Soft
Soft / bg-select-set.sh
Last active August 29, 2015 13:57
Script for managing multiple wallpapers
#!/usr/bin/env bash
CONFIG=$HOME/.config/nitrogen
SETS=$CONFIG/sets
function setWallpaper {
[ ! -f "$SETS/$1" ] && echo "Set \"$1\" does not exist" && return;
ln -f "$SETS/$1" "$CONFIG/bg-saved.cfg"
nitrogen --restore
}
@Soft
Soft / church.js
Created March 25, 2014 17:41
Church numerals
var addOne = function (x) { return x+1; };
var church = function(n) {
if (n === 0) {
return function(fn) {
return function(x) {
return x;
}
}
import Prelude hiding (Functor, Monad, (>>=), (>>), fmap)
import Data.Monoid (Monoid, mempty, (<>))
class Functor f where
fmap :: (a -> b) -> f a -> f b
class Functor f => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> f a -> f b
@Soft
Soft / multiplex.hs
Created February 13, 2014 19:27
Combine inputs from multiple line-oriented sources. Useful for displaying things in status bars like dzen or bar.
import Control.Monad (liftM, mapM, forever)
import Control.Monad.Loops (untilM_)
import Control.Concurrent (forkIO, threadDelay)
import Control.Concurrent.STM (atomically)
import Control.Concurrent.STM.TMVar (TMVar, newTMVar, swapTMVar, readTMVar)
import System.IO (hGetLine, hIsEOF, hFlush, Handle, stdin, stdout)
import System.Process (createProcess, shell, CreateProcess(..), StdStream(..))
import System.Environment (getArgs)
import Data.Maybe (catMaybes)
import Data.List (nub)
@Soft
Soft / feedbin-notifications.user.js
Last active January 4, 2016 19:59
Notifications for Feedbin
// ==UserScript==
// @name Feedbin unread notifications
// @match *://feedbin.me/*
// @grant none
// @author Samuel Laurén
// ==/UserScript==
var count = () => {
var unreadCount = document.querySelector("[data-behavior~=all_unread] .count");
return parseInt(unreadCount.innerHTML, 10);
// ==UserScript==
// @name TYS Booking Calendar Limit Remover
// @namespace tysbookingnolimits
// @include http://booking.tys.fi/varaus/service/timetable/*
// @grant none
// ==/UserScript==
window.maxDate = null;