Tutorial by Examples: er

$ 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...
Allow change user unique ID if account is compromised with a new user&password login To invalidate tokens when user changes their password or permissions, sign the token with a hash of those fields. If any of these field change, any previous tokens automatically fail to verify. The down...
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...
If you want to use docker for rails app, and use database, you need to know that all the data in the docker container will be destroyed (unless you configure the container specifically for keeping data) Sometimes, you need to create a docker container with an application and attach it to an old con...
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...
One of most common use cases of Gitflow Initialize repo and define branches $ git flow init # if you use default setup, you'll define six types of branches: # # main branches (lives forever) # # 1. master: for production releases # 2. develop: for "next ...
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 ...
You can use Firebase Authentication to let your users authenticate with Firebase using their email addresses and passwords, and to manage your app's password-based accounts. In this example, we use these steps to set it up for our Android project which is based on JavaScript. But before doing so, ...
$rootScope.$on listeners will remain in memory if you navigate to another controller. This will create a memory leak if the controller falls out of scope. Don't angular.module('app').controller('badExampleController', badExample); badExample.$inject = ['$scope', '$rootScope']; function badExam...
Tomcat's Host Manager application by default is located at http://localhost:8080/host-manager, but is not accessible until a user is given permission in the conf/tomcat-users.xml file. The file needs to have: A manager-gui role A user with this role For example: <tomcat-users> ......
Once you have access to the host-manager, the GUI will let you add a virtual host. Note: In Tomcat 7 and 8, adding a virtual host via the GUI does not write the vhost to config files. You will need to manually edit the server.xml file to have the vhost available after a restart. See http://tomc...
Once a virtual host has been added via the web application, directories will exist at: {CATALINA_HOME}\conf\Catalina\{Name} {CATALINA_HOME}\{App Base} To persist the virtual host after a restart, the server.xml file must be updated with the configuration. A Host element needs to be added inside...
The most common usage of a child theme is to override template parts. For example, a sidebar, if we have a theme with the following file at /themes/template/sidebar.php <?php /** * The sidebar containing the main widget area. * * @link https://developer.wordpress.org/themes/basics/templa...
Steps to reset database in Heroku: 1. Drop the database, when SHARED_DATABASE_URL is used: heroku pg:reset DATABASE 2. Recreate the database with nothing in it: heroku run rake db:migrate 3. Populate the database with your seed data: heroku run rake db:seed Steps 2 and 3 can be combined...
Executing a task with the background worker. Double Click on the BackgroundWorker control from the Toolbox This is how the BackgroundWorker appears after adding it. Double click on the added control to get the BackgroundWorker1_DoWork event and add the code to be executed when the BackgroundW...
You cannot access any GUI components from the BackgroudWorker. For example if you try to do something like this Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) TextBox1.Text = "Done" End Sub you will receive a runtime error saying that "Cross-thr...
Installers are custom types that implement the IWindsorInstaller interface and are used to register Components to the container, using the fluent registration API. public class MyInstaller : IWindsorInstaller { public void Install(IWindsorContainer container, IConfigurationStore store) {...
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...
When registering a component use the Interceptors() method to specify what are the interceptors/types of interceptors to be used for this component: The TInterceptor must implement the IInterceptor interface A single interceptor by type: container.Register( Component.For<MyInterceptor>...

Page 269 of 417