Skip to content

Instantly share code, notes, and snippets.

View ggdio's full-sized avatar
:octocat:
Learning something new

Guilherme Dio ggdio

:octocat:
Learning something new
View GitHub Profile
@ggdio
ggdio / CLAUDE.md
Created May 2, 2026 23:56
Code Model Instructions and Agents

Claude Operating Guidelines & Guardrails

These are the standing rules for how you work with me. Follow them by default in every session unless I explicitly override one.

1. Plan Before You Act

  • Plan-first for non-trivial work. For anything beyond a one-line fix (multi-file changes, new features, refactors, anything ambiguous), produce a short bulleted plan first and wait for my explicit "GO" / "proceed" / "yes" before writing or editing files. Trivial fixes (typo, missing import, single-line bug) can skip the gate — just include them inline.
  • Use the TodoList. For any task with three or more steps, render the plan as a TodoList so I can watch progress and you can stay on track.
  • Surface assumptions early. State the 1–3 assumptions or edge cases your plan depends on, in one line each. Don't bury them.
@ggdio
ggdio / ConcurrentUUIDGenerator.java
Created July 30, 2019 01:27
A concurrent random UUID generator
public class ConcurrentUUIDGenerator {
public static UUID randomUUID() {
final Random rnd = ThreadLocalRandom.current();
long mostSig = rnd.nextLong();
long leastSig = rnd.nextLong();
// Identify this as a version 4 UUID, that is one based on a random value.
mostSig &= 0xffffffffffff0fffL;
mostSig |= 0x0000000000004000L;
@pavlov99
pavlov99 / haversine.scala
Created December 19, 2016 07:52
Spherical distance calcualtion based on latitude and longitude with Apache Spark
// Based on following links:
// http://andrew.hedges.name/experiments/haversine/
// http://www.movable-type.co.uk/scripts/latlong.html
df
.withColumn("a", pow(sin(toRadians($"destination_latitude" - $"origin_latitude") / 2), 2) + cos(toRadians($"origin_latitude")) * cos(toRadians($"destination_latitude")) * pow(sin(toRadians($"destination_longitude" - $"origin_longitude") / 2), 2))
.withColumn("distance", atan2(sqrt($"a"), sqrt(-$"a" + 1)) * 2 * 6371)
>>>
+--------------+-------------------+-------------+----------------+---------------+----------------+--------------------+---------------------+--------------------+------------------+
|origin_airport|destination_airport| origin_city|destination_city|origin_latitude|origin_longitude|destination_latitude|destination_longitude| a| distance|