Skip to content

Instantly share code, notes, and snippets.

@olekukonko
olekukonko / parseInt64.go
Created April 26, 2014 11:32
strconv.ParseInt Faster Implementation to convert strings to int64
// Ascii numbers 0-9
const (
ascii_0 = 48
ascii_9 = 57
)
// parseInt64 expects decimal positive numbers. We
// return -1 to signal error
func parseInt64(d []byte) (n int64) {
if len(d) == 0 {
<?php
/**
* PHP XML to dynamic table
*
* @link http://stackoverflow.com/q/16997835/367456
*/
require('.../Iterator-Garden/src/autoload.php'); // for DecoratingIterator - use development branch

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

// call this function from a http Handler Func, where data is the response object
// response will be compressed with gzip if requester accepts it
// browser should automatically decompress into valid json
func jsonResponseWriter(w http.ResponseWriter, r *http.Request, data interface{}) error {
var err error
var jsonData []byte
if jsonData, err = json.Marshal(data); err != nil {
return err
}
w.Header().Set("Content-Type", "application/json")
@olekukonko
olekukonko / script.sh
Last active August 29, 2015 14:19 — forked from adnaan/script.sh
ls -la
echo "hello"
tree
adb devices
adb wait-for-device #example of a long running task
// To the extent possible under law, the Yawning Angel has waived all copyright
// and related or neighboring rights to orhttp_example, using the creative
// commons "cc0" public domain dedication. See LICENSE or
// <http://creativecommons.org/publicdomain/zero/1.0/> for full details.
package main
import (
// Things needed by the actual interface.
"golang.org/x/net/proxy"
func handleUpload(u io.Reader) (err error) {
// capture all bytes from upload
b, err := ioutil.ReadAll(u)
if err != nil {
return
}
// wrap the bytes in a ReadSeeker
r := bytes.NewReader(b)
@olekukonko
olekukonko / Tags.go
Last active August 29, 2015 14:26 — forked from mattcunningham/Tags.go
package main
import (
"fmt"
"reflect"
"net/url"
)
type ExampleType struct {
Name string `url:"name"`
@olekukonko
olekukonko / preprocessor_fun.h
Last active August 30, 2015 20:46 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
package main
import (
"container/list"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"