Skip to content

Instantly share code, notes, and snippets.

View perjo927's full-sized avatar
🧑‍💻

Per Jonsson perjo927

🧑‍💻
  • DevCode
  • Stockholm, Sweden
View GitHub Profile
@fatcerberus
fatcerberus / monads4all.md
Last active February 24, 2024 07:58
Monads for the Rest of Us

Monads for the Rest of Us

by Bruce Pascoe - 1 May, 2019

"A monad is just a monoid in the category of endofunctors. What's the problem?" ~James Iry[^1]

The problem... is that there are several problems.

It's been said that monads bear a dreadful curse. Once you finally understand what they are, you begin to see them everywhere--but somehow become completely incapable of explaining them to anyone else. Many tutorial writers have tried to break the Great Curse--the Web is lousy with bold attempts and half successes that attest to this--and just as many have failed. Well, I'm here to address the elephant in the room[^2] and tell you that I intend to break the Great Curse once and for all.

There are basically two ways a monad tutorial tends to go. One is a paragraph or two of minimal descriptions of one or two common monads (Haskell's Maybe in particular is very popular), followed by a lot of intimidating Haskell syntax trying to explain--precisely--how it all fits together. This is well

@perjo927
perjo927 / gitbot.ps1
Last active July 29, 2018 09:21
A git bot for Windows.
<#
Gitbot
Makes Your Git Stats Great
#>
param([string]$path="C:\")
function GenerateName {
$filepath = Resolve-Path "words.txt"
$raw = Get-Content -Path $filepath
@perjo927
perjo927 / HoverSupported.css
Last active November 10, 2022 16:17
CSS: Support hover only on non-touch devices using media query
/*
* Compiled CSS:
*/
a {
color: green;
}
@media not all and (pointer: coarse) {
a:hover {
color: blue;
}
@perjo927
perjo927 / CssUtils.ts
Last active April 29, 2018 14:13
Media query hacks for weird browsers (React+Styled Components)
// cssUtils.ts
import { css } from "styled-components";
export const IEOnly: Function = style => {
return css`
@media all and (-ms-high-contrast:none) {
*::-ms-backdrop, & {
${style};
}
`;
@perjo927
perjo927 / imperialmarch.ino
Created April 8, 2018 17:24
Imperial march from Star Wars for Zumo Robot Buzzer
#include <Wire.h>
#include <Zumo32U4.h>
Zumo32U4Buzzer buzzer;
const char march[] PROGMEM =
"! O2 T100 MS"
"a8. r16 a8. r16 a8. r16 f8 r16 >c16"
"ML"
"a8. r16 f8 r16" "MS" ">c16 a. r8"
@Kidde82
Kidde82 / webstorm.bat
Last active March 18, 2016 08:44
Add context menu to Windows 7 to open file/folder in WebStorm
REM This is just rewritten from https://gist.github.com/amnuts/162f6b03c5f94692fd6c to fit Webstorm
@echo off
REM Make sure to set WebStormPath to match the location of your Webstorm copy.
SET WebStormPath=C:\Program Files (x86)\JetBrains\WebStorm 2016.1\bin\WebStorm64.exe
echo Adding file entries
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in WebStorm" /t REG_SZ /v "" /d "Open in WebStorm" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open in WebStorm" /t REG_EXPAND_SZ /v "Icon" /d "%WebStormPath%,0" /f
@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
@indyfromoz
indyfromoz / aspnet-mvc.gitignore
Created November 19, 2012 06:44
.Gitignore for ASP.NET MVC
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
@clarle
clarle / js-frameworks.md
Created August 19, 2012 16:54
Mojito/Derby/Meteor comparison (Public WIP)

Next-generation JavaScript frameworks

Web application frameworks have been developing fast in the past few years, and as the technologies that they're built on top of get more advanced, each of these frameworks is able to provide newer features to help developers build more complex applications. This year, we've seen the release of a new class of application frameworks that takes advantage of JavaScript's ability to be both on the client and the server. What this allows these frameworks to do is provide both a new level of abstraction by sharing code between client and server, as well as embrace the benefits of both client-side rendering and server-side rendering.

For the end user, they get smooth, desktop-like responsiveness from client-side rendering, while still being able to maintain the SEO and accessbility benefits of server-side rendering. For developers, that means writing less boilerplate code, and being able to focus more on writing the application logic.

Today, there are three main framew