Skip to content

Instantly share code, notes, and snippets.

View wout's full-sized avatar
🕳️

Wout wout

🕳️
View GitHub Profile
@wout
wout / gist:5188265
Last active July 29, 2021 18:04
Zoom in and out with svg viewbox for http://svgjs.dev
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>svg.js</title>
<style type="text/css" media="screen">
#buttons {
position: absolute;
right: 0;
@wout
wout / haskellmind.hs
Last active June 3, 2021 17:07
Haskellmind: A Haskell CLI implementation of Mastermind
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 / gist:6352742
Created August 27, 2013 12:13
Textflow plugin for svg.js
// svg.textflow.js 0.8 - Copyright (c) 2013 Wout Fierens - Licensed under the MIT license
SVG.Textflow = function() {
this.constructor.call(this, SVG.create('text'))
/* define default style */
this.styles = {
'font-size': 16
, 'font-family': 'Helvetica, Arial, sans-serif'
, 'text-anchor': 'start'
@wout
wout / create_spec.rb
Created November 21, 2020 13:30 — forked from niinyarko/create_spec.rb
Request Spec Example for Devise Token Auth Gem with Rails 5.1
# 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 October 6, 2020 07:31 — forked from vuongpd95/rails-docker-compose.md
docker-compose for Rails application on Local
# 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 October 1, 2020 08:02
TiLiShop Bridgetown Sitemap Example
---
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 September 26, 2020 13:31 — forked from julienma/README.md
How to install Discourse 2.4+ on Dokku (2019)
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)
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
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