Tutorial by Examples

Nested serializers by default don't support create and update. To support this without duplicating DRF create/update logic, it is important to remove the nested data from validated_data before delegating to super: # an ordinary serializer class UserProfileSerializer(serializers.ModelSerializer): ...
std::vector<int> primes = {2, 3, 5, 7, 11, 13}; for(auto prime : primes) { std::cout << prime << std::endl; }
In Vim, your configuration file is ~/.vimrc, with further configuration files in ~/.vim. In Neovim, configuration files are located in ~/.config/nvim. There is also no ~/.nvimrc file. Instead, use ~/.config/nvim/init.vim. You can import your Vim configuration directly into Neovim using this Unix c...
The only way if your components does not have a parent-child relationship (or are related but too further such as a grand grand grand son) is to have some kind of a signal that one component subscribes to, and the other writes into. Those are the 2 basic operations of any event system: subscribe/li...
This fetches the value of NOW() in local time, in India Standard Time, and then again in UTC. SELECT NOW(); SET time_zone='Asia/Kolkata'; SELECT NOW(); SET time_zone='UTC'; SELECT NOW();
If you have a stored DATE or DATETIME (in a column somewhere) it was stored with respect to some time zone, but in MySQL the time zone is not stored with the value. So, if you want to convert it to another time zone, you can, but you must know the original time zone. Using CONVERT_TZ() does the con...
An integer literal is a primary expression of the form decimal-literal It is a non-zero decimal digit (1, 2, 3, 4, 5, 6, 7, 8, 9), followed by zero or more decimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) int d = 42; octal-literal It is the digit zero (0) followed by zero or more octal dig...
This is really easy. All TIMESTAMP values are stored in universal time, and always converted to the present time_zone setting whenever they are rendered. SET SESSION time_zone='America/Los_Angeles'; SELECT timestamp_sold FROM sales WHERE state_sold = 'CA' Why is this? TIMESTAMP values are...
Each server has a default global time_zone setting, configured by the owner of the server machine. You can find out the current time zone setting this way: SELECT @@time_zone Unfortunately, that usually yields the value SYSTEM, meaning the MySQL time is governed by the server OS's time zone sett...
To get a list of possible time_zone values in your MySQL server instance, use this command. SELECT mysql.time_zone_name.name Ordinarily, this shows the ZoneInfo list of time zones maintained by Paul Eggert at the Internet Assigned Numbers Authority. Worldwide there are appproximately 600 time z...
Javascript timestamps are based on the venerable UNIX time_t data type, and show the number of milliseconds since 1970-01-01 00:00:00 UTC. This expression gets the current time as a Javascript timestamp integer. (It does so correctly regardless of the current time_zone setting.) ROUND(UNIX_TIMEST...
CREATE TABLE times ( dt DATETIME(3), ts TIMESTAMP(3) ); makes a table with millisecond-precision date / time fields. INSERT INTO times VALUES (NOW(3), NOW(3)); inserts a row containing NOW() values with millisecond precision into the table. INSERT INTO times VALUES ('2015-01...
%f is the fractional precision format specifier for the DATE_FORMAT() function. SELECT DATE_FORMAT(NOW(3), '%Y-%m-%d %H:%i:%s.%f') displays a value like 2016-11-19 09:52:53.248000 with fractional microseconds. Because we used NOW(3), the final three digits in the fraction are 0.
If you have a Javascript timestamp value, for example 1478960868932, you can convert that to a MySQL fractional time value like this: FROM_UNIXTIME(1478960868932 * 0.001) It's simple to use that kind of expression to store your Javascript timestamp into a MySQL table. Do this: INSERT INTO table...
authenticate_with_http_token do |token, options| @user = User.find_by(auth_token: token) end You can test this endpoint with curl by making a request like curl -IH "Authorization: Token token=my-token" http://localhost:3000
RelativePanel has been introduced in Windows 10 and is used mainly to support adaptive layouts, where the child elements of the panel are laid out differently depending on available space. RelativePanel is typically used with visual states, which are used to switch the layout configuration, adaptin...
Here's an example of a React component with a "managed" input field. Whenever the value of the input field changes, an event handler is called which updates the state of the component with the new value of the input field. The call to setState in the event handler will trigger a call to ...
ActionScript 2.0: _root.createTextField("message", 0, 5, 5, 300, 50); var tf:TextFormat = new TextFormat(); tf.color = 0xFF0000; tf.size = 32; tf.bold = true; message.setTextFormat(tf); message.text = "Hello World!"; First function creates a TextField named "mess...
Unit tests test parts of the application in isolation. usually a unit under test is a class or module. let(:gift) { create :gift } describe '#find' do subject { described_class.find(user, Time.zone.now.to_date) } it { is_expected.to eq gift } end source This kind if test is as direct ...

Page 1025 of 1336