Skip to content

Instantly share code, notes, and snippets.

💻
Computing

Tomás h2non

💻
Computing
  • Dissident
  • Decentralized
Block or report user

Report or block h2non

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@h2non
h2non / issubsubclass.py
Last active Dec 30, 2016
Python metaprogramming for the win! Simple function to check is a given class has a subclass in the subclasses hierarchy chain.
View issubsubclass.py
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.
View keybase.md

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 Feb 18, 2019
JSON POST example with Alamofire
View json-post.swift
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 Apr 22, 2016 — forked from cb372/jargon.md
Category theory jargon cheat sheet
View jargon.md

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 Sep 1, 2015
Recursive implementation of string characters permutation covering all possible cases without duplication
View permute-characters.js
/**
* 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 Aug 29, 2015
Gist for issue: https://github.com/h2non/bimg/issues/44. Run: go run bimg-test.go
View 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
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
View s3-putObject.js
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 Aug 29, 2015
libvips cache trace output. Merges both stdout and stderr
View libvips_cache_trace_out.log
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) -
View debug.go
package bimg
import (
"github.com/dustin/go-humanize"
. "github.com/tj/go-debug"
"runtime"
"strconv"
"time"
)
@h2non
h2non / libvips-installer.sh
Last active Jul 25, 2019
libvips 7.42.x cross-platform simple installer script (supports OSX, Debian, Ubuntu, CentOS, Fedora, Amazon Linux)
View libvips-installer.sh
#!/bin/sh
#
# Orinally made by Lovell Fuller for sharp
# https://github.com/lovell/sharp
#
# Usage:
# curl -s https://gist.githubusercontent.com/h2non/89bb2f87c6499d0b25f1/raw/bf3d0743107f02f5db2b93c53f7f0e07a1c33112/libvips-installer.sh | sudo bash -
#
You can’t perform that action at this time.