Tutorial by Examples: f

$ ispow2() { return $((!($1!=0&&($1&$1-1)==0))); } $ i=0 $ while [ $i -lt 100 ]; do > if ispow2 $((i=i+1)); then > echo $i > fi > done 1 2 4 8 16 32 64 $1!=0 0 is not a power of 2. ($1&$1-1)==0 Unset the lowest bit. If it was the only bit...
Remove the token from the client storage to avoid usage Tokens are issued by the server and you can not force browsers to delete a cookie/localStorage or control how external clients are managing your tokens. Obviously if attackers have stolen the token before logout they still could use the token,...
This is a simple example to search in Google. It containt two parts, Feature File Step Definition File Am not going into much details here as the code itself is self explanatory. Feature File Feature:Google Key word search @mytag Scenario: search Spec Flow in Google search bar Given...
This will download libpng from the official "git" repository and build it in your "libpng" directory. git clone https://github.com/glennrp/libpng.git libpng cd libpng ./autogen.sh ./configure [--prefix=/path] make install where "/path" points to the installation...
HtmlHelper.Action() @Html.Action(actionName: "Index") output: The HTML rendered by an action method called Index() @Html.Action(actionName: "Index", routeValues: new {id = 1}) output: The HTML rendered by an action method called Index(int id) @(Html.Action("In...
Sometimes it is necessary to do an action on repeat or in a sequence. This example will make the node fade in and out a total of 3 times. In Swift: let node = SKSpriteNode(imageNamed: "image") let actionFadeOut = SKAction.fadeOutWithDuration(1.0) let actionFadeIn = SKAction.fadeInWithD...
One helpful case is to have the action run a block of code. In Swift: let node = SKSpriteNode(imageNamed: "image") let actionBlock = SKAction.runBlock({ //Do what you want here if let gameScene = node.scene as? GameScene { gameScene.score += 5 } }) node.runActi...
To select an element by an HTML attribute that contains a specified value use the css locator pattern [attribute*=value] //selects the first element with href value that contains'cont' element(by.css('[href*="cont"]')); //selects the first element with tag h1 and class attribute that...
Sometimes users from other regions than English-speaking have problems with encoding while for example programming a php project. It can be, that the server has another encoding then UTF-8, and if someone want to create a php project in UTF-8 on this server, his text might be shown incorrect. Examp...
Let us assume we have the following Series: >>> import pandas as pd >>> s = pd.Series([1, 4, 6, 3, 8, 7, 4, 5]) >>> s 0 1 1 4 2 6 3 3 4 8 5 7 6 4 7 5 dtype: int64 Followings are a few simple things which come handy when you are workin...
Pandas provides an effective way to apply a function to every element of a Series and get a new Series. Let us assume we have the following Series: >>> import pandas as pd >>> s = pd.Series([3, 7, 5, 8, 9, 1, 0, 4]) >>> s 0 3 1 7 2 5 3 8 4 9 5 1 ...
Sometimes it maybe useful to have multiple distinct indexes of a field with different Analyzers. You can use the multi-fields capability to do so. PUT my_index { "mappings": { "user": { "properties": { "name": { "type...
A child theme is identified by WordPress when there is a directory (for example child-theme) inside /wp-content/themes/ with the following files: style.css This file must start with a comment template like this: /* Theme Name: Example Child Author: Me Author URI: https://example.com/ ...
Sometimes we have requirement of parsing pages, but doing so requires you to be an authorised user. Here is an example which shows you how to do in oracle sign in. import sys import requests import json from bs4 import BeautifulSoup def mprint(x): sys.stdout.write(x) print re...
When registering types to the container Castle uses the type of the class in order to resolve. In the case that there is more than one registration for a specific type the Name property must be set: public void Install(IWindsorContainer container, IConfigurationStore store) { container.Regist...
A Lifestyle is the "how" Castle controls the scope in which a component is used and when to clean it up. The built-in lifestyles are Singelton, Transient, PerWebRequest, Scoped, Bound, PerThread and Pooled container.Register( Component.For<IFoo>() .ImplementedBy<...
The entire idea with dependency injection is that a class does not instantiate its dependencies but requests them (through constructor or property). Using Castle the way for specifying the way to resolve a dependency is by using the DependsOn: public class Foo : IFoo { public Foo(IBar bar, st...
<ItemGroup> <FilesToDelete Include="*.tmp" /> </ItemGroup> <Delete Files="@(FilesToDelete)" />
awk '{ for(f=1; f<=NF; f++) { print $f; } }' file
1) Services A service is a constructor function that is invoked once at runtime with new, just like what we would do with plain javascript with only difference that AngularJs is calling the new behind the scenes. There is one thumb rule to remember in case of services Services are constructors...

Page 289 of 457