Tutorial by Examples: c

Clojure uses prefix notation, that is: The operator comes before its operands. For example, a simple sum of two numbers would be: (+ 1 2) ;; => 3 Macros allow you to manipulate the Clojure language to a certain degree. For example, you could implement a macro that let you write code in infi...
import pylab as plt import numpy as np plt.style.use('ggplot') fig = plt.figure(1) ax = plt.gca() # make some testing data x = np.linspace( 0, np.pi, 1000 ) test_f = lambda x: np.sin(x)*3 + np.cos(2*x) # plot the test data ax.plot( x, test_f(x) , lw = 2) # set the axis labels ax...
Ring is de-facto standard API for clojure HTTP applications, similar to Ruby's Rack and Python's WSGI. We're going to use it with http-kit webserver. Create new Leiningen project: lein new app myapp Add http-kit dependency to project.clj: :dependencies [[org.clojure/clojure "1.8.0&quot...
The cubic-bezier function is a transition timing function which is often used for custom and smooth transitions. transition-timing-function: cubic-bezier(0.1, 0.7, 1.0, 0.1); The function takes four parameters: cubic-bezier(P1_x, P1_y, P2_x, P2_y) These parameters will be mapped to points whic...
The following method computes the sum of integers from 0 to N using recursion. public int sum(final int n) { if (n > 0) { return n + sum(n - 1); } else { return n; } } This method is O(N) and can be reduced to a simple loop using tail-call optimization. In f...
The following method computes the value of num raised to the power of exp using recursion: public long power(final int num, final int exp) { if (exp == 0) { return 1; } if (exp == 1) { return num; } return num * power(num, exp - 1); } This illustrates ...
<root xmlns="http://test/"> <element xmlns:example="http://foobar/"> <example:hello_world attribute="another example" /> </element> </root> The expression /root will return nothing, because there is no non-namespaced ...
Any predicate function can be used as a spec. Here's a simple example: (clojure.spec/valid? odd? 1) ;;=> true (clojure.spec/valid? odd? 2) ;;=> false the valid? function will take a spec and a value and return true if the value conforms to the spec and false otherwise. One other inte...
Let's say we have the following function: (defn nat-num-count [nums] (count (remove neg? nums))) We can write a spec for this function by defining a function spec of the same name: (clojure.spec/fdef nat-num-count :args (s/cat :nums (s/coll-of number?)) :ret integer? ...
Meteor has it's own package repository on atmospherejs.com You can add new packages from atmosphere by running: meteor add [package-author-name:package-name] For example: meteor add kadira:flow-router Similarly, you can remove the same package by: meteor remove kadira:flow-router To see...
Hibernate can use two types of fetch when you are mapping the relationship between two entities: EAGER and LAZY. In general, the EAGER fetch type is not a good idea, because it tells JPA to always fetch the data, even when this data is not necessary. Per example, if you have a Person entity and th...
While there are many parameters that can be changed and variations that can be added depending on the desired functionality, this example lays out the basic framework for launching PowerPoint. Note: This code requires that the PowerPoint reference has been added to the active VBA Project. See th...
Suppose we have an interface: interface IPerson { name: string; age: number; breath(): void; } And we want to create more specific interface that has the same properties of the person, we can do it using the extends keyword: interface IManager extends IPerson { managerId:...
Install jquery via npm : npm install jquery --save Install typings for the library: To add typings for a library, do the following: typings install jquery --global --save Add jquery to angular-cli-build.js file to vendorNpmFiles array: This is required so the build system...
You can search for man pages containing a particular string in their description using: man -k <string> For example: man -k unzip Might return: man -k unzip IO::Uncompress::Bunzip2(3pm) - Read bzip2 files/buffers IO::Uncompress::Gunzip(3pm) - Read RFC 1952 files/buffers IO::Uncom...
The following terms describe different ways to case identifiers. Pascal Casing The first letter in the identifier and the first letter of each subsequent concatenated word are capitalized. You can use Pascal case for identifiers of three or more characters. For example: BackColor Camel Casing Th...
Use a signal's connect method to connect a function to a signal. When a signal is sent, each connected function is called with the sender and any named arguments the signal provides. from flask import template_rendered def log_template(sender, template, context, **kwargs): sender.logger.in...
An example XML file <Sample> <Account> <One number="12"/> <Two number="14"/> </Account> <Account> <One number="14"/> <Two number="16"/> </Account&gt...
The default Angular router allows navigation to and from any route unconditionally. This is not always the desired behavior. In a scenario where a user may conditionally be allowed to navigate to or from a route, a Route Guard may be used to restrict this behavior. If your scenario fits one of the...
File app.routes Protected routes have canActivate binded to Guard import { provideRouter, Router, RouterConfig, CanActivate } from '@angular/router'; //components import { LoginComponent } from './login/login.component'; import { DashboardComponent } from './dashboard/dashboard.component'; ...

Page 177 of 826