The following are instructions to setup latest version of Varnish on various Linux distros.
CentOS 7
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish5/script.rpm.sh | sudo bash
Ubuntu
apt-get install apt-transport-https
curl https://repo.varnish-cache.org/GPG-key.txt ...
"alpha" is used to specify the opacity for an image.
set alpha using XML attribute:
android:alpha="0.5"
Note: takes float value from 0 (transparent) to 1 (fully visible)
set alpha programmatically:
imgExample.setAlpha(0.5f);
If you want to show local notification immediately, you should call:
Swift 3
UIApplication.shared.presentLocalNotificationNow(notification)
Swift 2
UIApplication.sharedApplication().presentLocalNotificationNow(notification)
Objective-C
[[UIApplication sharedApplication] presentLocalNotific...
Create a new Console Application
Add the NuGet package Microsoft.CodeAnalysis
Import the namespaces Microsoft.CodeAnalysis.MSBuild, System.Linq and Microsoft.CodeAnalysis.CSharp.Syntax
Write the following example code in the Main method:
// Declaring a variable with the current project file ...
Create a new console application with one line in the Main method: Console.WriteLine("Hello World")
Remember the path to the .csproj file and replace it in the example.
Create a new Console Application and install the Microsoft.CodeAnalysis NuGet package and try the following code:
cons...
Create a new console application with one line in the Main method: Console.WriteLine("Hello World")
Remember the path to the .vbproj file and replace it in the example.
Create a new Console Application and install the Microsoft.CodeAnalysis NuGet package and try the following code:
Cons...
Less has been one of the most popular CSS Pre-processors, and has also been widely deployed in numerous front-end frameworks like Bootstrap, Foundation, etc. The Less Compiler is a JavaScript based compiler, which can be obtained from a Content Delivery Network:
<script src="//cdnjs.cloudfl...
In the below example value in map $color-array is treated as list of pairs.
SCSS Input
$color-array:(
black: #4e4e4e,
blue: #0099cc,
green: #2ebc78
);
@each $color-name, $color-value in $color-array {
.bg-#{$color-name} {
background: $color-value;
}
}
...
Specifying the -gui command line option when running an ANTLR grammar in the test rig will result in a window popping up with a visual representation of the parse tree. For example:
Given the following grammar:
JSON.g4
/** Taken from "The Definitive ANTLR 4 Reference" by Terence Parr */...
Due to the vulnerability caused by CSRF, it is generally considered a good practice to check for an AntiForgeryToken on all HttpPosts unless there is a good reason to not do it (some technical issue with the post, there is another authentication mechanism and/or the post does not mutate state like s...
For a 12hour time format one can use:
^(?:0?[0-9]|1[0-2])[-:][0-5][0-9]\s*[ap]m$
Where
(?:0?[0-9]|1[0-2]) is the hour
[-:] is the separator, which can be adjusted to fit your need
[0-5][0-9] is the minute
\s*[ap]m followed any number of whitespace characters, and am or pm
If you need th...
PresenceOf - Validates that a value is not null or empty string
$validator->add('name', new \Phalcon\Validation\Validator\PresenceOf([
'message' => 'The name is required'
]));
Email - Checks if a value has a correct e-mail format
$validator->add('email', new \Phalcon\Validation\Va...
Consider the following code as an illustration:
public String joinWords(List<String> words) {
String message = "";
for (String word : words) {
message = message + " " + word;
}
return message;
}
Unfortunate this code is inefficient if the w...
For most GNU/Linux distributions, a version of GnuCOBOL is available in the repositories. GnuCOBOL was originally OpenCOBOL, rebranded when the project became an official GNU project. Many repositories are still using open-cobol as the package name (as of August 2016).
For Fedora, and other RPM b...
A spring bean can be configured such that it will register only if it has a particular value or a specified property is met. To do so, implement Condition.matches to check the property/value:
public class PropertyCondition implements Condition {
@Override
public boolean matches(ConditionC...
By default:
Use val, not var, wherever possible. This allows you to take seamless advantage of a number of functional utilities, including work distribution.
Use recursion and comprehensionss, not loops.
Use immutable collections. This is a corrolary to using val whenever possible.
Focus on da...
If all you need is to wrap the value into a promise, you don't need to use the long syntax like here:
//OVERLY VERBOSE
var defer;
defer = $q.defer();
defer.resolve(['one', 'two']);
return defer.promise;
In this case you can just write:
//BETTER
return $q.when(['one', 'two']);
$q.when ...
C-h t runs the function help-with-tutorial, which opens a buffer containing a tutorial on the basic editing functionality of emacs, including moving around in text, and working with files, buffers, and windows.
Another powerful & mature concurrency tool in Haskell is Software Transactional Memory, which allows for multiple threads to write to a single variable of type TVar a in an atomic manner.
TVar a is the main type associated with the STM monad and stands for transactional variable. They're used m...