Tutorial by Examples: sin

So here, I have removed the for loops, and made a timeout by adding a second case to the select that returns after 3 seconds. Because the select just waits until ANY case is true, the second case fires, and then our script ends, and chatter() never even gets a chance to finish. // Use of the select...
In the logging configuration file of your choice set the logging of the following packages to the levels shown.: # log the sql statement org.hibernate.SQL=DEBUG # log the parameters org.hibernate.type=TRACE There will probably be some logger specific prefixes that are required. Log4j config:...
This will show you the generated SQL, but will not show you the values contained within the queries. <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="hibernateProperties"> <p...
Lazy evaluation means Haskell will evaluate only list items whose values are needed. The basic recursive definition is: f (0) <- 0 f (1) <- 1 f (n) <- f (n-1) + f (n-2) If evaluated directly, it will be very slow. But, imagine we have a list that records all the results, fibs ...
The first thing we need to do it add EventBus to our module's gradle file: dependencies { ... compile 'org.greenrobot:eventbus:3.0.0' ... } Now we need to create a model for our event. It can contain anything we want to pass along. For now we'll just make an empty class. public ...
- name: copy ssl key/cert/ssl_include files copy: src=files/ssl/{{ item }} dest=/etc/apache2/ssl/ with_items: - g_chain.crt - server.crt - server.key - ssl_vhost.inc
POSIX/IEEE Open Group Base Specification says: [2addr] s/BRE/replacement/flags Substitute the replacement string for instances of the BRE in the pattern space. Any character other than backslash or newline can be used instead of a slash to delimit the BRE and the replacement. Within the BRE a...
Coming from imperative languages many developers wonder how to write a for-loop that exits early as F# doesn't support break, continue or return. The answer in F# is to use tail-recursion which is a flexible and idiomatic way to iterate while still providing excellent performance. Say we want to ...
The following function is returning another function as its result which can be later assigned to a variable and called: func jediTrainer () -> ((String, Int) -> String) { func train(name: String, times: Int) -> (String) { return "\(name) has been trained in the Force \(times)...
The Oracle Java Style Guide states: Modifiers should not be written out when they are implicit. (See Modifiers in Oracle Official Code Standard for the context and a link to the actual Oracle document.) This style guidance applies particularly to interfaces. Let's consider the following code ...
A typical use case for SpriteKit is where the SKView fills the whole screen. To do this in Xcode's Interface Builder, first create a normal ViewController, then select the contained view and change its Class from UIView to SKView: Within the code for the View Controller, in the viewDidLoad metho...
Const baseString As String = "Hello World" Dim charLength As Long charLength = Len(baseString) 'charlength = 11
Const baseString As String = "Hello World" Dim byteLength As Long byteLength = LenB(baseString) 'byteLength = 22
Const string1 As String = "foo" Const string2 As String = "bar" Const string3 As String = "fizz" Dim concatenatedString As String 'Concatenate two strings concatenatedString = string1 & string2 'concatenatedString = "foobar" 'Concatenate three s...
'Declare and assign a string array Dim widgetNames(2) As String widgetNames(0) = "foo" widgetNames(1) = "bar" widgetNames(2) = "fizz" 'Concatenate with Join and separate each element with a 3-character string concatenatedString = VBA.Strings.Join(widgetNames, &q...
The purpose of this example is to show how we can realize the Strategy pattern using Java 8 functional interfaces. We will start with a simple use case codes in classic Java, and then recode it in the Java 8 way. The example problem we using is a family of algorithms (strategies) that describe dif...
With the appropriate storage backend running a new titan graph can be initialised via: graph = TitanFactory.open("config.properties"); Wehere config.properties defines several configurations relevant to the storage backend. Titan provides some sample configs in its downloadable package...
#!/usr/bin/env perl use strict; use warnings 'all'; use XML::Twig; my $twig = XML::Twig->parse( \*DATA ); #we can use the 'root' method to find the root of the XML. my $root = $twig->root; #first_child finds the first child element matching a value. my $title = $root->firs...
Pseudo-elements are often used to change the look of lists (mostly for unordered lists, ul). The first step is to remove the default list bullets: ul { list-style-type: none; } Then you add the custom styling. In this example, we will create gradient boxes for bullets. li:before { conte...
The default gnuplot command plot (also only p) plot dataset with columns, of the form of the data_set.dat file below. # Prototype of a gnuplot data set # data_set.dat # X - X^2 - 2*X - Random 0 0 0 5 1 1 2 15 1.4142 2 2.8284 1 2 ...

Page 55 of 161