Skip to content

Instantly share code, notes, and snippets.

@awendt
awendt / server-with-error.mjs
Created December 1, 2023 08:57
HTTP server returning an error code specified by the client
import * as http from "node:http";
const PORT = 8000;
// source: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Node_server_without_framework
http
.createServer(async (req, res) => {
const statusCode = parseInt(req.url.slice(1));
res.writeHead(statusCode, { "Content-Type": "application/json" });
res.end("{}");
@awendt
awendt / README.md
Last active August 28, 2019 12:41
Data conversion scripts

Data conversion scripts

This is a collection of scripts to convert data from one format to another.

CSV to JSON

What? Turns CSV into JSON Why? JSON is nicer to navigate and query using jq or fx How?

@awendt
awendt / idea.md
Last active March 7, 2018 16:31
What configuring a project should feel like

This document is a DRAFT — please leave comments.

A beginner-friendly way of interactively creating config files

Whenever you're trying some new project, you'll likely have to configure something.

This mostly uses one of the following approaches:

  1. Copy the sample config file the project provides, understand the properties and change them
  2. RTFM to find out how to create the config file out of thin air
gem 'devise_saml_authenticatable'
generate 'devise:install'
initializer 'devise.rb', <<-CODE
Devise.setup do |config|
# ==> Configuration for :saml_authenticatable
# You can support multiple IdPs by setting this value to a class that implements a #settings method which takes
# an IdP entity id as an argument and returns a hash of idp settings for the corresponding IdP.
@awendt
awendt / agh16-english.md
Created August 26, 2016 06:45
Links to English election programs for Berlin's #agh16

I asked this on Twitter

Gibt es eigentlich englische Parteiprogramme für die #agh16? Frage für Menschen, die wegen EU-Herkunft Wahlunterlagen erhalten haben.

— André “Andr�” Wendt (@awendt) August 25, 2016
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

Here are the links I received (in the order I received them):

@awendt
awendt / after_enter.rb
Created January 14, 2015 16:06
AASM test case
gem 'activerecord', '3.2.19'
require 'active_record'
require 'minitest/autorun'
require 'logger'
gem 'aasm', '4.0.8'
require 'aasm'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
@awendt
awendt / flattr-tos.html
Last active August 29, 2015 14:03
Flattr TOS
<!doctype html>
<html class="no-js locale-en-gb aut11">
<head>
<meta charset="utf-8" />
<title>Terms of use - Flattr.com</title>
<link href="/favicon.ico" rel="shortcut icon" />
<link rel="apple-touch-icon" href="/_img/icons/ios-icon.png" />
@awendt
awendt / what_you_have.rb
Last active August 29, 2015 13:57
Answer for SO question 22569738
gem 'activerecord', '4.0.2'
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.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')