Tutorial by Examples: by

To fetch the latest version of an item in the current language: Sitecore.Context.Database.GetItem("/sitecore/content/Sitecore")
The difference between size and count is: size counts NaN values, count does not. df = pd.DataFrame( {"Name":["Alice", "Bob", "Mallory", "Mallory", "Bob" , "Mallory"], "City":["Seattle", &q...
First: The path structure If you don't have it you need to create the middleware folder within your app following the structure: yourproject/yourapp/middleware The folder middleware should be placed in the same folder as settings.py, urls, templates... Important: Don't forget to create the ini...
explode and strstr are simpler methods to get substrings by separators. A string containing several parts of text that are separated by a common character can be split into parts with the explode function. $fruits = "apple,pear,grapefruit,cherry"; print_r(explode(",",$fruits))...
int x = 5 / 0; // Undefined behavior Division by 0 is mathematically undefined, and as such it makes sense that this is undefined behavior. However: float x = 5.0f / 0.0f; // x is +infinity Most implementation implement IEEE-754, which defines floating point division by zero to return N...
It is not possible to use eval or exec to execute code from untrusted user securely. Even ast.literal_eval is prone to crashes in the parser. It is sometimes possible to guard against malicious code execution, but it doesn't exclude the possibility of outright crashes in the parser or the tokenizer....
If you want to see the generated bytecode for a Java program, you can use the provided javap command to view it. Assuming that we have the following Java source file: package com.stackoverflow.documentation; import org.springframework.stereotype.Service; import java.io.IOException; import j...
SP.SOD.executeOrDelayUntilScriptLoaded(myFunction,"sp.js"); function myFunction(){ var clientContext = new SP.ClientContext(); var list = clientContext.get_web().get_lists().getByTitle("List Title"); var item = list.getItemById(1); // get item with ID == 1 ...
Basic Example Use the set_viewXml method of the SP.CamlQuery object to specify a CAML query to retrieve items. SP.SOD.executeOrDelayUntilScriptLoaded(showListItems,"core.js"); function showListItems(){ var clientContext = new SP.ClientContext(); var list = clientContext.get_...
In JavaScript all arguments are passed by value. When a function assigns a new value to an argument variable, that change will not be visible to the caller: var obj = {a: 2}; function myfunc(arg){ arg = {a: 5}; // Note the assignment is to the parameter variable itself } myfunc(obj); conso...
Let's say that we want to have an alternative greeting that is accessible through a different URL. We might create a new function or even a new controller for that, but a best practice is to optimize what we already have, to make it work at it's best! To do this, we'll keep the same view as in the ...
To get template item by template Id. TemplateItem templateItem = Sitecore.Context.Database.GetTemplate(new ID("{11111111-1111-1111-1111-111111111111}"));
Input the name of the template to get the template by using GetTemplate Method. TemplateItem templateItem = Sitecore.Context.Database.GetTemplate("NameOfTheTemplate");
Declare a BluetoothAdapter first. BluetoothAdapter mBluetoothAdapter; Now create a BroadcastReceiver for ACTION_FOUND private final BroadcastReceiver mReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); //...
/// <summary> /// Gets a BackgroundTask by its name /// </summary> /// <param name="taskName">Name of the task to find</param> /// <returns>The found Task or null if none found</returns> public BackgroundTaskRegistration TaskByName(string taskName) ...
GROUP BY is used in combination with aggregation functions. Consider the following table: orderIduserIdstoreNameorderValueorderDate143Store A2520-03-2016257Store B5022-03-2016343Store A3025-03-2016482Store C1026-03-2016521Store A4529-03-2016 The query below uses GROUP BY to perform aggregated calc...
We start off with $db, an instance of the PDO class. After executing a query we often want to determine the number of rows that have been affected by it. The rowCount() method of the PDOStatement will work nicely: $query = $db->query("DELETE FROM table WHERE name = 'John'"); $count = ...
Some API calls return a single failure/success flag, without any additional information (e.g. GetObject): if ( GetObjectW( obj, 0, NULL ) == 0 ) { // Failure: no additional information available. }
Start with iter() built-in to get iterator over iterable and use next() to get elements one by one until StopIteration is raised signifying the end: s = {1, 2} # or list or generator or even iterator i = iter(s) # get iterator a = next(i) # a = 1 b = next(i) # b = 2 c = next(i) # raises S...
When you are copying a string into a malloced buffer, always remember to add 1 to strlen. char *dest = malloc(strlen(src)); /* WRONG */ char *dest = malloc(strlen(src) + 1); /* RIGHT */ strcpy(dest, src); This is because strlen does not include the trailing \0 in the length. If you take the ...

Page 5 of 23