Tutorial by Examples: ed

JavaScript uses reference counting technique to detect unused objects. When reference count to an object is zero, that object will be released by the garbage collector. Weakmap uses weak reference that does not contribute to reference count of an object, therefore it is very useful to solve memory l...
You can write detailed signals with the [Signal (detailed = true)] attribute. public class Emitter : Object { [Signal (detailed = true)] public signal void detailed_signal (); public void emit_with_detail (string detail) { this.detailed_signal[detail] (); } } void...
Used for the RAII style acquiring of try locks, timed try locks and recursive locks. std::unique_lock allows for exclusive ownership of mutexes. std::shared_lock allows for shared ownership of mutexes. Several threads can hold std::shared_locks on a std::shared_mutex. Available from C++ 14. std:...
A shared_lock can be used in conjunction with a unique lock to allow multiple readers and exclusive writers. #include <unordered_map> #include <mutex> #include <shared_mutex> #include <thread> #include <string> #include <iostream> class PhoneBook { ...
Dim duplicateFruits = New List(Of String) From {"Grape", "Apple", "Grape", "Apple", "Grape"} 'At this point, duplicateFruits.Length = 5 Dim uniqueFruits = duplicateFruits.Distinct(); 'Now, uniqueFruits.Count() = 2 'If iterated over at this poin...
We can create dynamic component and get the instances of component into an array and finally rendered it on template. For example, we can can consider two widget component, ChartWidget and PatientWidget which extended the class WidgetComponent that I wanted to add in the container. ChartWidget.ts ...
To find your existing .cs files, right click on the project in your instance of Visual Studio, and click Open Folder in File Explorer. Visual Studio --> Your current project (Windows Form) --> Solution Explorer --> Project Name --> Right Click --> Add --> Existing Item --> ...
GitHub Flavored Markdown (sometimes abbreviated to GFM) makes it easier to work with markdown on GitHub.com. Key features of GFM include: code indentation task list support easy GitHub issue referencing automatic GitHub username and SHA detection automatic url detection emoji support GFM...
import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { Route, BrowserRouter as Router, Link, match } from 'react-router-dom'; // define React components for multiple pages class Home extends React.Component<any, any> { render() { return ( <div&g...
This solution is more involved, leveraging custom TypeScript decorators which inject match, history and/or location data into your React.Component class, which gets you full type safety without needing any type guards, as the previous example required. // Routed.ts - defines decorators import { Ro...
Code to receive Chat dialogs from Quickblox server of Logged in user (Example with listview) private void receiveChatList() { QBRequestGetBuilder requestBuilder = new QBRequestGetBuilder(); requestBuilder.setLimit(100); QBRestChatService.getChatDialogs(null, requestBuilder).performAsync( ...
This code implements a version of std::async, but it behaves as if async were always called with the deferred launch policy. This function also does not have async's special future behavior; the returned future can be destroyed without ever acquiring its value. template<typename F> auto asyn...
std::packaged_task bundles a function and the associated promise for its return type: template<typename F> auto async_deferred(F&& func) -> std::future<decltype(func())> { auto task = std::packaged_task<decltype(func())()>(std::forward<F>(func)); aut...
In general, there are two types of Bash scripts: System tools which operate from the current working directory Project tools which modify files relative to their own place in the files system For the second type of scripts, it is useful to change to the directory where the script is stored. T...
Some programming languages have its own Regex peculiarities, for example, the $+ term (in C#, Perl, VB etc.) which replaces the matched text to the last group captured. Example: using System; using System.Text.RegularExpressions; public class Example { public static void Main() { ...
How to find documents created 60 seconds ago seconds = 60 gen_time = datetime.datetime.today() - datetime.timedelta(seconds=seconds) dummy_id = ObjectId.from_datetime(gen_time) db.CollectionName.find({"_id": {"$gte": dummy_id}}) If you're in a different timezone, y...
// XSS Filtering $data = array( 'name'=> '<script>Abuse Data</script>' ); $data = $this->security->xss_clean($data); // Clean Data // Escaping Queries <?php $username = $this->input->post('username'); $query = 'SELECT * FROM subscribers_tbl ...
Given the following multi-release Jar: jar root - demo - SampleClass.class - META-INF - versions - 9 - demo - SampleClass.class The following class prints the URL of the SampleClass: package demo; import java.net.URL; public class Main...
First step : PCL part public class RoundedBoxView : BoxView { public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create("CornerRadius", typeof(double), typeof(RoundedEntry), default(double)); public double CornerRadius { get...
Use Nginx map to parse fields and reject requests. # Allowed hosts map $http_host $name { hostnames; default no; example.com yes; *.example.com yes; example.org yes; *.example.org yes; .example.net yes; wap.* yes; } # Allowed count...

Page 133 of 145