Objective-C
Declare a slider property in the ViewController.h or in the interface of ViewController.m
@property (strong, nonatomic)UISlider *slider;
//Define frame of slider and add to view
CGRect frame = CGRectMake(0.0, 100.0, 320.0, 10.0);
UISlider *slider = [[UISlider alloc] initWithFrame:...
Consider this example:
private void button1_Click(object sender, EventArgs e)
{
label1.Text = RunTooLong();
}
This method will freeze UI application until the RunTooLong will be completed. The application will be unresponsive.
You can try run inner code asynchronously:
private void butt...
The members of a union share the same space in memory. This means that writing to one member overwrites the data in all other members and that reading from one member results in the same data as reading from all other members. However, because union members can have differing types and sizes, the da...
Install Anaconda(PyQt5 is build-in), especially for windows user.
Integrate QtDesigner and QtUIConvert in PyCharm(External Tools)
Open PyCharm Settings > Tools > External Tools
Create Tool(QtDesigner) - used to edit *.ui files
Create Tool(PyUIConv) - used to convert *.ui to *.py
...
Carthage Setup
Download the latest version of Carthage from the given link Download Link
Down in the Download section download the Carthage.pkg file.
Once the download is complete install it by double clinking on the download pkg file.
To check for successful download run the following command i...
Here I have shared a code snippet for implementing endless scrolling in recycle view.
Step 1:
First make a one abstract method in Recycleview adapter like below.
public abstract class ViewAllCategoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
public abstract void lo...
DECLARE @ID AS INT;
SET @ID = (SELECT MIN(ID) from TABLE);
WHILE @ID IS NOT NULL
BEGIN
PRINT @ID;
SET @ID = (SELECT MIN(ID) FROM TABLE WHERE ID > @ID);
END
RwLocks allow a single producer provide any number of readers with data while preventing readers from seeing invalid or inconsistent data.
The following example uses RwLock to show how a single producer thread can periodically increase a value while two consumers threads are reading the value.
use...
Customizing error messages
The /resources/lang/[lang]/validation.php files contain the error messages to be used by the validator. You can edit them as needed.
Most of them have placeholders which will be automatically replaced when generating the error message.
For example, in 'required' => '...
Catalan numbers algorithm is Dynamic Programming algorithm.
In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. The Catalan numbers on nonnegative integers n are a set of numbers t...
A palindrome is a word that can be read both ways, like 'kayak'.
This example will show how to find if a given word is a palindrome using Python3.
First, we need to turn a string into a stack (we will use arrays as stacks).
str = "string"
stk = [c for c in str] #this makes an array: [&...
According to Wikipedia:
[A] software design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve ...
Viewchild offers one way interaction from parent to child. There is no feedback or output from child when ViewChild is used.
We have a DataListComponent that shows some information. DataListComponent has PagerComponent as it's child. When user makes a search on DataListComponent, it gets a data fro...
If you want to create a custom validation rule, you can do so for instance in the boot method of a service provider, via the Validator facade.
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Validator;
class AppServiceProvider extends ServiceProvider
{
...
public class KnapsackProblem
{
private static int Knapsack(int w, int[] weight, int[] value, int n)
{
int i;
int[,] k = new int[n + 1, w + 1];
for (i = 0; i <= n; i++)
{
int b;
for (b = 0; b <= w; b++)
{
...