Skip to content

Instantly share code, notes, and snippets.

@stiff
stiff / type-level-routes.cpp
Last active September 26, 2021 15:25
Type level routes in C++20
// loosely based on https://servant.dev
// /usr/local/Cellar/gcc/10.2.0/bin/g++-10 -std=c++20 type-level-routes.cpp && ./a.out
#include <iostream>
#include <string>
// FixedString from https://www.reddit.com/r/cpp/comments/bhxx49/c20_string_literals_as_nontype_template/
template<unsigned N>
struct FixedString {
@stiff
stiff / css-layout-hack.js
Last active November 24, 2020 03:26 — forked from olee/css-layout-hack.js
CSS/HTML layout debugger
// create a bookmark and use this code as the URL, you can now toggle the css on/off
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3
javascript: (function() {
var styleEl = document.getElementById('css-layout-hack');
if (styleEl) {
styleEl.remove();
return;
}
styleEl = document.createElement('style');
styleEl.id = 'css-layout-hack';
@stiff
stiff / ruby-419-issue-12753-test.rb
Created February 10, 2015 20:46
ruby-419-issue-12753-test
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.1.9'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
@stiff
stiff / rails-420-issue-18862-regression.rb
Created February 9, 2015 18:43
Rails 4 issue 18862 test
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.2.0'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
@stiff
stiff / pathfinder.rb
Created December 6, 2011 15:23 — forked from dmeremyanin/pathfinder.rb
pathfinder
input = []
input << [500]
input << [100, 200]
input << [300, 400, 500]
input << [200, 200, 500, 900]
input << [900, 100, 200, 100, 101]
input << [100, 900, 100, 100, 100, 700]
# n = input.size
@stiff
stiff / simple.rb
Created August 29, 2008 12:54 — forked from yaroslav/simple.rb
lambda replaced with an instance of a new class
module Pluralizations
# Uses English pluralization rules -- it will pick the first translation if count is not equal to 1
# and the second translation if it is equal to 1.
class OneOther
def get_symbol(n)
n == 1 ? :one : :other
end
end
end