Skip to content

Instantly share code, notes, and snippets.

@guregu
guregu / newgltd.txt
Created June 13, 2012 12:55
Top new gLTD applications
APP 13
INC 11
HOME 11
ART 10
SHOP 9
BLOG 9
BOOK 9
LLC 9
MUSIC 8
MOVIE 8
@guregu
guregu / server.c
Last active December 20, 2015 09:49
小さなWebサーバ ・ Unix系のOSで実行してください ・ デフォルトはhttp://localhost:8888からアクセスできます
/* * * * * * * * * * * *
* シンプルなHTTPサーバ
* Gregory Scott Roseberry
* 1M100407-6
* * * * * * * * * * * */
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
@guregu
guregu / ex1.md
Last active January 2, 2016 11:49
Using Hakobiya

Using Hakobiya

Hakobiya is alpha software I'm working on designed to make real-time communication in Angular.js easy. I found myself remaking basically the same simple servers over and over, just to push variables around. Hakobiya is a flexible generalization of those servers.

Let's see what Hakobiya can do by running the included chat application.

Running

You need Go installed. http://golang.org

Install Hakobiya with: go get github.com/guregu/hakobiya

@guregu
guregu / tiled.go
Last active October 14, 2015 22:42
engi + tiled
package tiled
import (
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"github.com/guregu/eng"
@guregu
guregu / main.go
Created February 12, 2016 23:19
Compsing kami
package main
import (
"fmt"
"net/http"
"github.com/guregu/kami"
"golang.org/x/net/context"
)
@guregu
guregu / fix-image-maps.js
Created October 17, 2017 14:40
Responsive image maps (vanilla JS)
function fixImageMaps(force) {
var imgs = document.querySelectorAll("img[usemap]");
[].forEach.call(imgs, function(img) {
if (!img.naturalHeight) { return; }
var h = img.height / img.naturalHeight;
var w = img.width / img.naturalWidth;
var map = document.getElementsByName(img.useMap.slice(1))[0];
if (!map) { return; }
for (var i = 0; i < map.children.length; i++) {
var area = map.children[i];
@guregu
guregu / benchmarks.txt
Created April 25, 2020 10:54
Benchmarks for guregu/null v4
# Benchmarks for v4
BenchmarkIntUnmarshalJSON-8 4329932 268 ns/op 184 B/op 2 allocs/op
BenchmarkIntStringUnmarshalJSON-8 4859449 248 ns/op 184 B/op 2 allocs/op
BenchmarkNullIntUnmarshalJSON-8 183305532 6.46 ns/op 0 B/op 0 allocs/op
BenchmarkStringUnmarshalJSON-8 4850442 241 ns/op 181 B/op 2 allocs/op
BenchmarkNullStringUnmarshalJSON-8 184386210 6.46 ns/op 0 B/op 0 allocs/op
# Benchmarks for v3
BenchmarkIntUnmarshalJSON-8 1756759 682 ns/op 392 B/op 6 allocs/op
BenchmarkIntStringUnmarshalJSON-8 3163022 380 ns/op 216 B/op 4 allocs/op
@guregu
guregu / telegram.go
Created November 3, 2020 14:50
telegram message sending and webhook
package mail
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
var TelegramAuthToken string // set this
@guregu
guregu / mail.go
Created November 4, 2020 14:26
minimal SES mailer
package email
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ses"
)
const noreply = " <noreply@example.com>"
@guregu
guregu / between.go
Last active March 15, 2022 05:47
ichiban/prolog implementation: between/3
package lib
import (
"context"
"math"
"github.com/ichiban/prolog/engine"
"github.com/guregu/predicates/internal"
)