embedding binary data as string literals
The problem: had a gzipped file that I wanted to include as a string literal in code.
The solution:
- used the following tool go-bindata:
go-bindata -nocompress *.gz
- found the []byte(“”) representation of the file
- included it in the code
- done!
mysql access denied for user root
Faced this error: Access denied for user ‘root’@’localhost’ (using password: YES) (Mysql2::Error)
Found the fix here:
$ mysql -u root mysql $mysql> UPDATE user SET Password=PASSWORD('my_password') where USER='root'; $mysql> FLUSH PRIVILEGES;
but the 2nd variant was the one that worked in my case:
update user set authentication_string=password('my_password') where user='root';
golang Writer on []byte
Forgot to do a Flush on bufio.NewWriter, and the Bytes() method was returning an empty slice:
atom exclude certain extensions when doing a file search
You can specify more than one pattern in the file/directory pattern, with ! where you can do something like this:
!vendor,!*.go
This will have the effect of not searching in the vendor folder, or in any file with .go extension.
pongo2 register custom function
Say you want to create a function that returns the value of an environment variable:
To use it in the templates, register it on the pongo2.Context:
Last step, is to pass that context when you render the view.
monitor files for changes and run command with nodemon
Used nodemon to restart a simple go web server, when changing any of the files from a folder called web:
nodemon --watch web --exec "go run main.go"
check non-standard extensions with facebook flow
By default, .js and .json are analyzed. Had some files with .es6 extension. To get them to show up when running flow, I had to add this to .flowconfig:
[options] module.file_ext=.es6 module.file_ext=.js module.file_ext=.json