Tutorial by Examples: sin

To broaden the selections of a structured query language (SQL-SELECT) statement, wildcard characters, the percent sign (%) and the underscore (_), can be used. The _ (underscore) character can be used as a wildcard for any single character in a pattern match. Find all employees whose Fname start w...
Variables inside single quotes ' don't get expanded by POSIX compatible shells, so using a shell variable in a sed substitution requires the use of double quotes " instead of single quotes ': $ var="he" $ echo "hello" | sed "s/$var/XX/" XXllo $ var="he&q...
If you want to add custom.js script that is located in the js/ folder of your theme, you'll need to enqueue it. In functions.php add <?php add_action( 'after_setup_theme', 'yourtheme_theme_setup' ); if ( ! function_exists( 'yourtheme_theme_setup' ) ) { function yourtheme_theme_setup()...
A popular form of data analysis is split-apply-combine, in which you split your data into groups, apply some sort of processing on each group, and then combine the results. Let's consider a data analysis where we want to obtain the two cars with the best miles per gallon (mpg) for each cylinder cou...
Once you've got all your settings, you'll want to use them in your code. To do so, add the following import to your file: from django.conf import settings You may then access your settings as attributes of the settings module, for example: if not settings.DEBUG: email_user(user, message) ...
It's a bad idea to hard code paths in your application. One should always use relative urls so that your code can work seamlessly across different machines. The best way to set this up is to define a variable like this import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) Then use th...
Using environment variables is a widely used way to setting an app's config depending on it environment, as stated in The Twelve-Factor App. As configurations are likely to change between deployment environments, this is a very interesting way to modify the configuration without having to dig in th...
Joins can also be used in an UPDATE statement: CREATE TABLE Users ( UserId int NOT NULL, AccountId int NOT NULL, RealName nvarchar(200) NOT NULL ) CREATE TABLE Preferences ( UserId int NOT NULL, SomeSetting bit NOT NULL ) Update the SomeSetting column of the Prefere...
connection.Execute(@"some Query with @a,@b,@c", new {a=somevalueOfa,b=somevalueOfb,c=somevalueOfc});
You can reference models in a seeder. use DB; use App\Models\User; class UserTableSeeder extends Illuminate\Database\Seeder{ public function run(){ # Remove all existing entrie DB::table('users')->delete() ; User::create([ 'name' => 'Admin', ...
We can provide a consumer that will be called with the multiple relevant values: C++11 template <class F> void foo(int a, int b, F consumer) { consumer(a + b, a - b, a * b, a / b); } // use is simple... ignoring some results is possible as well foo(5, 12, [](int sum, int , int , i...
You can access the elements of an array by their indices. Array index numbering starts at 0. %w(a b c)[0] # => 'a' %w(a b c)[1] # => 'b' You can crop an array using range %w(a b c d)[1..2] # => ['b', 'c'] (indices from 1 to 2, including the 2) %w(a b c d)[1...2] # => ['b'] (indic...
One of the first questions people have when they begin to use PowerShell for scripting is how to manipulate the output from a cmdlet to perform another action. The pipeline symbol | is used at the end of a cmdlet to take the data it exports and feed it to the next cmdlet. A simple example is using...
MKLocalSearch allows users to search for location using natural language strings like "gym". Once the search get completed, the class returns a list of locations within a specified region that match the search string. Search results are in form of MKMapItem within MKLocalSearchResponse ob...
The MATLAB Profiler is a tool for software profiling of MATLAB code. Using the Profiler, it is possible to obtain a visual representation of both execution time and memory consumption. Running the Profiler can be done in two ways: Clicking the "Run and Time" button in the MATLAB GUI...
One might want to group their data by the runs of a variable and perform some sort of analysis. Consider the following simple dataset: (dat <- data.frame(x = c(1, 1, 2, 2, 2, 1), y = 1:6)) # x y # 1 1 1 # 2 1 2 # 3 2 3 # 4 2 4 # 5 2 5 # 6 1 6 The variable x has three runs: a run of l...
Option Explicit Sub LoopAllSheets() Dim sht As Excel.Worksheet ' declare an array of type String without committing to maximum number of members Dim sht_Name() As String Dim i As Integer ' get the number of worksheets in Active Workbook , and put it as the maximum number of members in t...
.reverse is used to reverse the order of items inside an array. Example for .reverse: [1, 2, 3, 4].reverse(); Results in: [4, 3, 2, 1] Note: Please note that .reverse(Array.prototype.reverse) will reverse the array in place. Instead of returning a reversed copy, it will return the same ar...
if ($PSCmdlet.ShouldProcess("Target of action")) { # Do the thing } When using -WhatIf: What if: Performing the action "Invoke-MyCmdlet" on target "Target of action" When using -Confirm: Are you sure you want to perform this action? Performing operation &qu...
-- The following assumes that trim module is installed or in the caller's package.path, -- which is a built-in variable that Lua uses to determine where to look for modules. local trim = require "trim" local msg = " Hello, world! " local cleaned = trim.trim_all(msg)...

Page 17 of 161