std::cout << wizard.CastSpell("abracadabra") << wizard.DrinkPotion("Rosanke") << wizard.Mana();
More info can be found:
Thursday, June 11, 2015
TIL: never depend on the order of evaluation of sub-expressions in a stream
The code below may result in a 6 different execution orders. It will surprise and hurt you, so don't do that ;-)
Labels:
C++,
it's a trap
Location:
Śródmieście, Olsztyn, Polska
Monday, June 1, 2015
Endless extracting of tar.bz2 archive
Funny story. Over a year ago I've backed up a project directory to tar.bz2 archive. Today I've decided to check what's inside. I've encountered a frozen window of 'extract here' option from file context menu.
I've killed the extract process and rerun it from a terminal:
I've killed the extract process and rerun it from a terminal:
tar -xvvf archive.tar.bz2After few normal lines i've seen smth (in fact thousands of such lines):
hrwxr-x--- user/group 0 2013-02-06 23:20 workspace/a/b/a/b/f.go link to workspace/a/b/f.go hrwxr-x--- user/group 0 2013-02-06 23:20 workspace/a/b/a/b/a/b/f.go link to workspace/a/b/a/b/f.goThis clued me, that probably the archive kept the symbolic links. After Googling and reading
tar manual I had this idea: let's remove a symlink from an archive:
tar --delete -f archive.tar workspace/a/b/aThis worked just well :-)
Thursday, May 28, 2015
pep8
I've got very comfortable with clang-format for C++ and gofmt for Go.
Every time I have to use some other language i'm missing them very much.
Today I've found a solution for Python. It makes life so much easier.
The two awesome tools are:
pep8
pep8 is a tool to check your Python code against some of the style conventions in PEP 8.https://pypi.python.org/pypi/pep8
autopep8
autopep8 automatically formats Python code to conform to the PEP 8 style guide. It uses the pep8 utility to determine what parts of the code needs to be formatted. autopep8 is capable of fixing most of the formatting issues that can be reported by pep8.https://github.com/hhatto/autopep8
Wednesday, April 29, 2015
Torch7 weird error and Google Search without a solution
The below is an error one gets when working with Torch7 from time to time:
/usr/local/bin/luajit: /usr/local/share/lua/5.1/nn/Tanh.lua:4: attempt to index field 'nn' (a nil value) stack traceback: /usr/local/share/lua/5.1/nn/Tanh.lua:4: in function 'updateOutput' /usr/local/share/lua/5.1/nn/Sequential.lua:29: in function 'updateOutput' /usr/local/share/lua/5.1/nn/Sequential.lua:29: in function 'forward' main.lua:93: in function 'opfunc' /usr/local/share/lua/5.1/optim/sgd.lua:43: in function 'sgd' main.lua:117: in function 'train3' main.lua:142: in main chunk [C]: in function 'dofile' /usr/local/lib/luarocks/rocks/trepl/scm-1/bin/th:131: in main chunk [C]: at 0x00406260Reading a bit about similar errors(1) I've concluded that probably the type of
Tensor is
wrong. I work on torch.CudaTensor objects, why the problem? I've forgot to import the
correct library:
require("cunn")
Wednesday, April 22, 2015
Reflex - trigger an execution of command on a file change event
How many times you were working on some tiny project that needs to be rebuild / restarted after you modify the code? I guess often.
After experimenting with some solutions I found an ultimate one: https://github.com/cespare/reflex
Installation:
After experimenting with some solutions I found an ultimate one: https://github.com/cespare/reflex
Installation:
go get github.com/cespare/reflexAutomatically recompiling markdown file into html every time the file is changed:
reflex -r '\.md$' blackfriday-tool -page article.md article.htmlOr you can restart Go app when saved files:
reflex -r '\.go$' -- go run main.go
Subscribe to:
Posts (Atom)