An example of implementation UITableView which allows to detect if cell has been tapped single or double time.
override func viewDidLoad() {
viewDidLoad()
let doubleTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleDoubleTap(sender:)))
doubleTa...
To create a background with a gradient you can use the CAGradientLayer class:
Swift 3.1:
func createGradient() {
let caLayer = CAGradientLayer()
caLayer.colors = [UIColor.white, UIColor.green, UIColor.blue]
caLayer.locations = [0, 0.5, 1]
caLayer.bounds = self.bounds
self...
To add a custom image for the thumb of the slider, simply call the setThumbImage method with your custom image:
Swift 3.1:
let slider = UISlider()
let thumbImage = UIImage
slider.setThumbImage(thumbImage, for: .normal)
multiply-square-matrix-parallel(A, B)
n = A.lines
C = Matrix(n,n) //create a new matrix n*n
parallel for i = 1 to n
parallel for j = 1 to n
C[i][j] = 0
pour k = 1 to n
C[i][j] = C[i][j] + A[i][k]*B[k][j]
return C
matrix-vector(A,x)
n = A.lines
y = Vector(n) //create a new vector of length n
parallel for i = 1 to n
y[i] = 0
parallel for i = 1 to n
for j = 1 to n
y[i] = y[i] + A[i][j]*x[j]
return y
A is an array and p and q indexes of the array such as you gonna sort the sub-array A[p..r]. B is a sub-array which will be populated by the sort.
A call to p-merge-sort(A,p,r,B,s) sorts elements from A[p..r] and put them in B[s..s+r-p].
p-merge-sort(A,p,r,B,s)
n = r-p+1
if n==1
...
Suppose we have a simple class with validation annotations
public class UserDTO {
@NotEmpty
private String name;
@Min(18)
private int age;
//getters/setters
}
A controller to check the UserDTO validity.
@RestController
public class ValidationController {
@Reque...
In following example we will create table movies with AWS Ruby SDK v2.
Here, each Movie as one unique Partition Key as id, and Range Key year. Apart from this we want to be able to query movies with their name, hence we will create a Global Secondary Index (GSI) name-year-index with name as Hash Ke...
Q-learning is a variant of model-free reinforcement learning. In Q-learning we want the agent to estimate how good a (state, action) pair is so that it can choose good actions in each state. This is done by approximating an action-value function (Q) that fits in equation below:
Where s and a are ...
So the good news is that Apple kindly includes a Ruby interpreter. Unfortunately, it tends not to be a recent version:
$ /usr/bin/ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
If you have Homebrew installed, you can get the latest Ruby with:
$ brew install ruby...
This example show you how you add new sounds to your MOD and play them. First of all you need a sound file which has the format *.ogg. Any other format is not allowed by the Minecraft application and will be rejected.
The soundfile has the name: sound1.ogg
Put the sound file under the following pa...
Run the following bash script as sudo
#!/bin/bash
# get deps
apt -y install build-essential libncurses5-dev libxml2-dev libsqlite3-dev libssl-dev libsrtp0-dev uuid-dev libjansson-dev
# download
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-14-current.tar.gz...
Ex1:-
let str1 = 'stackoverflow';
let str2 = 'flowerovstack';
These strings are anagrams.
// Create Hash from str1 and increase one count.
hashMap = {
s : 1,
t : 1,
a : 1,
c : 1,
k : 1,
o : 2,
v : 1,
e : 1,
r : 1,
f : 1,
l : 1,
w : 1...
(function(){
var hashMap = {};
function isAnagram (str1, str2) {
if(str1.length !== str2.length){
return false;
}
// Create hash map of str1 character and increase value one (+1).
createStr1HashMap(str1);
/...
You get this exception mostly with form submissions. Laravel protects application from CSRF and validates every request and ensures the request originated from within the application. This validation is done using a token. If this token mismatches this exception is generated.
Quick Fix
Add this wi...