Skip to content

Instantly share code, notes, and snippets.

Avatar
👅

Wout wout

👅
View GitHub Profile
@wout
wout / haskellmind.hs
Last active Jun 3, 2021
Haskellmind: A Haskell CLI implementation of Mastermind
View haskellmind.hs
import System.Random
import Data.Char (isDigit)
makeCode :: IO [Char]
makeCode = do
gen <- newStdGen
return $ take 4 (randomRs ('0','9') gen)
breakCode :: String -> Int -> IO ()
breakCode code turns = do
@wout
wout / create_spec.rb
Created Nov 21, 2020 — forked from niinyarko/create_spec.rb
Request Spec Example for Devise Token Auth Gem with Rails 5.1
View create_spec.rb
# Example Request
# My Devise model is named Merchant
# Key lines to note are 16, 21, 27, 28, 29
require 'rails_helper'
RSpec.describe 'POST /api/v2/customer_groups', type: :request do
let(:merchant) { FactoryGirl.create(:merchant) }
let(:user) { FactoryGirl.create(:user) }
let(:customer) { merchant.customers.create(user_id: user.id)}
let(:params) {{
@wout
wout / rails-docker-compose.md
Created Oct 6, 2020 — forked from vuongpd95/rails-docker-compose.md
docker-compose for Rails application on Local
View rails-docker-compose.md
# docker/webapp/Dockerfile
FROM ruby:2.6.6

SHELL ["/bin/bash", "-c"]
RUN apt-get update -qq && apt-get install -y postgresql-client memcached tzdata nano
# Install node 12, yarn
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
@wout
wout / sitemap.xml
Last active Oct 1, 2020
TiLiShop Bridgetown Sitemap Example
View sitemap.xml
---
layout: false
permalink: "/sitemap.xml"
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://tilishop.com/</loc>
</url>
<url>
@wout
wout / README.md
Created Sep 26, 2020 — forked from julienma/README.md
How to install Discourse 2.4+ on Dokku (2019)
View README.md
View payconiq-jwk-to-pem.rb
require 'jose'
require 'faraday'
require 'fast_jsonparser'
endpoint = 'https://ext.payconiq.com/certificates'
kid = 'es.signature.ext.payconiq.com'
response = Faraday.get(endpoint, {}, { 'Accept' => 'application/json' })
keys = FastJsonparser.parse(response.body).dig(:keys)
View Ruby OpenSSL: Verify Signature Example.rb
require 'openssl'
def verify_sign(key, signature, data)
# Verifies with a public key that the data was signed with their private key
pubkey = key.public_key
if pubkey.verify(OpenSSL::Digest::SHA256.new, signature, data)
puts 'the signature is valid'
else
puts 'the signature is invalid'
end
end
View Ruby OpenSSL: Verify Signature Example.rb
require 'openssl'
def verify_sign(key, signature, data)
# Verifies with a public key that the data was signed with their private key
pubkey = key.public_key
if pubkey.verify(OpenSSL::Digest::SHA256.new, signature, data)
puts 'the signature is valid'
else
puts 'the signature is invalid'
end
end
@wout
wout / prefetch.js
Created Jul 2, 2020 — forked from hopsoft/prefetch.js
Turbolinks Prefetching
View prefetch.js
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 = () => {
View elementary OS AppCenter debug
** (process:2152): DEBUG: 08:43:35.748: ScreenshotCache.vala:18: screenshot path is at /home/wout/.cache/io.elementary.appcenter/screenshots
(io.elementary.appcenter:2152): Gtk-DEBUG: 08:43:35.790: Connecting to session manager
** (io.elementary.appcenter:2152): DEBUG: 08:43:35.794: Client.vala:114: update cache called false
** (io.elementary.appcenter:2152): DEBUG: 08:43:35.794: Client.vala:161: Too soon to refresh and not forced
(io.elementary.appcenter:2152): PackageKit-DEBUG: 08:43:35.795: notify::connected
(io.elementary.appcenter:2152): PackageKit-DEBUG: 08:43:35.821: notify::connected
** (io.elementary.appcenter:2152): DEBUG: 08:43:35.822: Opening cache file: /home/wout/.cache/appstream-cache-YJJIK0.mdb
** (io.elementary.appcenter:2152): DEBUG: 08:43:35.823: Added /usr/share/app-info/yaml to YAML metadata search path.
** (io.elementary.appcenter:2152): DEBUG: 08:43:35.823: Added /var/lib/app-info/yaml to YAML metadata search path.