Skip to content

Instantly share code, notes, and snippets.

@miguelmota
miguelmota / iota.js
Created March 22, 2019 19:22
Node.js iota (Golang iota equivalent)
const iota = (() => { let n = 0; return () => n++ })()
const myEnum = {
foo: iota(), // 0
bar: iota(), // 1
baz: iota(), // 2
qux: iota(), // 3
}
@felipecrv
felipecrv / SimpleImage.php
Created May 31, 2013 21:15
A PHP Imagick wrapper class that makes image manipulation simpler by making some decisions and by adding new functionality. The `getMainBorderColor()` method is specially interesting. With it you can calculate which color is the most frequent in the lateral borders of an image. I used it to set a background for an area that could possibly be lef…
<?php
class SimpleImage {
private $img;
public function __construct($path) {
$path = Filesystem::resolvePath($path);
Filesystem::assertExists($path);