Tutorial by Examples: before

The following is handy to have in build logs that identifies the build machine, and some parameters; simply make you main task depend on this task to print it before every build. <!-- Print Environment Info --> <target name="environment"> <!-- Get the current ti...
ob_start(); $user_count = 0; foreach( $users as $user ) { if( $user['access'] != 7 ) { continue; } ?> <li class="users user-<?php echo $user['id']; ?>"> <a href="<?php echo $user['link']; ?>"> <?php echo $user...
Summary This goal is to reorganize all of your scattered commits into more meaningful commits for easier code reviews. If there are too many layers of changes across too many files at once, it is harder to do a code review. If you can reorganize your chronologically created commits into topical com...
MySQL3.19 DROP TABLE IF EXISTS MyTable; PostgreSQL8.x DROP TABLE IF EXISTS MyTable; SQL Server2005 If Exists(Select * From Information_Schema.Tables Where Table_Schema = 'dbo' And Table_Name = 'MyTable') Drop Table dbo.MyTable SQLite3.0 DROP TABLE IF EXI...
Tips & Tricks to avoid nasty situations EC2 Instances and EBS Set IAM Roles. Unlike tags, the IAM Role is set once and for all on EC2 instanciation (even after 4 years) ! Try to identify and categorize beforehand your instances so you can give an them appropriate IAM roles. IAM Roles are ...
An annotated method with @Before will be executed before every execution of @Test methods. Analogous an @After annotated method gets executed after every @Test method. This can be used to repeatedly set up a Test setting and clean up after every test. So the tests are independent and preparation cod...
The beforeFilter() method executes before any other method executes in the controller. First use the Event namespace before defining the class in your controller file. use Cake\Event\Event; In your controller, add the beforeFilter() method as shown below. public function beforeFilter(Event $ev...
Given a file file.txt with the following content: line 1 line 2 line 3 You can add a new line using below command sed '/line 2/{x;p;x;}' file.txt The above command will output line 1 line 2 line 3 Explanation: x command is eXchange. sed has a buffer that you can use to store some ...
Let's say your launch activity is called MainActivity, in your app com.example.myapp. In the manifest: <activity android:name=".MainActivity" > <intent-filter> <action android:name="android.intent.action.MAIN"/> ...
Using the document-ready event can have small performance drawbacks, with delayed execution of up to ~300ms. Sometimes the same behavior can be achieved by execution of code just before the closing </body> tag: <body> <span id="greeting"></span> world! <sc...
Usually grep prints only matching lines. In the example below seq 9 generates a list of numbers from 1 to 9, one per line, and grep prints a single matching line: seq 9 | grep 5 # 5 The -C n option (or --context=n in long form) prints n lines before and after each matching line, in addition to ...
runOutsideAngular can be used to run code outside Angular 2 so that it does not trigger change detection unnecessarily. This can be used to for example run multiple HTTP request to get all the data before rendering it. To execute code again inside Angular 2, run method of NgZone can be used. my.com...
.git/hooks/pre-commit #!/bin/sh if [ -s pom.xml ]; then echo "Running mvn verify" mvn clean verify if [ $? -ne 0 ]; then echo "Maven build failed" exit 1 fi fi
An example of "before" middleware would be as follows: <?php namespace App\Http\Middleware; use Closure; class BeforeMiddleware { public function handle($request, Closure $next) { // Perform action return $next($request); } } while &quot...
This command will save the open file with sudo rights :w !sudo tee % >/dev/null You can also map w!! to write out a file as root :cnoremap w!! w !sudo tee % >/dev/null
Description: Evaluate expression after user's confirmation. Arguments: ng-confirm-click:(expression) Expression to evaluate when confirmed. ng-confirm-message:(template) Message to be shown in confirm dialog. Code: Directives.directive("ngConfirmClick", ["$parse","...
Some people recommend that you should apply various tests to a file before attempting to open it either to provide better diagnostics or avoid dealing with exceptions. For example, this method attempts to check if path corresponds to a readable file: public static File getValidatedFile(String path...
Sometimes, one wants to run some initialization code once before testing a condition. In certain other languages, this kind of loop has special do-while syntax. However, this syntax can be replaced with a regular while loop and break statement, so Julia does not have specialized do-while syntax. Ins...
PrepareForSegue: func prepareForSegue(_ segue:UIStoryboardSegue, sender sender:AnyObject?) Notifies the view controller that a segue is about to be performed Parameters segue: The segue object. sender: The object that initialized the segue. Example in Swift Perform a task if the ident...
Get last segment echo end($this->uri->segment_array()); //it will print others Get before last segment echo $this->uri->segment(count($this->uri->segment_array())-1); //it will print how-can-i-do-this More info: [http://stackoverflow.com/questions/9221164/code-igniter-get-b...

Page 1 of 3