If we have a c++ project that uses a config.h configuration file with some custom paths or variables, we can generate it using CMake and a generic file config.h.in.
The config.h.in can be part of a git repository, while the generated file config.h will never be added, as it is generated from the cu...
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* Get the user's first name.
*
* @param string $value
* @return string
*/
public function getFirstNameAttribute($value)
{
return ucfirst($v...
Basic foreground images can be inserted into an email document just like they are for web pages:
<img src="http://www.yourserver.com/email/images/logo.png">
And they can be made links by wrapping them in an <a href> tag:
<a href="http://www.yourwebsite.com">...
Comparator cmp = [ compare:{ a, b -> a <=> b } ] as Comparator
def col = [ 'aa', 'aa', 'nn', '00' ]
SortedSet sorted = new TreeSet( cmp )
sorted.addAll col
assert '[00, aa, nn]' == sorted.toString()
my @letters = ( 'a' .. 'z' ); # English ascii-bet
print $letters[ rand @letters ] for 1 .. 5; # prints 5 letters at random
How it works
rand EXPR expects a scalar value, so @letters is evaluated in scalar context
An array in scalar context returns the number of elements it ...
The series of events here is supposed to work as follows:
Compile code with -pg option
Link code with -pg option
Run program
Program generates gmon.out file
Run gprof program
To add profiling flags, you must add to your CMakeLists.txt:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg"...
You can use
Map<String, List<String>> myMap = new HashMap<>();
instead of
Map<String, List<String>> myMap = new HashMap<String, List<String>>();
However, you can't use
List<String> list = new ArrayList<>();
list.add("A");
...
public String getTypeOfDayWithSwitchStatement(String dayOfWeekArg) {
String typeOfDay;
switch (dayOfWeekArg) {
case "Monday":
typeOfDay = "Start of work week";
break;
case "Tuesday":
case "Wednes...
If you are using Windows open Git Bash.
If you are using Mac or Linux open your Terminal.
Before you generate an SSH key, you can check to see if you have any existing SSH keys.
List the contents of your ~/.ssh directory:
$ ls -al ~/.ssh
# Lists all the files in your ~/.ssh directory
Check...
If shift is called outside of a delimiting reset block, it can be used to create functions that themselves create continuations inside a reset block. It is important to note that shift's type is not just (((A => B) => C) => A), it is actually (((A => B) => C) => (A @cpsParam[B, C])...
We can have three cases to analyze an algorithm:
Worst Case
Average Case
Best Case
#include <stdio.h>
// Linearly search x in arr[]. If x is present then return the index,
// otherwise return -1
int search(int arr[], int n, int x)
{
int i;
for (i=0; i<n; i...
Not everything in a bindings library will have the same name in C# as it does in Java.
In C#, interface names start with "I", but Java has no such convention. When you import a Java library, an interface named SomeInterface will become ISomeInterface.
Similarly, Java doesn't have propert...
In order to create a workspace, one should run the following in the terminal:
$ mkdir -p ~/workspace_name/src
$ cd ~/workspace_name/src
$ catkin_init_workspace
$ cd ~/workspace_name/
$ catkin_make
The previous commands creates a workspace named workspace_name. Once a workspace has been creat...
Assuming a workspace named workspace_name has been previously created in the home directory, a package named package_name can be created by executing the following command lines.
$ cd ~/workspace_name/src/
$ catkin_create_pkg package_name rospy
A statement is usually a test on a variable or the return value of a function. To test those values, we can use some relational operators:
OperatorMeaningExample==Equal to1 == 1 is TRUE, 1 == 2 is FALSE!=Not equal to1 != 2 is TRUE, 1 != 1 is FALSE<Less than1 < 2 is TRUE, 2 < 1 is FALSE>...
std::integer_sequence itself is about holding a sequence of integers which can be turned into a parameter pack. Its primary value is the possibility to create "factory" class templates creating these sequences:
#include <iostream>
#include <initializer_list>
#include <uti...
The phpunit.xml file is the default configuration file for tests and is already setup for testing with PHPUnit.
The default testing environment APP_ENV is defined as testing with array being the cache driver CACHE_DRIVER. With this setup, no data (session/cache) will be retained while testing.
T...
Declaring the splat is useful for reusing sets of parameters multiple times or with slight variations:
$splat = @{
Class = "Win32_SystemEnclosure"
Property = "Manufacturer"
ErrorAction = "Stop"
}
Get-WmiObject -ComputerName $env:COMPUTERNAME @splat
Get...
CSS variables cascade in much the same way as other properties, and can be restated safely.
You can define variables multiple times and only the definition with the highest specificity will apply to the element selected.
Assuming this HTML:
<a class="button">Button Green</a>...