Skip to content

Instantly share code, notes, and snippets.

View wout's full-sized avatar
🕳️

Wout wout

🕳️
View GitHub Profile
@hopsoft
hopsoft / prefetch.js
Last active December 27, 2023 02:45
Turbolinks Prefetching
const hoverTime = 400
const fetchers = {}
const doc = document.implementation.createHTMLDocument('prefetch')
function fetchPage (url, success) {
const xhr = new XMLHttpRequest()
xhr.open('GET', url)
xhr.setRequestHeader('VND.PREFETCH', 'true')
xhr.setRequestHeader('Accept', 'text/html')
xhr.onreadystatechange = () => {
@ryancat
ryancat / colorConvert.js
Created May 9, 2018 06:10
Convert color from RGB to LAB, RGB to HEX, or vice versa
/**
* Convert a hex color string to RGB array
* @param {String} hex Hex color string
*/
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? [
parseInt(result[1], 16),
parseInt(result[2], 16),
parseInt(result[3], 16)
@keathley
keathley / dry_monad_usage.md
Last active March 14, 2024 15:16
A description of how to take advantage of the dry-monad gem.

How we're using dry-monad

Imagine that we have an application where user's have a location. We want to find the weather for their current location using an external service call. We want to provide this functionality in a json api. A basic implementation might look like this.

def create
 user = User.find(params[:id])
@dfontana
dfontana / CmderZSH.md
Last active March 12, 2023 21:45
My setup guide for installing Cgywin, Mintty, Cmder, and ZSH.

What's this?

Instructions to obtain ZSH on a windows environment, without the input funny business presented by some other attempted solutions.

The final result is ZSH running on a mintty terminal, emulated by cygwin, and being handled by the popular cmder.

Why is this here?

For the benefit of myself and others. I've already followed these instructions twice. It took me hours to figure all this out, maybe someone else can save a few.

What exactly is covered?

  • Installing and setting up cmder
@kjellm
kjellm / app.rb
Last active July 26, 2021 04:46
Event Source proof of concept. Copyright 2017 Kjell-Magne Øierud. License: MIT https://opensource.org/licenses/MIT
require_relative 'base'
require_relative 'event'
require_relative 'cmd'
require_relative 'crud'
require_relative 'model'
require_relative 'read'
require 'pp'
class Application < BaseObject
@sam0x17
sam0x17 / disable middle click paste in linux.md
Last active July 30, 2023 18:17
disable middle-click paste in linux without disabling middle scroll

Disable middle-click paste in Linux

Install packages:

sudo apt-get install xbindkeys xsel xdotool

Create xbindkey configuration file:

# ~/.xbindkeysrc
@jagrosh
jagrosh / WebhookTutorial.md
Last active December 4, 2023 20:28
Simple Webhook Tutorial (Twitter -> Discord)

Simple Webhook Tutorial

In this tutorial, I will be explaining how to set up a simple webhook to relay your tweets to a Discord channel

Step 1 - Register on Zapier

  1. Go to https://zapier.com/ and create an account (if you don't already have one).

Step 2 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send Tweets
@YusukeHosonuma
YusukeHosonuma / map_filter.hs
Created May 8, 2016 13:19
Haskell - implement map and filter functions by recursion and foldr versions.
-- | recursion version
map' :: (a -> b) -> [a] -> [b]
map' _ [] = []
map' f (x:xs) = f x : map' f xs
filter' :: (a -> Bool) -> [a] -> [a]
filter' _ [] = []
filter' f (x:xs)
| f x = x : (filter' f xs)
@pboling
pboling / slim_vs_haml.md
Last active February 11, 2024 16:33
Slim vs Haml

Analysis of Slim vs. Haml Project Health

  • Static data as of April 13, 2015, some updates as of October 1, 2015
# Metric Haml Slim Winner
1 Issues Open Issues Open Issues Slim
2 Stars Stars Open Issues Slim
3 Quality Code Climate technical debt Code Climate maintainability -- Haml
4 Test Coverage ![Code Climate coverage](https://i
@jansanchez
jansanchez / gist:ce5b0ca1c5e538f4b266
Last active February 28, 2024 00:27
How to install NVIDIA video drivers in Elementary OS