Tutorial by Examples: c

import java.time.LocalTime; import java.time.ZoneId; import java.time.temporal.ChronoUnit; public class Test { public static void main(String[] args) { ZoneId zone1 = ZoneId.of("Europe/Berlin"); ZoneId zone2 = ZoneId.of("Brazil/East"); ...
When a module is using at expressions, such as: #lang at-exp racket/base or #lang scribble/manual You have access to the following types of comments: @;{Block text that goes until the closing brace.} As well as: @; Single line text. Note that if you are using a language that ...
The @lru_cache decorator can be used wrap an expensive, computationally-intensive function with a Least Recently Used cache. This allows function calls to be memoized, so that future calls with the same parameters can return instantly instead of having to be recomputed. @lru_cache(maxsize=None) # ...
This combines queries such that the best (that is, highest-scoring) match of it's subqueries contributes to the final score. List<Query> disjuncts = new ArrayList<Query>(); disjuncts.add(new TermQuery(new Term("fieldname", "hello"))); disjuncts.add(new TermQuery(...
For those of us using Maven as a build system, we can use the Maven Archetype to create a new application. First consult the maven archetype catalog mvn archetype:generate -DarchetypeCatalog=http://struts.apache.org/ you can use one of the following achetypes: The Blank Convention Archetype (s...
Always encode from unicode to bytes. In this direction, you get to choose the encoding. >>> u'🐍'.encode('utf-8') '\xf0\x9f\x90\x8d' The other way is to decode from bytes to unicode. In this direction, you have to know what the encoding is. >>> b'\xf0\x9f\x90\x8d'.decode('...
When a table has an AUTO_INCREMENT PRIMARY KEY, normally one does not insert into that column. Instead, specify all the other columns, then ask what the new id was. CREATE TABLE t ( id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, this ..., that ..., PRIMARY KEY(id) ); INSERT I...
This set of example show how to execute commands stored in strings or script files, without the need of the interactive prompt. This is especially useful to when a shell script needs to interact with a database. Execute command from a string $ mysql -uroot -proot test -e'select * from people' +...
Suppose you have a DataFrame of numerical values, for example: df = pd.DataFrame(np.random.randn(1000, 3), columns=['a', 'b', 'c']) Then >>> df.corr() a b c a 1.000000 0.018602 0.038098 b 0.018602 1.000000 -0.014245 c 0.038098 -0.014245 1.000000...
Colored text can be created by passing the text and a font color name to the following function: private String getColoredSpanned(String text, String color) { String input = "<font color=" + color + ">" + text + "</font>"; return input; } The ...
In Kotlin, classes are final by default which means they cannot be inherited from. To allow inheritance on a class, use the open keyword. open class Thing { // I can now be extended! } Note: abstract classes, sealed classes and interfaces will be open by default.
Defining the base class: open class BaseClass { val x = 10 } Defining the derived class: class DerivedClass: BaseClass() { fun foo() { println("x is equal to " + x) } } Using the subclass: fun main(args: Array<String>) { val derivedClass = Deri...
Defining the base class: open class Person { fun jump() { println("Jumping...") } } Defining the derived class: class Ninja: Person() { fun sneak() { println("Sneaking around...") } } The Ninja has access to all of the methods in Pe...
Sometimes your webpage needs a automatic redirect. For example, to redirect to example.com after 5 seconds: <meta http-equiv="refresh" content="5;url=https://www.example.com/" /> This is line will send you to the designated website (in this case example.com after 5 sec...
One of the more annoying things that programmers can do is to scatter calls to printStackTrace() throughout their code. The problem is that the printStackTrace() is going to write the stacktrace to standard output. For an application that is intended for end-users who are not Java programmers,...
Union types are used in several languages, like C-language, to contain several different types which can "overlap". In other words, they might contain different fields all of which start at the same memory offset, even when they might have different lengths and types. This has the benef...
setuptools_scm is an officially-blessed package that can use Git or Mercurial metadata to determine the version number of your package, and find Python packages and package data to include in it. from setuptools import setup, find_packages setup( setup_requires=['setuptools_scm'], use_...
PostScript is a Turing-complete general programming language, designed and developed by Adobe Systems. Many of the ideas which blossomed in PostScript had been cultivated in projects for Xerox and Evans & Sutherland. Its main real-world application historically is as a page description language...
CREATE TABLE menagerie.bird ( bird_id INT NOT NULL AUTO_INCREMENT, species VARCHAR(300) DEFAULT NULL COMMENT 'You can include genus, but never subspecies.', INDEX idx_species (species) COMMENT 'We must search on species often.', PRIMARY KEY (bird_id) ) ENGINE=InnoDB COMMENT 'Thi...
Create example table Employee: CREATE TABLE Employee ( Id INT, EmpName VARCHAR(25), EmpGender VARCHAR(6), EmpDeptId INT ) Creates stored procedure that checks whether the values passed in stored procedure are not null or non empty and perform insert operation in Employee ta...

Page 485 of 826