Skip to content

Instantly share code, notes, and snippets.

View mogarick's full-sized avatar

Ricardo Montoya mogarick

View GitHub Profile

Add an "overnight mode" Stop hook to this repository for Claude Code. ​ Goal: when overnight mode is on, an unattended agent must never end its turn by asking a human a question. If its final message asks one, the hook blocks the stop and tells it to pick the most reasonable (based on what it knows about the project, task, and my preferences) reversible option and keep working. After two blocks in one session it lets the stop through, so a truly stuck agent can still finish. ​ Overnight mode is on only while the file ~/.agents/OVERNIGHT exists. I create it before leaving and delete it in the morning. ​ Steps:

  1. Create Tools/hooks/guard_overnight_questions.py with exactly the script below (adjust the wording of MESSAGE only if I ask).
  2. Register it in .claude/settings.json under hooks.Stop. Merge into any existing hooks; do not overwrite other entries. Use this entry: {"hooks": [{"type": "command", "command": "python3 "${CLAUDE_PROJECT_DIR}/Tools/hooks/guard_overnight_questions.py""}]}
@mogarick
mogarick / hello-properties-complex.ts
Last active July 18, 2021 03:31
typescript complex example from twitter question
//From: https://www.typescriptlang.org/play?#code/C4TwDgpgBAEhA28D2AeACgJyZDwCWEAzlBAB7AQB2AJsRhAIbVKXwhSHAZ6UDmA2gF0AfFAC8UAN4AoKFDBYc+IgC4ombBFwFC0gL5QAZFABKEAMZIM1dIq3LC-SgFcAtgCMtggDRQXHrWFpaQB6EKhgAAtofgA6eI0lHUEoHgAzLWI8YCgGYgYI5zB4CGk050pzfBYoc3oGCjhEVET7HRJyKlooeuZWdk5uPiFhAApo5rUm5BQ4hLttIhEASilZHohgZwxKKAnkfWC6xkaEZFGZOQVNRcI1fgBySgZXCAffB4ZeN59159e1ABGABMAGZvOsvhA1AAWACsADZ9MtpEA
type Hello<Properties extends readonly string[]> = {
properties: Properties
} & Record<Properties[number], number>
// the [...Properties] infers it as a tuple
function createHello<Properties extends readonly string[]>(hello: Hello<[...Properties]>) {
return hello
}
@mogarick
mogarick / regex-mongoid-json-object-to-string.md
Last active July 18, 2021 01:40
Search and replace de mongoID JSON object para serializar a solo string

Un mongoID en json tiene la forma siguiente:

{
  _id: {
     $oid: "58ae6b11fd54e89021a96610",
   }
}
@mogarick
mogarick / machine.js
Created April 21, 2021 16:04
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mogarick
mogarick / machine.js
Last active April 19, 2021 22:38
Generated by XState Viz: https://xstate.js.org/viz
const lightMachine = Machine({
// not a parallel machine
id: 'light',
initial: 'green',
states: {
green: {
on: { TIMER: 'yellow' }
},
yellow: {
on: { TIMER: 'red' }
@mogarick
mogarick / paths.js
Last active September 18, 2019 18:33
Hack for custom-react-scripts to compile specific dependencies when such dependencies are not compiled for es5
appSrc: [resolveApp('src'),resolveApp('node_modules/react-native-vector-icons')]
@mogarick
mogarick / 0_reuse_code.js
Created June 24, 2016 15:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mogarick
mogarick / queryLogLaravelEloquent.php
Last active January 18, 2017 18:36
Log de queries generadas por Laravel Eloquent
<?php
// Display all SQL executed in Eloquent
//source: http://laravel-tricks.com/tricks/display-all-sql-executed-in-eloquent
Event::listen('illuminate.query', function($query){Log::debug($query);});
@mogarick
mogarick / index.js
Last active July 4, 2016 09:54
Wrapper / Facade to expose pickadate components for using out of the box in Browserify by using a simple require('pickadate') (No need to assign to a variable)
//This code is a simple adaptation from the index.js file in CryptoJS node module
(function (root, factory, undef) {
if (typeof exports === "object") {
// CommonJS
module.exports = exports = factory(require('./picker'), require('./picker.date'), require('./picker.time'));
}
else if (typeof define === "function" && define.amd) {
// AMD
define(['./picker','./picker.date', './picker.time'], factory);
}
@mogarick
mogarick / utcTimestampsWithTimezone.js
Last active May 14, 2024 10:16
Getting UTC timestamps of iCal with Timezone using the mozilla-comm/ical.js lib
//Please note I'm also using underscore each function for the iterations
//iCal -> jsCal
var icalEvents = ICal.parse(iCalStringData);
//jsCal->Component
var comp = new Component(icalEvents[1]);
//Get all VTIMEZONE iCalendar components
var vtimezones = comp.getAllSubcomponents("vtimezone");
//Add all timezones in iCalendar object to TimezonService