Tutorial by Examples: ada

var timestamp = Math.floor(new Date(1974, 6, 25).getTime() / 1000); var hex = ('00000000' + timestamp.toString(16)).substr(-8); // zero padding var objectId = new ObjectId(hex + new ObjectId().str.substring(8));
If you know the format of the string you are converting (parsing) you should use DateTime.ParseExact Dim dateString As String = "12.07.2003" Dim dateFormat As String = "dd.MM.yyyy" Dim dateValue As Date dateValue = DateTime.ParseExact(dateString, dateFormat, Globalization.C...
Simply use the .ToString overload of a DateTime object to get the format you require: Dim dateValue As DateTime = New DateTime(2001, 03, 06) Dim dateString As String = dateValue.ToString("yyyy-MM-dd") '2001-03-06
/** * Load a class by from a ClassNode * * @param cn * ClassNode to load * @return */ public static Class<?> load(ClassNode cn) { ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); return new ClassDefiner(ClassLoader.getSystemClassLoader()).get(cn....
To copy a data.frame as a data.table, use as.data.table or data.table: DF = data.frame(x = letters[1:5], y = 1:5, z = (1:5) > 3) DT <- as.data.table(DF) # or DT <- data.table(DF) This is rarely necessary. One exception is when using built-in datasets like mtcars, which must be copi...
CREATE DATABASE LINK dblink_name CONNECT TO remote_username IDENTIFIED BY remote_password USING 'tns_service_name'; The remote DB will then be accessible in the following way: SELECT * FROM MY_TABLE@dblink_name; To test a database link connection without needing to know any of the objec...
$ IFS= read -r foo <<EOF > this is a \n line >EOF $ printf '%s\n' "$foo" this is a \n line
$ read -r foo <<EOF > this is a line >EOF $ printf '%s\n' "$foo" this is a line
For efficiency, data.table offers a way of altering a data.frame or list to make a data.table in-place: # example data.frame DF = data.frame(x = letters[1:5], y = 1:5, z = (1:5) > 3) # modification setDT(DF) Note that we do not <- assign the result, since the object DF has been modifi...
Value constructors are functions that return a value of a data type. Because of this, just like any other function, they can take one or more parameters: data Foo = Bar String Int | Biz String Let's check the type of the Bar value constructor. :t Bar prints Bar :: String -> Int -> Foo...
Type constructors can take one or more type parameters: data Foo a b = Bar a b | Biz a b Type parameters in Haskell must begin with a lowercase letter. Our custom data type is not a real type yet. In order to create values of our type, we must substitute all type parameters with actual types. Be...
As of GHC 7.10, Applicative is a superclass of Monad (i.e., every type which is a Monad must also be an Applicative). All the methods of Applicative (pure, <*>) can be implemented in terms of methods of Monad (return, >>=). It is obvious that pure and return serve equivalent purposes, ...
It can be useful to load a resource (image, text file, properties, KeyStore, ...) that is packaged inside a JAR. For this purpose, we can use the Class and ClassLoaders. Suppose we have the following project structure : program.jar | \-com \-project | |-file.txt \-Test.class ...
Sometimes specific instances of data should be used. Recreation is not desired and referencing static data would have a code smell. It is possible to specify a XmlAdapter instance the Unmarshaller should use, which allows the user to use XmlAdapters with no zero-arg constructor and/or pass data to ...
This will load a JSON file from disk and convert it to the given type. public static <T> T getFile(String fileName, Class<T> type) throws FileNotFoundException { Gson gson = new GsonBuilder() .create(); FileReader json = new FileReader(fileName); return gson....
Interface declaration for downloading a file public interface ApiInterface { @GET("movie/now_playing") Call<MovieResponse> getNowPlayingMovies(@Query("api_key") String apiKey, @Query("page") int page); // option 1: a resource relative to your bas...
When you also want to expose metadata without a config file you can build on the example programmatically creating a ServiceHost: public ConsoleHost() { mHost = new ServiceHost(typeof(Example), new Uri("http://localhost:8000/Example"), new Uri("net.tcp://9000/Example")); ...
It is possible to define a data type with field labels. data Person = Person { age :: Int, name :: String } This definition differs from a normal record definition as it also defines *record accessors which can be used to access parts of a data type. In this example, two record accessors are de...
Opening a database is an asynchronous operation. We need to send a request to open our database and then listen for events so we know when it's ready. We'll open a DemoDB database. If it doesn't exist yet, it will get created when we send the request. The 2 below says that we're asking for version...
import java.util.Scanner; Scanner s = new Scanner(System.in); int number = s.nextInt(); If you want to read an int from the command line, just use this snippet. First of all, you have to create a Scanner object, that listens to System.in, which is by default the Command Line, when you start ...

Page 5 of 12