Skip to content

Instantly share code, notes, and snippets.

View MiroslavCsonka's full-sized avatar

Miroslav Csonka MiroslavCsonka

View GitHub Profile
@MiroslavCsonka
MiroslavCsonka / terminal.sh
Last active March 26, 2025 17:07
Github Action with `gh signoff`
git add xyz.rb
git commit -m "A meaningful change"
# NOTE: The job has a 5-second waiting period since there's a delay between pushing and creating a new "signoff" GitHub check status.
git push && gh signoff
@MiroslavCsonka
MiroslavCsonka / Extension logs
Created January 27, 2025 23:04
Integrating Turbo into a Chrome extension
turbo:load # initial extension load
turbo:before-visit
turbo:before-fetch-request
turbo:visit # sends current URL to the server
turbo:before-fetch-response
turbo:before-cache
turbo:visit # server redirects to the appropriate url (based on the url)
turbo:load
@MiroslavCsonka
MiroslavCsonka / .env
Created October 4, 2024 23:19
ELK set-up for local Rails development
ELASTIC_PASSWORD=<your-elastic-password>
KIBANA_PASSWORD=<your-kibana-password>
@MiroslavCsonka
MiroslavCsonka / xml_snapshot_testing.rb
Last active April 8, 2021 10:36
Snapshot testing in RSpec
def expect_to_match_xml_fixture(xml, fixture_path)
expected = Nokogiri::XML(xml, &:noblanks).to_xml
fixture_path = Rails.root.join("spec/fixtures", fixture_path)
File.write(fixture_path, expected) if ENV["REPLACE_FIXTURE_SNAPSHOTS"] == "true"
actual = Nokogiri::XML(File.read(fixture_path), &:noblanks).to_xml
expect(expected).to eq(actual)
end
@MiroslavCsonka
MiroslavCsonka / links_for_youtube_playlist.js
Created June 20, 2018 17:15
Get a list of URLs from a youtube playlist (or watch later). Super handy for youtube-dl since you don't have to auth or anything
### Keybase proof
I hereby claim:
* I am miroslavcsonka on github.
* I am mcsonka (https://keybase.io/mcsonka) on keybase.
* I have a public key ASCxwlKD-VKxw1grZKSdRUCyttnCR4uZYFEUv9Zd_UmZ9go
To claim this, I am signing this object:
@MiroslavCsonka
MiroslavCsonka / main.rb
Created September 7, 2016 21:48
Generate a matrix with a diagonal pattern
[
[[0, 0], [1, 0], [2, 0], [3, 0]],
[[0, 1], [1, 1], [2, 1], [3, 1]],
[[0, 2], [1, 2], [2, 2], [3, 2]],
[[0, 3], [1, 3], [2, 3], [3, 3]],
]
$rows = 4
$columns = 4
case class With[+A, +B](a: A, b: B)
case class Pass[A](value: A) extends Result[A]
case class Fail(errors: List[String]) extends Result[Nothing]
sealed trait Result[+A] {
def and[B](that: Result[B]): Result[A With B] = (this, that) match {
case (Pass(a), Pass(b)) => Pass(With(a, b))
case (Pass(_), Fail(e)) => Fail(e)
@MiroslavCsonka
MiroslavCsonka / custom_matcher.rb
Last active November 28, 2015 23:25
json expression example
class HashBuilder
def self.build &block
hb = HashBuilder.new
hb.instance_eval(&block)
hb.hash
end
attr_reader :hash