Saturday, July 01, 2017
when I looking for a more lightweight search engine, mongodb came cross my mind. it does supports text search.
I know mongodb has lots of bad comments, but as I said it's getting better, its wiredtiger storage engine supports compression
I decided give a try. use it to replace MySQL and elasticsearch
last week I was writing crappy node.js codes (callback hell style) under terminal using vim
however, just code and think less seem work pretty well on me. (partly because I'm still fluent in vim)
code was crappy but I could get the result faster. once I got the result I want, I could kept fine tuning and refactoring with less worry. because job was done and it's always possible to make it better.
worse is better, make it work then make it better. it was a good experiment and reminds me my junior years.
some recent tweets:
5 Programming Languages You Should Really Try
tl;dr version: nim, go, f#, rust and clojure
I told my colleagues the choice of mine are: elixir/erlang (prolog family), rust (c family), f# (ML family), clojure (lisp family) and haskell (king of all)
Why the JVM is a Good Choice for Serverless Computing: John Chapin Discusses AWS Lambda at QCon NY
I like JVM but I'm not quite sure about this one, the development process so painful because it's too damn slow to upload.
Inventory management in MongoDB: A design philosophy I find baffling
I read this after I finished my reading on MongoDB in Action 2nd Edition, of course I didn't notice the problem, but I'm more interested in how not to do it from discussion on hackernews and Model Data for Atomic Operations
Sunday, July 02, 2017
reading an old book: Effective MySQL Replication Techniques in Depth
because I'm going to setup a myrocks slave, wants to make sure I understand how replication works first.
the book is quite good by the way.
Saturday, July 08, 2017
finger hurts again, leave emacs and return to vim temporarily.
probably because of the alt
key, which I used heavily under tmux and emacs
also discovered more vim usage:
for emacs ctrl-l
vim equivalent:
zz
: centerzt
: topzb
: bottomz.
: like center, but put cursor at the first non-blank character
to lower/upper case, after selected block of text, u
to lowercase and U
to uppercase.
open file under cursor:
gf
to open itctrl-w f
to open it with split windowctrl-w gf
to open it in new tab
for tabs:
:tabe
to open file in new tab:tabf
to find file in new tab:tabc
to close tab, or usectrl-w c
gt
/gT
moves between tabs:tabs
lists all tabs
when under split window, ctrl-w T
moves current window to new tab
Thursday, July 20, 2017
trying Wily editor, maybe I should try plan9port for acme or sam editors, but wily is just an apt-get install
command.
I played acme on inferno before, I already forgot how to use it.
some history, about Lars Bak (Dart) and Robert Griesemer (Go), they are both worked at Strongtalk and HotSpot, then V8
they are the creators of Dart (Lars) and Go (Robert, with Rob Pike and Ken Thompson)
two members from StrongTalk team are super famous too:
Gilad Bracha, co-author of Java Language Specification and Java Virtual Machine Specification, Dart team.
Urs Hölzle, hotspot, Google's eighth employee and built Google's infrastructure.
all these people were in a team ... crazy.
I need to leave clojure for a while, I feel inefficient when working with it lately.
I'm doing go now.
I was searching for a jq wrapper for go, didn't find anything great.
maybe this one will work: threatgrid/jqpipe-go: A Go Wrapper for JQ
Saturday, July 22, 2017
I read Go in Action last year, but I'm reading it again now. actually I already forgot what I've read last time.
one thing I still not figured out yet is when designing a function, how to determine accept values or pointers.
there're two parts, receivers and arguments
for receivers:
- if not an interface type, either values or pointers can be used. compiler will reference/dereference automatically.
- if receiver is an interface type, pointers receiver can only be called by the type contains pointers. values receiver can be call by the type contains both values and pointers.
the best practice to declare methods is using pointer receivers.
for arguments, I'm not sure yet. I think as the book said:
if you need to access and change the state of a variabel, pass pointer. if you don't need to manipulate the state, pass value.
when starting a new go project, I noticed since v1.6
lookup paths include ./vendor/
folder.
but how about go get
? will it download packages to ./vendor
?
looks like I'll need to copy dependencies from $GOPATH/src/foo
to ./vendor/foo
should I check in the ./vendor
folder?
I think I will, but need to remove .git
folders inside dependencies.
I don't want to use godep or govendor or glide yet.
one important thing is the ./vendor
folder must inside GOPATH
:
.
└── src
├── foo
│ └── foo.go
└── user
├── main.go
└── vendor
└── bar
└── bar.go
this will work:
$ GOPATH=$PWD go run src/user/main.go
$ GOPATH=$PWD go build user
if you put main.go
and verdor
outside of user
folder, it's not going to work.
it's weird and seems they're still working on a solution. so we have to stick with GOPATH
.
recently I switched to use GNU Unifont
under ubuntu, simply apt-get install ttf-unifont
Sunday, July 23, 2017
JSON-to-Go helps you convert json to go structs, very useful.
json in go standard library is under encoding
namespace, you can decode
but also have to be able to encode
as well. that's why they don't deal with dynamic fields.
some discussion on clojure start-up time again: How ’bout that start-up time?
slow start-up time is very painful, especially on my old laptops.
vim tips time:
to zoom/expand a split window, use
c-w |
(horizontally)c-w _
(vertically),c-w =
to un-zoom.c-w r
andc-w R
to swap windows.
:ls
to list buffers, :bn
and :bp
to navigate.
you can set make
command like this:
autocmd BufNewFile,BufRead *.js set makeprg=node\ %
then when editing .js
files, :make
to run the file.
however, now I will create a Makefile
for the project and :make
will automatically calls it.
I have to turn off set autochdir
because of this, and use:
:pwd
to check current directory:lcd %:p:h
to change directory
the benifits of using Makefile
is vim now able to open corresponding file and line when error occurs.
surround plugin
change surroundings, use cs
remove surroundings, use ds
insert surroundings, use ysiw
or yss
my colleagues mentioned Linux Torvalds uses uemacs
I checked out the repo and compiled it. I'm afraid it is not an emacs
but it should be a good reference for writing an editor.
after uemacs and wily experience, I decide to try turning off colors on my editor and shell.
I like it so far.
Tuesday, July 25, 2017
gocon 2017 videos are here
I watched a very good one: Liz Rice - A Go Programmer's Guide to Syscalls
she implemented a strace
in go, really cool. I also learned seccomp which can limit what syscalls you allow the application to run and docker support seccomp
Also watch a little bit of:
- Alan Shreve - grpc: From Tutorial to Production
- Aaron Schlesinger - Functional Programming in Go
- Marty Schoch - Building a High-Performance Key/Value Store in Go
watched dotGo 2015 - Rob Pike - Simplicity is Complicated
now I agree that maybe they are right. when coding in clojure I need to think a lot. while using go, I just code, because there's no alternative, you just have one way to do things. I don't have to think about is this the best way to do it? is there any better way?
but on the other hand, it's less fun.
same as now I switched back to vim, I think less (I have very little plugins and custom keys), emacs I just have too many short keys.
after clojure I was picking a language between go and elixir, I choosed go because it's more simple.
I will continue my study on elixir sometimes next year maybe?
Wednesday, July 26, 2017
Watching Renzo Borgatti - Clojure Transducers In The Wild
Renzo Borgatti has some pretty cool stuffs:
more low level go stuff from gophercon 2017: Areg Melik Adamyan - Let NFV Go: Experimental Framework for Network Functions
I don't think I'll touch these, but good to know:
- YANFF - Yet Another Network Function Framework
- DPDK is a set of libraries and drivers for fast packet processing.
- DPDK and the new pdump framework for packet capture
go 1.9rc1
is released:
$ go get golang.org/x/build/version/go1.9.rc1
$ go1.9rc1 download
$ go1.9rc1 version
for what's new can check this slide: The State of Go (May 2017)
- Alias declarations (mentioned in Russ Cox - The Future of Go)
sync.Map
watching Rich Hickey - Inside Transducers
it's a difficult talk and I'll need some time to finish it. but it goes over many implementation of clojure functions, worth the time.
defn Episode #24 – Enter the Dragan
the guest uses xmonad:
I took a look, seems depends on ghc, which is pretty large. I think I'll better stick with awesome wm
I learned today systemd supports Timers, as alternative to cron
basically setup a systemd service and a .timer
file.
more details on systemd/Timers - ArchWiki
I'm not sure if it's better than cron? I'll just let puppet handles it.
cider-jack-in
is painfully slow, I may try some of suggestion mentioned in this article.
but I'm not doing any clojure right now ...
reading Go Web Programming, it is good.
now I understand more about the net/http package, and the difference between HandleFunc
and HandlerFunc
:
HandlerFunc
convert a function to handler and register it toDefaultServeMux
HandlerFunc
is a function type
if you have a function foo
that takes http.ResponseWriter
and *http.Request
as arguments, you can use HandlerFunc(foo)
to convert foo
to HandlerFunc
type (just like string(1)
to convert 1
to "1"
)
HandlerFunc
has one method: ServeHTTP
.
another type that has ServeHTTP
method is ServeMux
, the DefaultServeMux
is an instance of ServeMux
.
the type has ServeHTTP
method fulfill the requirement of handler
interface:
type Handler interface {
ServeHTTP(ResponseWriter, *Request)
}
so HandlerFunc
and ServeHTTP
are both Handler
.
Wednesday, July 31, 2017
watched GopherCon 2017: Kris Nova - Valuable Lessons in Over-Engineering the Core of Kubernetes kops
they changed from YAML config to use FuncMap Type, had great performance improvement.
I found some Example Of Using Templates In Golang:
fmap := template.FuncMap{
"formatAsDollars": formatAsDollars,
"formatAsDate": formatAsDate,
"urgentNote": urgentNote,
}
t := template.Must(template.New("email.tmpl").Funcs(fmap).ParseFiles("email.tmpl"))
using a template like this:
{{.FromDate | formatAsDate}} to {{.ToDate | formatAsDate}}.
Blog Archive
- Newer Entries
- 2017 August
- 2017 September
- 2017 October
- 2017 November
- 2017 December
- 2018 January
- 2018 February
- 2018 March
- 2018 April
- 2018 May
- 2018 June
- 2018 July
- 2018 August
- 2018 September
- 2018 October
- 2018 November
- 2018 December
- 2019 January
- 2019 February
- 2019 March
- 2019 April
- 2019 May
- 2019 July
- 2019 October
- 2019 November
- 2019 December
- 2020 August
- 2020 September
- 2020 October
- 2020 November
- 2020 December
- 2021 January
- 2021 February
- 2021 March
- 2021 April
- 2021 May
- 2021 June
- 2021 August
- 2021 September
- 2021 December
- 2022 March
- 2022 April
- 2022 May
- 2022 June
- 2022 July
- 2022 August
- 2022 September
- 2022 October
- 2022 November
- 2022 December
- 2023 January
- 2023 February
- 2023 March
- 2023 April
- 2023 July
- 2023 August
- 2023 September
- 2023 October
- 2023 November
- 2023 December
- 2024 January
- 2024 February
- 2024 March
- 2024 April
- 2024 May
- 2024 June
- 2024 August
- 2024 September
- 2024 October
- 2024 November
- Older Entries
- 2017 June
- 2017 May
- 2017 April
- 2017 March
- 2017 February
- 2017 January
- 2016 December
- 2016 November
- 2016 October
- 2016 September
- 2016 August
- 2016 July
- 2016 June
- 2016 May
- 2016 April
- 2016 March
- 2016 February
- 2016 January
- 2015 December
- 2015 November
- 2015 October
- 2015 September
- 2015 August
- 2015 July
- 2015 June
- 2015 May
- 2015 April
- 2015 March
- 2015 February
- 2015 January
- 2014 December
- 2014 November
- 2014 October
- 2014 September
- 2014 August
- 2014 March
- 2014 February
- 2014 January
- 2013 December
- 2013 October
- 2013 July
- 2013 June
- 2013 May
- 2013 March
- 2013 February
- 2013 January
- 2012 December
- 2012 November
- 2012 October
- 2012 September
- 2012 August