Tutorial by Examples: c

OneGet was originally a product from the Open Source Technology Center at Microsoft. Not only is it inspired by open-source Linux package managers, OneGet itself is also open source. It's now part of PowerShell As opposed to Unix based package managers (such as apt-get, yum, or dpkg), Windows allow...
Atomic variables can be accessed concurrently between different threads without creating race conditions. /* a global static variable that is visible by all threads */ static unsigned _Atomic active = ATOMIC_VAR_INIT(0); int myThread(void* a) { ++active; // increment active race fr...
This is an example on how to call a web service from salesforce. The code below is calling a REST based service hosted on data.gov to find farmers markets close to the zipcode. Please remember in order to invoke a HTTP callout from your org, you need to tweak the remote settings for the org. strin...
Creation To create a Custom Setting, go to: Classic Setup > Develop > Custom Settings > New Lightning Setup > Custom Code > Custom Settings > New Create your setting (see the Remarks later in this document for the differences between Hierarchy & List custom settings). You...
Custom Setting Custom Setting Field Custom Setting Field Value When the field is checked the validation rule will be disabled, for the running user or in this example, their profile - The rule can also be disabled for a whole Salesforce org - Validation Rule AND( /* the below is the...
Explanation In this example a simple Trigger has been created to change the Close Date of an Opportunity, that's about to be inserted or updated, to a date 10 days in the future. The Apex Controller custom setting's checkbox field enables the code to be disabled at the user / profile / org level. ...
To obtain an instance of an HTTP Request, class Illuminate\Http\Request need to be type hint either in the constructor or the method of the controller. Example code: <?php namespace App\Http\Controllers; /* Here how we illuminate the request class in controller */ use Illuminate\Http\Re...
Sometimes we need to accept route params as well as access the HTTP Request params. We can still type hint the Requests class in laravel controller and achieve that as explained below E.g. We have a route that update a certain post like this (passing post id i route ) Route::put('post/{id}', 'Post...
import xlsxwriter # sample data chart_data = [ {'name': 'Lorem', 'value': 23}, {'name': 'Ipsum', 'value': 48}, {'name': 'Dolor', 'value': 15}, {'name': 'Sit', 'value': 8}, {'name': 'Amet', 'value': 32} ] # excel file path xls_file = 'chart.xlsx' # the workbook w...
In C, multi-line comments, /* and */, do not nest. If you annotate a block of code or function using this style of comment: /* * max(): Finds the largest integer in an array and returns it. * If the array length is less than 1, the result is undefined. * arr: The array of integers to search....
This test class will test the IsBlank(...) method of SomeClass. Below is the example SomeClass. This class has only the one, basic static method, but you will be unable to deploy it to a production instance for use until you have reached the code coverage threshold. public class SomeClass { ...
XML Data can be written as is in XQuery and will be found in the output. The following code can be considered valid XQuery : <application> <id>MyApp</id> <name>My Application</name> <version>1.0</version> </application> Note that your XQ...
To address data from an XML input, XQuery uses XPath. It makes it easy to filter data and restructure it. Given the following XML input <?xml version="1.0" encoding="UTF-8"?> <applications> <application> <id>MyApp</id> <name>My...
Resolving scoped services during application startup can be difficult, because there is no request and hence no scoped service. Resolving a scoped service during application startup via app.ApplicationServices.GetService<AppDbContext>() can cause issues, because it will be created in the sc...
Various websites provide online access to C++ compilers. Online compiler's feature set vary significantly from site to site, but usually they allow to do the following: Paste your code into a web form in the browser. Select some compiler options and compile the code. Collect compiler and/or pro...
from bs4 import BeautifulSoup import requests # Use the requests module to obtain a page res = requests.get('https://www.codechef.com/problems/easy') # Create a BeautifulSoup object page = BeautifulSoup(res.text, 'lxml') # the text field contains the source of the page # Now use a CSS ...
functions.php: function rm_init_js() { wp_enqueue_script( 'custom-ajax-script', get_template_directory_uri() . '/js/ajax.js', array( 'jquery', 'wp-util' ), '1.0', true ); // pass custom variables to JS wp_localize_script( 'custom-ajax-script', 'BEJS', array( 'action' => ...
The image contained in the ImageView may not fit the exact size given to the container. In that case, the framework allows you to resize the image in a number of ways. Center <ImageView android:layout_width="20dp" android:layout_height="20dp" andr...
Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view (minus padding). Official Docs When the image matches the proportions of the container: When the image is...
Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding). Official Docs It will center the image and resize it to the smaller size, if both container s...

Page 418 of 826