Posts

Showing posts from July, 2018

Golang Structs Caveats

By default Go initiates empty structs (as well as other variable types) with empty fields. The question is next - let's assume we have next struct: type Example struct { ready bool, num int16, q float32, } Total 1 byte for bool, 2 bytes for int16 and 2 for float32 = 7 bytes.? Not so, because we have int16 after bool, Go will use padding - use memory in same amount as next declared field requires. That means if we have field that requires 2 bytes after field that requires 1 byte, Go will require 1 more byte as a padding for "1 byte" field. If we use fields like int64 - 8 bytes, on every object we will spend extra 7 bytes. What is the solution? Declare "heavy" fields first, than "light" ones. type Example struct { num int16, q float32, ready bool, }

How to create read only user in PostgreSQL

-- Create a group CREATE ROLE readaccess; -- Grant access to existing tables GRANT USAGE ON SCHEMA public TO readaccess; GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; -- Grant access to future tables ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; -- Create a final user with password CREATE USER tomek WITH PASSWORD 'secret'; GRANT readaccess TO tomek; Taken from gist.github.com

Implementation marketplace using Stripe or PayPal

Definition Marketplace – type of business model of Internet application, which provides service for sellers to sell products directly in application, and application will capture and charge buyer using payment provider systems. It is possible for a marketplace application to take platform fees. Overview There are different platforms which allow to implement marketplace functionality. Most commonly used are PayPal Marketplace and Stripe Connect , also recently become popular Adyen . Only PayPal and Stripe was investigated. All of the have developer’s sandboxes. Paypal has separate one, Stripe included into a real account (You have to enable test data, just toggle “View test data”). Settings Stripe To be able to work with Stripe application should have Publishable key and Secret key and Client id / Test mode client id. Publishable key and secret key you can found under Developers -> API keys . Client Id is received from an account manager. ...

Biochemistry - That's Cool

Image
Recently visited biochemistry site of BI in Vienna. Production of proteins using cells is really interesting area for me. Don't plan to switch areas, however process is complex, and am really keen to get knowledge how people manage it.

Kafka auto flush

To avoid a call of flush command on Kafka producer just set property linger.ms to 1 on properties passed to a Kafka producer constructor.