Skip to content

Instantly share code, notes, and snippets.

Krzysztof Kowalczyk kjk

Block or report user

Report or block kjk

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
View test_json.go
package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
)
var jsonStr1 string = `{ "foo" :
View IsBlankFast.go
func IsBlankFast(s string) bool {
n := len(s)
for i := 0; i < n; i++ {
c := s[i]
if c == '\r' || c == '\n' || c == ' ' {
continue
}
return false
}
return true
View nstextview.xml
<window title="test" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1578"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView fixedFrame="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="85O-8d-iEd">
View Notes on Go and Image Magick.md

Hard won wisdom: ImageMagick (and its fork GraphicsMagick) are essentiallyh single-threaded due to internal locking.

What it means is that if you use Go bindings and try to get a higher performance by using multiple goroutines, it won't work.

View NoFreeAllocator.cpp
/* Copyright 2014 the SumatraPDF project authors (see AUTHORS file).
License: Simplified BSD (see COPYING.BSD) */
/* NOTE: this is unfinished work in progress */
/* NoFreeAllocator (ScratchAllocator ?) is designed for quickly and easily
allocating temporary memory that doesn't outlive the stack frame
in which it was allocated.
Consider this piece of code:
@kjk
kjk / go_smaz_faster.md
Created Dec 11, 2014
Improving smaz benchmarking
View go_smaz_faster.md

Before:

Krzysztofs-MacBook-Pro-4:go-smaz kkowalczyk$ go test -bench=.
PASS
BenchmarkCompression	     500	   3451735 ns/op	  39.60 MB/s
BenchmarkDecompression	     500	   2740847 ns/op	  27.58 MB/s

After:

Krzysztofs-MacBook-Pro-4:go-smaz kkowalczyk$ go test -bench=.
View ProgramVersion.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
/* This code was written by Krzysztof Kowalczyk (http://blog.kowalczyk.info)
and is placed in public domain. */
View ffprobe usage
`./ffprobe -show_format -show_streams -print_format json $file`
@kjk
kjk / test_gob.go
Created Dec 18, 2013
Shows that one cannot append data to a gob file - the decoder will error out with 'extra data in buffer` when trying to decode data written by append.
View test_gob.go
package main
import (
"encoding/gob"
"fmt"
"io"
"log"
"math/rand"
"os"
)
@kjk
kjk / show_caller_name.go
Last active Dec 31, 2015
Shows that we can get the caller's function name without access to source code. go build -o test show_caller_name.go; rm show_caller_name.go; ./test
View show_caller_name.go
package main
import (
"bytes"
"fmt"
"runtime"
)
var (
dunno = []byte("???")
You can’t perform that action at this time.