Tutorial by Examples: c

Applications running in non-development environments often require database updates. After using the Add-Migration command to create your database patches there's the need to run the updates on other environments, and then the test environment as well. Challenges commonly faced are: no Visual S...
Using React.createClass will automatically bind this context (values) correctly, but that is not the case when using ES6 classes. React.createClass Note the onClick declaration with the this.handleClick method bound. When this method gets called React will apply the right execution context to the ...
In order to get the total number of commits that each developer or contributor has made on a repository, you can simply use the git shortlog: git shortlog -s which provides the author names and number of commits by each one. Additionally, if you want to have the results calculated on all branch...
In spark-shell: sc.version Generally in a program: SparkContext.version Using spark-submit: spark-submit --version
Let say you want to build your API to comply jsonapi.org specification and the result should look like: { "article": { "id": "305", "type": "articles", "attributes": { "title": "Asking Alexandria&q...
from pymongo import MongoClient uri = "mongodb://localhost:27017/" client = MongoClient(uri) db = client['test_db'] # or # db = client.test_db # collection = db['test_collection'] # or collection = db.test_collection collection.save({"hello":"world"...
import cv2 import numpy as np import urllib stream=urllib.urlopen('http://96.10.1.168/mjpg/video.mjpg') bytes='' while True: bytes+=stream.read(1024) a = bytes.find('\xff\xd8') # JPEG start b = bytes.find('\xff\xd9') # JPEG end if a!=-1 and b!=-1: jpg = bytes[a:b+...
"Fat Model, Skinny Controller" is a very good first step, but it doesn't scale well once your codebase starts to grow. Let's think on the Single Responsibility of models. What is the single responsibility of models? Is it to hold business logic? Is it to hold non-response-related logic? ...
In your Maven project, add the following to your pom.xml file. The following versions are for Cassandra 3.x. <dependency> <groupId>com.datastax.cassandra</groupId> <artifactId>cassandra-driver-core</artifactId> <version>3.1.0</ve...
Connecting to Cassandra is very similar to connecting to other datasources. With Cassandra, credentials are not required. String cassandraIPAddress = "127.0.0.1"; String cassandraKeyspace = "myKeyspace"; String username = "foo"; String password = "bar"; ...
public enum Cassandra { DB; private Session session; private Cluster cluster; private static final Logger LOGGER = LoggerFactory.getLogger(Cassandra.class); /** * Connect to the cassandra database based on the connection configuration provided. * Multiple c...
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...
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...
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...

Page 638 of 826