Skip to content

Instantly share code, notes, and snippets.

View margnus1's full-sized avatar

Magnus Lång margnus1

  • Uppsala, Sweden
View GitHub Profile
@margnus1
margnus1 / GW2DayNight.h
Last active August 27, 2020 20:13
A ReShade macro allowing smooth variation of presets based on Guild Wars 2 in-game time.
/*
* The GW2DayNight(,) macro
*
* The following defines a macro (think function) that allows parameters of a
* reshade preset to fade smoothly with no stutter or sudden changes between one
* value at daytime (in the Guild Wars 2 game world), and another at nighttime.
*
* The macro is used as follows: Instead of a plain number in your preset, say
* '1.02', you put 'GW2DayNight(1.02,1.06)'. Now, that number will be 1.02 at
* daytime, 1.06 at nighttime, and something inbetween (changing every second)
@margnus1
margnus1 / map_adt.erl
Created April 19, 2016 13:10
Maps and opaque types
-module(map_adt).
-compile(export_all).
-export_type([t/0, t/1, m/0, s/1, sm/1]).
-opaque t() :: #{atom() => integer()}.
-opaque t(A) :: #{A => integer()}.

Current Syntax

Existing map specification syntax, as was introduced in 17.0, allows the following different syntaxes:

  • map() or #{}: the type of any map (of any size).

  • #{a => integer(), b => list()}

A map that may only contain keys a and b. If it contains a key a, then it must be mapped to an integer value. Analogously for b.

@margnus1
margnus1 / SubtleDaysImmersiveNights.h
Last active August 24, 2016 20:07
A ReShade preset for Guild Wars 2 utilising the "date" uniform in ReShade to adapt to the time of day in-game.
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ReShade effect file
// visit facebook.com/MartyMcModding for news/updates
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// MasterEffect ReBorn 1.1.287 public beta by Marty McFly
// Continuation of MasterEffect 1.6.1
// Copyright © 2008-2015 Marty McFly
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*==============================================================================*\
@margnus1
margnus1 / Microsoft.PowerShell_profile.ps1
Last active August 29, 2015 14:08
My PowerShell profile
Write-Host -NoNewline "Loading Posh-Git..."
[Console]::CursorLeft = 0
Import-Module posh-git
$Global:GitPromptSettings.BeforeText = "["
$Global:GitPromptSettings.AfterText = "] "
$Global:GitPromptSettings.UntrackedText = ""
$Global:GitPromptSettings.UntrackedForegroundColor = [ConsoleColor]::Red
$Global:GitPromptSettings.WorkingForegroundColor = [ConsoleColor]::Red
$Global:GitPromptSettings.ShowStatusWhenZero = false
@margnus1
margnus1 / multiple-cursors-config.el
Last active August 29, 2015 14:03
My multiple-cursors init file. Main feature is the M-drag for interactive rectangle selection.
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
;; CUA mode might make the first C-S-c into a C-c
(global-set-key (kbd "C-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-symbol-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-symbol-like-this)
(global-set-key (kbd "C-M->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-M-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-set-key (kbd "M-S-<down>") 'mc/mark-next-lines)
@margnus1
margnus1 / .bashrc
Created February 4, 2014 13:26
Useful bashrc lines for Uppsala University computer systems.
#
# Other direct PATH settings
#
if [[ "$MAGNUS_PATH_ADDED" != "yes" ]]; then
export MAGNUS_PATH_ADDED=yes
export PATH="${HOME}/bin:${PATH}:/usr/hacks/bin:/usr/hacks/games"
export MANPATH="${MANPATH}:/usr/hacks/man"
fi
#
@margnus1
margnus1 / quickCheck.hs
Last active December 31, 2015 22:59
GHC port of QuickCheck script
--
-- This file defines a command
-- quickCheck <options> <files>
-- which invokes quickCheck on all properties defined in the files given as
-- arguments, by generating an input script for ghci and then piping it in.
--
import Data.List
import System.Environment (getArgs)
import System.Process
@margnus1
margnus1 / gist:7580741
Created November 21, 2013 12:26
Emacs solaris DELETE!=BACKSPACE init code
(normal-erase-is-backspace-mode 0)
;; (define-key key-translation-map [?\C-h] [?\C-?])
(global-set-key [(deletechar)] 'backward-delete-char)
(global-set-key [(delete)] 'delete-char)
@margnus1
margnus1 / .emacs.el
Last active December 27, 2015 05:09
My ever-growing emacs init file
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-PDF-mode t)
'(adaptive-wrap-extra-indent 1)
'(c-basic-offset 4)
'(column-number-mode t)
'(cua-enable-cua-keys nil)