Skip to content

Instantly share code, notes, and snippets.

View marcusandre's full-sized avatar

Marcus André marcusandre

View GitHub Profile
* {
box-sizing: border-box;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-kerning: auto;
}
html {
font-family: sans-serif;
@marcusandre
marcusandre / key.go
Created January 9, 2018 09:24
Generate a random key with crypto/rand
// Example to generate a random key with crypto/rand.
// It's useful to use it for example to prevent request forgery by comparing it
// inside requests.
package main
import (
"crypto/rand"
"fmt"
"log"
@marcusandre
marcusandre / immutable.js
Created November 13, 2017 07:48
Immutable array operations
clone = x => [...x]
push = y => x => [...x, y]
pop = x => x.slice(0, -1)
unshift = y => x => [y, ...x]
shift = x => x.slice(1)
sort = f => x => [...x].sort(f)
del = i => x => [...x.slice(0, 1), ...x.slice(i + 1)]
splice = (s, c, ...y) => x => [...x.slice(0, s), ...y, ...x.slice(s + c)]
@marcusandre
marcusandre / pseudo-blockchain.go
Last active October 12, 2017 21:44
An ordered and back-linked list in Go
package blockchain
import (
"bytes"
"crypto/sha256"
"strconv"
"time"
)
type Blockchain struct {
# Options
setopt emacs
setopt nobeep
setopt nonomatch
setopt shnullcmd
setopt extendedglob
setopt bashautolist
setopt noautomenu
setopt noalwayslastprompt

Keybase proof

I hereby claim:

  • I am marcusandre on github.
  • I am marcusandre (https://keybase.io/marcusandre) on keybase.
  • I have a public key ASCrKff2YGOK0PVAVVmuA6LQxM7sHQZR5G8giVByGEVSzgo

To claim this, I am signing this object:

@marcusandre
marcusandre / pre-commit
Created August 11, 2017 04:13
Git pre-commit to run tests and linting automatically
#!/bin/sh
branch=`git rev-parse --abbrev-ref HEAD`
if [ "$branch" = "master" ]; then
make lint && make test
fi
@marcusandre
marcusandre / raf-to-jpg.sh
Created August 5, 2017 08:12
Convert RAF files to JPG.
for i in *.RAF; do sips -s format jpeg $i --out "${i%.*}.jpg"; done
var pager = require('pager')
for (let i = 1, l = 20; i <= l; i++) {
console.log(`Selected page ${i}:`, pager(i, l))
}
@marcusandre
marcusandre / wp-custom-excerpt.php
Created April 19, 2017 12:25
Fuck you wordpress
$delim = '<!--more-->';
$content = explode($delim, $post->post_content);
$content_before = apply_filters('the_content', $content[0]);
$content_after = apply_filters('the_content', $content[1]);