Skip to content

Instantly share code, notes, and snippets.

View h2non's full-sized avatar

Tom h2non

  • Dissident
  • Decentralized
View GitHub Profile
@h2non
h2non / libvips-installer.sh
Last active July 25, 2024 03:38
libvips 7.42.x cross-platform simple installer script (supports OSX, Debian, Ubuntu, CentOS, Fedora, Amazon Linux)
#!/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 -
#
@h2non
h2non / ffmpeg-install-osx.sh
Last active August 29, 2015 14:14
Install ffmpeg and common video/audio encoding shared libraries in OSX
brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools --with-libogg
@h2non
h2non / ancestors.js
Created February 6, 2015 18:55
Recursively inspect the prototype chain inheritance of a given object in JavaScript (inspired in Ruby's Class.ancestors)
// Under WTFPL license ;)
function ancestors(obj) {
var hierarchy = [];
if (['boolean', 'number', 'string', 'undefined'].indexOf(typeof obj) !== -1 || obj === null) { // primitives types
obj = Object(obj);
} else if (typeof obj === 'function') {
hierarchy.push(
obj.name ||
(obj.toString().match(/function (\w*)/) ||
obj.toString().match(/\[object (\w*)\]/))[1] ||
@h2non
h2non / .editorconfig
Created November 12, 2014 14:26
Editorconfig for package.json
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
@h2non
h2non / jshint-directives-node.js
Last active August 29, 2015 14:09
JSHint directives for node.js projects
{
"node": true,
"browser": false,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
(function (global) {
'use strict';
/*\
|*|
|*| Base64 / binary data / UTF-8 strings utilities
|*|
|*| https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding
|*|
\*/
@h2non
h2non / base64-utf8-decode.js
Created October 28, 2014 14:42
Base64 UTF8 native decoding in browsers
function base64UTF8Decode(str) {
return unescape(decodeURIComponent(window.atob(str)))
}
@h2non
h2non / cors.conf
Last active November 28, 2017 02:40
Nginx CORS config
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers *;
add_header Access-Control-Allow-Methods GET, POST, OPTIONS;
add_header Access-Control-Allow-Credentials true;
@h2non
h2non / uuid.js
Last active August 29, 2015 14:06
Time-based UUID v4 compliant generator (RFC4122 compliant)
function uuid() {
var uuid = "", i, random;
for (i = 0; i < 32; i++) {
random = Math.random() * 16 | 0;
if (i == 8 || i == 12 || i == 16 || i == 20) uuid += "-"
uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16)
}
return uuid
}
@h2non
h2non / nar-static-http-app.md
Last active August 29, 2015 14:03
Create an executable binary-like nar archive based on a static web application with an embedded HTTP server

nar webapp howto

Create a fully self-contained executable of a web application with an embedded HTTP server using nar

Install nar as global package (you must have node.js already installed in your system)

$ npm install -g nar