Skip to content

Instantly share code, notes, and snippets.

View christos's full-sized avatar

Christos Zisopoulos christos

View GitHub Profile
@pcreux
pcreux / authorizations.rb
Last active September 8, 2025 12:50
All introspection of authorization rules to understand why users can/cannot perform an action. That helps with debugging and offers better error messages.
# I would really like to introspect complex authorization rules to understand why users can/cannot perform an action.
# That helps with debugging and offers better error messages.
# Sample:
#
# ```ruby
# auth = Authorize.new(CanUpdate, owner, message_1)
# pp auth.permitted? # => false
# pp auth.explain
# # => "(❌ IsAdmin) or (✅ IsPublisher and ❌ IsOwner)"

Beast Mode

Beast Mode is a custom chat mode for VS Code agent that adds an opinionated workflow to the agent, including use of a todo list, extensive internet research capabilities, planning, tool usage instructions and more. Designed to be used with 4.1, although it will work with any model.

Below you will find the Beast Mode prompt in various versions - starting with the most recent - 3.1

Installation Instructions

  • Go to the "agent" dropdown in VS Code chat sidebar and select "Configure Modes".
  • Select "Create new custom chat mode file"

Namespaces 101

Introduction

Ruby has recently merged namespaces as an experimental feature that is disabled by default, as of this writing.

This is a non-trivial development driven by @matz himself, and mainly implemented by @tagomoris, who just became a Ruby committer (🎉).

The feature has been cooking for a long time, with a first ticket opened a couple of years ago (#19744) and a revised one opened just last week (#21311).

@kddnewton
kddnewton / json.rb
Last active December 18, 2024 17:34
JSON parser with pattern matching
require "json"
struct = { "a" => 1, "b" => 2, "c" => [1, 2, 3], "d" => [{ "e" => 3 }, nil, false, true, [], {}] }
source = JSON.dump(struct)
tokens = []
index = 0
until source.empty?
tokens <<
@karlseguin
karlseguin / waf.conf
Created October 22, 2021 13:02
basic nginx waf
# WAFs are a waste of time. False positives negatively impact actual users.
# And for what? Protection against vulnerabilities that, if you still have
# in this day in age, you're in more trouble than you think.
# Still, to keep my logs clean, I like to run something like the follwoing:
location ~ \.php$ { access_log off; return 444; }
location ~ \.asp$ { access_log off; return 444; }
location ~ \.aspx$ { access_log off; return 444; }
location ~ /Admincenter/ { access_log off; return 444; }
location /console/ { access_log off; return 444; }
@Envek
Envek / login_helpers.rb
Created October 11, 2021 06:42
Signing-in user for integration tests via cookie-only session with Rails, Devise, Capybara, and Cuprite
# spec/system/support/login_helpers.rb
# See this blog post for setup guide: https://evilmartians.com/chronicles/system-of-a-test-setting-up-end-to-end-rails-testing
module LoginHelpers
def login_as(user)
# Craft session cookie to make request authenticated (to pass even routing constraints)
# Compilation of these:
# - https://dev.to/nejremeslnici/migrating-selenium-system-tests-to-cuprite-42ah#faster-signin-in-tests
# - https://turriate.com/articles/2011/feb/how-to-generate-signed-rails-session-cookie
# - https://github.com/rails/rails/blob/43e29f0f5d54294ed61c31ddecdf76c2e1a474f7/actionpack/test/dispatch/cookies_test.rb#L350
@dhh
dhh / pagination_controller.js
Last active August 26, 2025 17:15
HEY's Stimulus Pagination Controller
/*
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
</section>

Honest is looking for a Rails contractor (3-month, 40h/week commitment)

Honest is building the “customer service agent’s best friend”: contextual, real-time assistance and shortcuts for digital customer service teams.

We’re looking for an experienced Rails contractor to come help us improve our Rails app, initially with a 3-month, 40h/week commitment. We’ll appreciate an inclination for “foundation” work (enhancing performance, increasing test coverage, improving our CI/CD pipeline…) although there’s plenty to do in user-facing features too.

Honest is built as a pretty standard Rails 6 “beautiful monolith” hosted in Github and running on Heroku, powered by PostgreSQL and Redis. You’ll have the chance to acquire experience on newer stuff like Hotwire too.

You’ll be part of a small, fully-remote team coordinating mainly via Discord and Jira. You’ll work along with colleagues with plenty of experience in the different aspects of building digital products. We keep a healthy, respectful,

Senior Backend Developer at Devengo

Devengo is a startup focused on a simple but ambitious mission: make finance a fairer place. Founded by well-known fintech players Fernando Cabello-Astolfi and Alberto Molpeceres our first product is an innovative social benefit that allows workers to collect their earned wages in real-time. Your money, when you need it.

The problem

Economists identify¹ three main challenges any person and household must face to reach a sustainable level of financial wellness: having sufficient and stable income, maintaining an economic-financial balance that limits problems of overindebtedness and avoiding severe poverty.

The last two challenges are the most pressing ones as they have an immediate effect on the material living conditions of the population and they compound over time sinking the households' economies further and further.

In Spain al

@bomberstudios
bomberstudios / DNI-Electronico-en-Mac.md
Last active June 25, 2025 13:20
Instrucciones para instalar el DNI Electrónico en un Mac en 2021

DNI Electrónico en Mac

El lector que voy a usar es el SVEON SCT011M, que es el mas barato que encontré en tienda física y tiene un precio razonable en Amazon: https://www.amazon.es/dp/B072LTLZW3/

Estos son los pasos que he seguido:

  1. Descargar Firefox (he probado con la ultima version, 86.0.1)
  2. Enchufar el lector, sin el DNI (no se si es importante hacerlo aquí o se puede hacer luego, pero mejor no nos arriesgamos, yo lo hice aquí y me ha funcionado)
  3. Descargar libpkcs11 para Intel o para Apple Silicon. Estos enlaces estan en la web oficial del DNI Electrónico por si quieres ver si hay alguna versión más reciente.
  4. Instalar el paquete (los ficheros se copiaran en /Library/Libpkcs11-dnie, y en esa misma carpeta se instalara una app para desinstalarlo en e