Skip to content

Instantly share code, notes, and snippets.

View h2non's full-sized avatar

Tom h2non

  • Dissident
  • Decentralized
View GitHub Profile
Understand the Task: Grasp the main objective, goals, requirements, constraints, and expected output.
- Minimal Changes: If an existing prompt is provided, improve it only if it's simple. For complex prompts, enhance clarity and add missing elements without altering the original structure.
- Reasoning Before Conclusions: Encourage reasoning steps before any conclusions are reached. ATTENTION! If the user provides examples where the reasoning happens afterward, REVERSE the order! NEVER START EXAMPLES WITH CONCLUSIONS!
- Reasoning Order: Call out reasoning portions of the prompt and conclusion parts (specific fields by name). For each, determine the ORDER in which this is done, and whether it needs to be reversed.
- Conclusion, classifications, or results should ALWAYS appear last.
- Examples: Include high-quality examples if helpful, using placeholders [in brackets] for complex elements.
- What kinds of examples may need to be included, how many, and whether they are complex enough to benefit from p
@h2non
h2non / issubsubclass.py
Last active December 30, 2016 00:15
Python metaprogramming for the win! Simple function to check is a given class has a subclass in the subclasses hierarchy chain.
def issubsubclass(cls, subcls):
"""
Recursively check if a given class has a subclass of `obj` class in the
subclasses hierarchy.
Under the hood, it does some metaprogramming magic recursively checking
the `__bases__` magic attribute.
Extends `issubclass` built-in function to check subclass hierarchies.

Keybase proof

I hereby claim:

  • I am h2non on github.
  • I am h2non (https://keybase.io/h2non) on keybase.
  • I have a public key whose fingerprint is F261 06C4 A327 FE10 8FE2 37B9 E63F AD85 FCFF 12F8

To claim this, I am signing this object:

@h2non
h2non / json-post.swift
Last active September 11, 2022 01:38
JSON POST example with Alamofire
let parameters = [
"username": "foo",
"password": "123456"
]
Alamofire.request(.POST, "https://httpbin.org/post", parameters: parameters, encoding: .JSON)
// -> HTTP body: {"foo": [1, 2, 3], "bar": {"baz": "qux"}}
@h2non
h2non / jargon.md
Last active April 22, 2016 06:56 — forked from cb372/jargon.md
Category theory jargon cheat sheet

Category theory jargon cheat sheet

A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)

I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.

Functor

A functor is something that supports map.

@h2non
h2non / permute-characters.js
Last active September 1, 2015 18:44
Recursive implementation of string characters permutation covering all possible cases without duplication
/**
* Recursive implementation of string characters permutation
* covering all possible cases without duplication
*/
function permute(str) {
var stack = []
if (str.length === 1) {
return [ str ]
}
@h2non
h2non / bimg-test.go
Last active August 29, 2015 14:24
Gist for issue: https://github.com/h2non/bimg/issues/44. Run: go run bimg-test.go
package main
import (
"fmt"
"gopkg.in/h2non/bimg.v0"
"os"
)
const operations = 10000
@h2non
h2non / s3-putObject.js
Created May 4, 2015 17:13
Simple example demostrating how to wrap the S3.putObject() in AWS node.js SDK to transform it into a pipeable compatible interface. Related issue: https://github.com/aws/aws-sdk-js/issues/588
var fs = require('fs')
var pipefy = require('pipefy')
var AWS = require('aws-sdk')
var s3 = new AWS.S3()
// Keep safe the original function with proper scope
var putObject = s3.putObject.bind(s3)
// Override the function
s3.putObject = function (opts, cb) {
@h2non
h2non / libvips_cache_trace_out.log
Last active August 29, 2015 14:19
libvips cache trace output. Merges both stdout and stderr
This file has been truncated, but you can view the full file.
vips cache : jpegload_buffer buffer=VIPS_TYPE_BLOB, data = 0xc20818e000, length = 877585 access=((VipsAccess) VIPS_ACCESS_SEQUENTIAL) -
vips cache : jpegload_buffer buffer=VIPS_TYPE_BLOB, data = 0xc208358000, length = 877585 access=((VipsAccess) VIPS_ACCESS_SEQUENTIAL) -
vips cache+: jpegload_buffer buffer=VIPS_TYPE_BLOB, data = 0xc20818e000, length = 877585 shrink=4 -
vips cache+: jpegload_buffer buffer=VIPS_TYPE_BLOB, data = 0xc208358000, length = 877585 shrink=4 -
vips cache : copy in=((VipsImage*) 0x70191b0) -
vips cache+: shrink in=((VipsImage*) 0x70191b0) xshrink=4.000000 yshrink=4.000000 -
vips cache : copy in=((VipsImage*) 0x70197f0) -
vips cache+: shrink in=((VipsImage*) 0x70197f0) xshrink=4.000000 yshrink=4.000000 -
vips cache : copy in=((VipsImage*) 0x7019980) -
@h2non
h2non / debug.go
Last active August 29, 2015 14:18
package bimg
import (
"github.com/dustin/go-humanize"
. "github.com/tj/go-debug"
"runtime"
"strconv"
"time"
)