Skip to content

Instantly share code, notes, and snippets.

@fnky
fnky / ANSI.md
Last active April 4, 2025 11:17
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27

We first talked about selectorless at ng-conf 2024.

Originally, Angular was designed to enhance HTML elements with components and directives. That was deeply embedded in AngularJS because there was a global directive registry. Each directive has a selector that could match any element of the page as long as it satisfies the directive's selector. This means that the same HTML can behave very differently depending on the directives that match its elements.

In Angular, we had a hierarchical registry via NgModules. In each NgModule, you can declare components and directives, which can dynamically match elements in the templates of components that belong to the transitive closure of these NgModules. This way, if you provide the same component in the context of a different trasitive closure, the elements of its template can match different components and directives and have a completely different behavior.

Throughout the years, we saw that Ng

@kaichao
kaichao / log-http-headers.md
Last active April 4, 2025 11:14
nginx: Log complete request/response with all headers

1. switch nginx image to openresty/openresty

2. add the following to server/location (/etc/nginx/conf.d/default.conf)

   set $req_header "";
   set $resp_header "";
   header_filter_by_lua_block{ 
      local h = ngx.req.get_headers();
      for k, v in pairs(h) do
         ngx.var.req_header = ngx.var.req_header .. k.."="..v.." ";
@vivekkr12
vivekkr12 / BouncyCastleCertificateGenerator.java
Last active April 4, 2025 11:14
Generate root X509Certificate, Sign a Certificate from the root certificate by generating a CSR (Certificate Signing Request) and save the certificates to a keystore using BouncyCastle 1.5x
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.asn1.x509.KeyUsage;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cert.X509v3CertificateBuilder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
@chrisaldrich
chrisaldrich / Hypothesidian.js
Last active April 4, 2025 11:13 — forked from TfTHacker/Hypothesidian.js
Hypothes.is - retrieve your annotations into Obsidian (for templater plugin)
<%*
/*
# Hypothes.idian a templater script for retrieving annotations from Hypothes.is
Dev: RoamHacker https://twitter.com/roamhacker
# Prerequisites:
+ Templater plugin by https://github.com/SilentVoid13/Templater
+ Free Hypothes.is developer token from: https://hypothes.is/account/developer
+ This script will prompt you for his token and save it to a file called "hypothesis config.md"
+ This file store your configuration and can be located any where in your vault.
@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
- After making changes, ALWAYS make sure to start up a new server so I can test it.
- Always look for existing code to iterate on instead of creating new code.
- Do not drastically change the patterns before trying to iterate on existing patterns.
- Always kill all existing related servers that may have been created in previous testing before trying to start a new server.
- Always prefer simple solutions
- Avoid duplication of code whenever possible, which means checking for other areas of the codebase that might already have similar code and functionality
- Write code that takes into account the different environments: dev, test, and prod
- You are careful to only make changes that are requested or you are confident are well understood and related to the change being requested
- When fixing an issue or bug, do not introduce a new pattern or technology without first exhausting all options for the existing implementation. And if you finally do this, make sure to remove the old implementation afterwards so we d
@ruvnet
ruvnet / .roomodes.json
Created March 30, 2025 15:12
This guide introduces Roo Code and the innovative Boomerang task concept, now integrated into SPARC Orchestration. By following the SPARC methodology (Specification, Pseudocode, Architecture, Refinement, Completion) and leveraging advanced reasoning models such as o3, Sonnet 3.7 Thinking, and DeepSeek, you can efficiently break down complex proj…
{
"customModes": [
{
"slug": "sparc",
"name": "⚡️ SPARC Orchestrator",
"roleDefinition": "You are SPARC, the orchestrator of complex workflows. You break down large objectives into delegated subtasks aligned to the SPARC methodology. You ensure secure, modular, testable, and maintainable delivery using the appropriate specialist modes.",
"customInstructions": "Follow SPARC:\n\n1. Specification: Clarify objectives and scope. Never allow hard-coded env vars.\n2. Pseudocode: Request high-level logic with TDD anchors.\n3. Architecture: Ensure extensible system diagrams and service boundaries.\n4. Refinement: Use TDD, debugging, security, and optimization flows.\n5. Completion: Integrate, document, and monitor for continuous improvement.\n\nUse `new_task` to assign:\n- spec-pseudocode\n- architect\n- code\n- tdd\n- debug\n- security-review\n- docs-writer\n- integration\n- post-deployment-monitoring-mode\n- refinement-optimization-mode\n\nValidate:\n✅ Files < 500 lines\n✅ No hard-coded