Skip to content

Instantly share code, notes, and snippets.

@tnhu
tnhu / audit-logs.json
Created April 1, 2025 21:29
audit-logs.json
{
"audit_logs": [
{
"time": "1:20:50pm",
"date": "Jan 2, 2021",
"module": "Feature Flag",
"project": "My Project X",
"environment": "Production",
"environment_type": "Production",
"user": "Peter Bishop",
@tnhu
tnhu / agent loop
Created March 10, 2025 08:29 — forked from jlia0/agent loop
Manus tools and prompts
You are Manus, an AI agent created by the Manus team.
You excel at the following tasks:
1. Information gathering, fact-checking, and documentation
2. Data processing, analysis, and visualization
3. Writing multi-chapter articles and in-depth research reports
4. Creating websites, applications, and tools
5. Using programming to solve various problems beyond development
6. Various tasks that can be accomplished using computers and the internet
@tnhu
tnhu / chainable-actions.ts
Last active December 2, 2024 17:49
Base class providing chainable async actions with error handling
/**
* Base class providing chainable async actions with error handling
* @template T - The type of object being operated on
*/
export abstract class ChainableActions<T> {
protected chain: Array<{ operation: string; task: () => Promise<void> }> = []
protected error: any | null = null
protected subject: T
protected errorHandler: ((error: any) => void) | null = null
protected updateHandler: ((subject: T) => void) | null = null
@tnhu
tnhu / MyContext.tsx
Created November 24, 2021 23:30
Six simple steps to create and use React Context #react #typescript #context
import React, { useState, useContext } from 'react'
// 1. Define data that the context holds, plus a setter to update data
interface MyContextProps {
standalone: boolean
setMyContext: (value: Partial<Omit<MyContextProps, 'setMyContext'>>) => void
}
// 2. Create the actual context with some default data
const MyAppContext = React.createContext<MyContextProps>({
@tnhu
tnhu / web-servers.md
Last active March 23, 2020 20:33 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8181
@tnhu
tnhu / curl.md
Created August 30, 2018 00:13 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@tnhu
tnhu / icons.css
Created October 19, 2017 18:16
icons.css
:root {
--icon-pending: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="SUCCESS_1_" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"><style type="text/css">.st0{fill-rule:evenodd;clip-rule:evenodd;fill:%23DBDCDD;} .st1{fill-rule:evenodd;clip-rule:evenodd;fill:%23FFFFFF;} </style> <g id="Ellipse_524"> <g> <circle class="st0" cx="8" cy="8" r="8"/> </g> </g> <g id="Ellipse_1551"> <g> <circle class="st1" cx="8" cy="8" r="6"/> </g> </g> </svg>');
--icon-queued: url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="QUE_1_copy_1_" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve"> <style type="text/css"> .st0{fill:#E1E4E5;} .st1{fill:#FFFFFF;} .st2{fill:#C3C8CA;} </style> <g id="Ellipse_
@tnhu
tnhu / gist:4569211a3f1c6758ba22e7281aa739b3
Created January 12, 2017 00:48
Sublime regular expression search & replace
Find what: (^.*): (.*$)
Replace with: "$1": "$2",
--
Before:
memberOf: CN=Realtime Systems,OU=DEPT,OU=Groups,DC=corp,DC=qc
department: Inventory & DMP
After:
@tnhu
tnhu / postgres-cheatsheet.md
Created December 16, 2016 02:19 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

@tnhu
tnhu / DumpStack.java
Created July 13, 2016 22:41
Dump Java stack trace without throwing an exception
import org.apache.commons.lang3.exception.ExceptionUtils;
import play.Logger;
String stackTrace = ExceptionUtils.getStackTrace(new Exception()));
// Log warning with stack trace for a deprecated method
Logger.warn("Method is deprecated: " + stackTrace);