Skip to content

Instantly share code, notes, and snippets.

@dalizard
dalizard / 00-ADVENT-OF-CODE-2022-RUBY.md
Created February 21, 2024 13:07 — forked from skanev/00-ADVENT-OF-CODE-2022-RUBY.md
Advent of Code 2022 in Ruby (sort of)

Advent of Code 2022 solutions in Perl Ruby

Just for kicks, I'm trying to solve them with semi-golfed Ruby. That is:

  • As short as possible, but
  • Have some whitespace to make them somewhat readable
  • Avoid single-letter identifiers to keep them somewhat readable
  • Don't make them too short when they are short enough

Each solution parses the input file and outputs the answer.

@dalizard
dalizard / http_debug.rb
Created February 15, 2024 12:23 — forked from dathanb/http_debug.rb
Print Raw HTTP Request and Response Payload in Ruby
module Net
class HTTP
alias_method(:orig_request, :request) unless method_defined?(:orig_request)
def request(req, body = nil, &block)
puts '===== REQUEST ====='
puts "Request: #{req.method} http://#{@address}:#{@port}#{req.path}"
puts 'Request headers: '
req.each_header do |key, value|
puts "\t#{key}: #{value}"
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.049 000.049: --- NVIM STARTING ---
000.929 000.880: locale set
001.421 000.492: inits 1
001.441 000.020: window checked
001.623 000.182: parsing arguments
001.884 000.261: expanding arguments
-module(frequency_tests).
-include_lib("eunit/include/eunit.hrl").
-define(setup(F), {setup, fun start/0, fun stop/1, F}).
%%%
%%% TESTS DESCRIPTIONS
%%%
boot_up_test_() ->
{"Can be started with a registered name",
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([init/0]).
@dalizard
dalizard / rules for good testing.md
Created November 18, 2016 09:19 — forked from Integralist/rules for good testing.md
Sandi Metz advice for writing tests

Rules for good testing

Look at the following image...

...it shows an object being tested.

You can't see inside the object. All you can do is send it messages. This is an important point to make because we should be "testing the interface, and NOT the implementation" - doing so will allow us to change the implementation without causing our tests to break.

diff -urN mutt-1.6.1/buffy.c mutt-1.6.1-sidebar/buffy.c
--- mutt-1.6.1/buffy.c 2016-05-02 03:02:12.397171385 +0100
+++ mutt-1.6.1-sidebar/buffy.c 2016-05-02 03:02:15.009212943 +0100
@@ -27,6 +27,10 @@
#include "mutt_curses.h"
+#ifdef USE_SIDEBAR
+#include "sidebar.h"
+#endif
[1] pry(main)> module A
[1] pry(main)* module B; end
[1] pry(main)* end
=> nil
[2] pry(main)> A::B.class_eval { Module.nesting }
=> []
[3] pry(main)> A::B.class_eval('Module.nesting')
=> [A::B]
[4] pry(main)>
1/9/15 4:33:40.420 PM 2BUA8C4S2C.com.agilebits.onepassword-osx-helper[444]: This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release.
Stack:(
0 CoreFoundation 0x00007fff93ba464c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff92ba66de objc_exception_throw + 43
2 CoreFoundation 0x00007fff93ba44fd +[NSException raise:format:] + 205
3 Foundation 0x00007fff8cd00be0 _AssertAutolayoutOnMainThreadOnly + 83
4 Foundation 0x00007fff8cadf432 -[NSISEngine withBehaviors:performModifications:] + 31
5 AppKit 0x00007fff8fd007ea -[NSView(NSConstraintBasedLayout) _withAutomaticEngineOptimizationDisabled:] + 70
6 AppKit 0x00007fff8fd88138 __52-[NSView(NSConstraintBasedLayout) _setLayoutEngine:]_block_invoke
Everything below was the setup while I was on Namecheap. I registered an account with DNSSimple, and I don't have any problems there.
=============================================================================================================================
I am using 3 domains with you - forebits.com, teodosita.com, and teodesita.com. For the last 2, things do not work as expected. They are using your DNS servers. Both of the last 2 domains only have CNAME records, which are used for Heroku hosted stuff. It's been more than a few days since the update. Currently I get the following:
~ $ dig -t ns teodesita.com
; <<>> DiG 9.8.3-P1 <<>> -t ns teodesita.com
;; global options: +cmd