问:
Handle Exception in ResponsesEntity java
I wonder how to handle exception in ResponsesEntity.
When it receive wrong url, it supposes to go to the catch block and display the log. But I keep getting error message in console. The try-catch not working as it not display log message.

```<code>@GetMapping("abc/{Id}")
    public ResponseEntity info(@PathVariable("Id") String id) {
        HttpEntity httpEntity = new HttpEntity(buildHttpHeaders());
        String theUrl = url + "/xxx/transactions/" +id;
        ResponseEntity<TDto> responseEntity = restTemplate.exchange(theUrl, HttpMethod.GET, httpEntity, TDto.class);
        TDto tdto = responseEntity.getBody();
        Tran tran = new Tran();
        try {
              tran.setDate(new Date());
              tran.saveAndFlush(tran); // save to database
        }catch(Exception e)
        {
            log.info("Log: "+e);
        }
        return responseEntity;
    }
</code>```

Error

```<code>org.springframework.web.client.HttpClientErrorException: 404 Not Found
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:63)
    at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531)
    at com.rh.tranglo.controller.ApiController.retrieveTransactionInfo(ApiController.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
</code>```

Is there a way to handle exception by displaying the log in catch block?

答:
You didn't actually included responseEntity in your try-catch. try-catch will catch only exceptions that are within try { // all exceptions in between parenthesis will be caught }

```<code>@GetMapping("abc/{Id}")
public ResponseEntity info(@PathVariable("Id") String id) {
try {
    HttpEntity httpEntity = new HttpEntity(buildHttpHeaders());

    String theUrl = url + "/xxx/transactions/" +id;
    ResponseEntity<TDto> responseEntity = restTemplate.exchange(theUrl,
    HttpMethod.GET, httpEntity, TDto.class);
    TDto tdto = responseEntity.getBody();
    Tran tran = new Tran();

          tran.setDate(new Date());
          tran.saveAndFlush(tran); // save to database
     }catch(Exception e)
    {
        log.info("Log: "+e);
    }
    return responseEntity;
}
</code>```

It should look more like something like this if you want to catch throws from responseEntity , But in your case only exceptions thrown by this ones will be caught:

```<code>try {
          tran.setDate(new Date()); -> this will throw exceptions(very unlikely)
          tran.saveAndFlush(tran); -> or this will throw exceptions,
    }
</code>```

And any other exceptions won't be caught

Body:
I wonder how to handle exception in ResponsesEntity.
When it receive wrong url, it supposes to go to the catch block and display the log. But I keep getting error message in console. The try-catch not working as it not display log message.

@GetMapping("abc/{Id}")
    public ResponseEntity info(@PathVariable("Id") String id) {
        HttpEntity httpEntity = new HttpEntity(buildHttpHeaders());
        String theUrl = url + "/xxx/transactions/" +id;
        ResponseEntity<TDto> responseEntity = restTemplate.exchange(theUrl, HttpMethod.GET, httpEntity, TDto.class);
        TDto tdto = responseEntity.getBody();
        Tran tran = new Tran();
        try {
              tran.setDate(new Date());
              tran.saveAndFlush(tran); // save to database
        }catch(Exception e)
        {
            log.info("Log: "+e);
        }
        return responseEntity;
    }

Error

org.springframework.web.client.HttpClientErrorException: 404 Not Found
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:63)
    at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:531)
    at com.rh.tranglo.controller.ApiController.retrieveTransactionInfo(ApiController.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)

Is there a way to handle exception by displaying the log in catch block?

Body:
You didn't actually included responseEntity in your try-catch. try-catch will catch only exceptions that are within try { // all exceptions in between parenthesis will be caught }

@GetMapping("abc/{Id}")
public ResponseEntity info(@PathVariable("Id") String id) {
try {
    HttpEntity httpEntity = new HttpEntity(buildHttpHeaders());

    String theUrl = url + "/xxx/transactions/" +id;
    ResponseEntity<TDto> responseEntity = restTemplate.exchange(theUrl,
    HttpMethod.GET, httpEntity, TDto.class);
    TDto tdto = responseEntity.getBody();
    Tran tran = new Tran();

          tran.setDate(new Date());
          tran.saveAndFlush(tran); // save to database
     }catch(Exception e)
    {
        log.info("Log: "+e);
    }
    return responseEntity;
}

It should look more like something like this if you want to catch throws from responseEntity , But in your case only exceptions thrown by this ones will be caught:

try {
          tran.setDate(new Date()); -> this will throw exceptions(very unlikely)
          tran.saveAndFlush(tran); -> or this will throw exceptions,
    }

And any other exceptions won't be caught


来源: stackexchange

问:
jQuery Ajax get value via function?
I have created a save(id) function that will submit ajax post request. When calling a save(id). How to get value/data from save(id) before going to next step. How to solve this?

For example:

```<code>        function save(id) {
            $.ajax({
                type: "POST",
                url: "/post/",
                dataType: "json",
                contentType: 'application/json',
                data: JSON.stringify({
                    id: id,
                }),
                success: function (data) {
                 return data;
                },
                error: function (error) {
                return data;
                }
            });
        }
</code>```

Usage:

```<code>$('.btn-create').click(function () {
  var id = 123;
  data = saveArea(id); //get data from ajax request or error data?
  if (data) {
     window.location = "/post/" + data.something
  }
}
</code>```

答:
Just make things a bit simpler.

For starters just add window.location = "/post/" + data.something to the success callback.
Like this:

```<code>function save(id) {
    return $.ajax({
        type: "POST",
        url: "/post/",
        dataType: "json",
        contentType: 'application/json',
        data: JSON.stringify({
            id: id,
        }),
        success:function(data){
            window.location = "/post/" + data.something
        }
    }).responseText;
}
</code>```

Or by adding all your Ajax code within the click event.

```<code>$('.btn-create').click(function () {
   var id = "123";

   $.ajax({
    type: "POST",
    url: "/post/",
    dataType: "json",
    contentType: 'application/json',
    data: JSON.stringify({
        id: id,
    }),
    success: function (data) {
     window.location = "/post/" + data.something
    },
    error: function (error) {
      console.log(error)
    }
  });

}
</code>```

ContentLicense: CC BY-SA 3.0

Title: jQuery Ajax get value via function?

Body:
I have created a save(id) function that will submit ajax post request. When calling a save(id). How to get value/data from save(id) before going to next step. How to solve this?

For example:

        function save(id) {
            $.ajax({
                type: "POST",
                url: "/post/",
                dataType: "json",
                contentType: 'application/json',
                data: JSON.stringify({
                    id: id,
                }),
                success: function (data) {
                 return data;
                },
                error: function (error) {
                return data;
                }
            });
        }

Usage:

$('.btn-create').click(function () {
  var id = 123;
  data = saveArea(id); //get data from ajax request or error data?
  if (data) {
     window.location = "/post/" + data.something
  }
}

Body:
Just make things a bit simpler.

For starters just add window.location = "/post/" + data.something to the success callback.
Like this:

function save(id) {
    return $.ajax({
        type: "POST",
        url: "/post/",
        dataType: "json",
        contentType: 'application/json',
        data: JSON.stringify({
            id: id,
        }),
        success:function(data){
            window.location = "/post/" + data.something
        }
    }).responseText;
}

Or by adding all your Ajax code within the click event.

$('.btn-create').click(function () {
   var id = "123";

   $.ajax({
    type: "POST",
    url: "/post/",
    dataType: "json",
    contentType: 'application/json',
    data: JSON.stringify({
        id: id,
    }),
    success: function (data) {
     window.location = "/post/" + data.something
    },
    error: function (error) {
      console.log(error)
    }
  });

}


问:
Pointing sub domain only to AWS EC2 instance?
I am trying to migrate a PHP site to AWS.

I have created an instance with a specific AWS url and have configured an AWS Route 53 service.

Looking at the docs here: http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html#root-domain-walkthrough-update-ns-record

It says to update the Nameservers for the particular domain, however that would affect the live version of the site which is still being hosted on Digital Ocean.

What I want to do is:

Point a subdomain e.g. dev.mysite.com to the dev environment on AWS

Check everything is ok

Create a live environment on AWS

Point mysite.com to the live environment.

I am still new to this way of hosting, is what I am trying to achieve, feasible.

Or is there another way I should be tackling this.

Any suggestions welcome.

Thanks

答:
That's absolutely fine. Within Route 53, you can create an a record for your Apex (www.site.com) to point to your EC2 (?) instance, and then another CNAME record which points to your dev.site.com

Note that Alias records are free, and the preferred way of doing the above, but only work with certain types of AWS resources such as ELBs.


问:
"The type org.openqa.selenium.remote.http.HttpClient$Factory cannot be resolved." error message in selenium script
I'm trying to build a testing framework for an android application using selenium webdriver on eclipse and Appium. I'm not using Maven. The initial script to launch the app is as follows:

package executionEngine;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import io.appium.java_client.android.AndroidDriver;

public class DriverScript {

 public static AndroidDriver driver = null;

 public static void main(String[] args) throws MalformedURLException {
  // TODO Auto-generated method stub

  File app = new File(System.getProperty("user.dir")+"\\BP_QASTG.apk");

  // Created object of DesiredCapabilities class.

    DesiredCapabilities capabilities = new DesiredCapabilities();
    //capabilities.setCapability(CapabilityType.BROWSER_NAME,"");

    // Set android deviceName desired capability. Set your device name.
    capabilities.setCapability("deviceName", "Galaxy Tab A");

    // Set android VERSION desired capability. Set your mobile device's OS version.
    capabilities.setCapability(CapabilityType.VERSION, "6.0.2");

    // Set android platformName desired capability. It's Android in our case here.
    capabilities.setCapability("platformName", "Android");

    // Set android appPackage desired capability. It is

    capabilities.setCapability("appPackage", "com.rivigo.zoombp.rivigozoombpapp");

    // Set android appActivity desired capability. It is

    capabilities.setCapability("appActivity", "com.rivigo.zoombp.rivigozoombpapp.activity.Activity.RivigoHomeActivity");
    capabilities.setCapability("app", app.getAbsolutePath());

    // Set appium server address and port number in URL string.
    //AndroidDriver  driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
   driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
   //driver = (AndroidDriver)((new URL("http://127.0.0.1:4723/wd/hub"), capabilities));
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

 }

}```

In the above code, the line where I declare the URL is marked in RED and hovering over it shows me this message: "The type org.openqa.selenium.remote.http.HttpClient$Factory cannot be resolved. It is indirectly referenced from required .class files"

I have seen many answers asking to add required jar files; but I'm sure I have added all the jar files required. It would be great if anyone can point out the particular jar file I might have missed,if indeed that is the issue, so that I can download and add it separately.

I have seen other answers asking to remove and re-add the JRE system library or close and repair the project, etc. which did not work for me.

I have tried with eclipse-neon and eclipse-mars versions also.
Please ask for any details you need,

I'm blocked here for quite sometime,
help on this would be appreciated,

Thanks,
Rahul

答:
Add the below maven dependency to your pom.xml to resolve the issue.</p>

```<code><dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-remote-driver</artifactId>
    <version>3.4.0</version>
</dependency>
</code>```

Body:
I'm trying to build a testing framework for an android application using selenium webdriver on eclipse and Appium. I'm not using Maven. The initial script to launch the app is as follows:

package executionEngine;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import io.appium.java_client.android.AndroidDriver;

public class DriverScript {

 public static AndroidDriver driver = null;

 public static void main(String[] args) throws MalformedURLException {
  // TODO Auto-generated method stub

  File app = new File(System.getProperty("user.dir")+"\\BP_QASTG.apk");

  // Created object of DesiredCapabilities class.

    DesiredCapabilities capabilities = new DesiredCapabilities();
    //capabilities.setCapability(CapabilityType.BROWSER_NAME,"");

    // Set android deviceName desired capability. Set your device name.
    capabilities.setCapability("deviceName", "Galaxy Tab A");

    // Set android VERSION desired capability. Set your mobile device's OS version.
    capabilities.setCapability(CapabilityType.VERSION, "6.0.2");

    // Set android platformName desired capability. It's Android in our case here.
    capabilities.setCapability("platformName", "Android");

    // Set android appPackage desired capability. It is

    capabilities.setCapability("appPackage", "com.rivigo.zoombp.rivigozoombpapp");

    // Set android appActivity desired capability. It is

    capabilities.setCapability("appActivity", "com.rivigo.zoombp.rivigozoombpapp.activity.Activity.RivigoHomeActivity");
    capabilities.setCapability("app", app.getAbsolutePath());

    // Set appium server address and port number in URL string.
    //AndroidDriver  driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
   driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
   //driver = (AndroidDriver)((new URL("http://127.0.0.1:4723/wd/hub"), capabilities));
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

 }

}

In the above code, the line where I declare the URL is marked in RED and hovering over it shows me this message: "The type org.openqa.selenium.remote.http.HttpClient$Factory cannot be resolved. It is indirectly referenced from required .class files"

I have seen many answers asking to add required jar files; but I'm sure I have added all the jar files required. It would be great if anyone can point out the particular jar file I might have missed,if indeed that is the issue, so that I can download and add it separately.

I have seen other answers asking to remove and re-add the JRE system library or close and repair the project, etc. which did not work for me.

I have tried with eclipse-neon and eclipse-mars versions also.
Please ask for any details you need,

I'm blocked here for quite sometime,
help on this would be appreciated,

Thanks,
Rahul

Body:
Add the below maven dependency to your pom.xml to resolve the issue.

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-remote-driver</artifactId>
    <version>3.4.0</version>
</dependency>


问:
Getting System.UnauthorizedAccessException while trying to write to a file from the web service
My code:

```<code>[WebMethod]
        public string HelloWorld()
        {
            string path = @"D:\Data\wwwroot\MyService\MyService\log.txt";
            if (File.Exists(path))
            {
                using (StreamWriter sw = new StreamWriter(path))
                {
                    sw.Write("Some sample text for the file");
                    return "wrote to a file";
                }
            }
            else
            {
                return "file doesnt exist";
            }

        }
</code>```

what I am getting is:
System.UnauthorizedAccessException: Access to the path 'D:\Data\wwwroot\MyService\MyService\log.txt' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   at System.IO.StreamWriter..ctor(String path)
   at LinkTagOutWebService.Service1.HelloWorld() in D:\Data\wwwroot\MyService\MyService\Service.asmx.cs:line 29

Any security settings I need? The log file is set to red/write....

答: Issue solved, it was a permissions issue. You have to grant the IIS user that your app is running under the permission to write to the file.</p>

ContentLicense: CC BY-SA 2.5

Body:
My code:

[WebMethod]
        public string HelloWorld()
        {
            string path = @"D:\Data\wwwroot\MyService\MyService\log.txt";
            if (File.Exists(path))
            {
                using (StreamWriter sw = new StreamWriter(path))
                {
                    sw.Write("Some sample text for the file");
                    return "wrote to a file";
                }
            }
            else
            {
                return "file doesnt exist";
            }

        }

what I am getting is:
System.UnauthorizedAccessException: Access to the path 'D:\Data\wwwroot\MyService\MyService\log.txt' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   at System.IO.StreamWriter..ctor(String path)
   at LinkTagOutWebService.Service1.HelloWorld() in D:\Data\wwwroot\MyService\MyService\Service.asmx.cs:line 29

Any security settings I need? The log file is set to red/write....


问:
Unique identifier for HTML elements
Besides the ID, if you say you want a unique identifier for an HTML element (let’s say a div).

I browsed the DOM for something (like a number or string) that was unique for each element; but the DOM was big and I failed to find that on the Internet.

Is there a property (in the DOM obviously) that is unique only to that element? (Other than the ID and also you don't specify it, but it comes when the DOM is constructed.)

答:
I just encountered the same situation, and while I was looking into some DOM elements in the Chrome developer tools inspector, I noticed that they all seem to have a property like jQuery11230892710877873282 assigned with a unique number.

Obviously the number after 'jQuery' is different every time you load the page. My guess is that jQuery is generating this internally every time it tries to access or manipulate any DOM element.

I played a little bit with it, and it looks like elements that are never accessed/manipulated by jQuery may not have this property, but the moment you do something like $(elem), the property will be there. So, since we're using both jQuery and Lodash, I devised the following function to return a unique ID regardless of whether the element actually has a DOM id attribute.

```<code>_.reduce(
    $(elem),
    function(result, value, key) {
        if(_.startsWith(key, 'jQuery'))
            return value;
        },
    0)
</code>```

ContentLicense: CC BY-SA 4.0

Title: Unique identifier for HTML elements

Body:
I just encountered the same situation, and while I was looking into some DOM elements in the Chrome developer tools inspector, I noticed that they all seem to have a property like jQuery11230892710877873282 assigned with a unique number.

Obviously the number after 'jQuery' is different every time you load the page. My guess is that jQuery is generating this internally every time it tries to access or manipulate any DOM element.

I played a little bit with it, and it looks like elements that are never accessed/manipulated by jQuery may not have this property, but the moment you do something like $(elem), the property will be there. So, since we're using both jQuery and Lodash, I devised the following function to return a unique ID regardless of whether the element actually has a DOM id attribute.

_.reduce(
    $(elem),
    function(result, value, key) {
        if(_.startsWith(key, 'jQuery'))
            return value;
        },
    0)


问:
shopify run from a 3rd party hosting website like iPage
I have a shop currently running on shopify, but I brought the web domain myself, not through shopify, thus shopify doesn't allow me to make a website email account i.e. admin@mywebsitename.com .

I decided to purchased an iPage.com plan to make the website email address (admin@mywebsitename.com).

I am being instructed to repoint my website to new name servers but I'm afraid that will disrupt my shop.

Can anyone help me with how do i make a website email (admin@mywebsitename.com) with ipage.com, without disrupting my shopify shop.

all your help is appreciated

答:
Make sure your MX entry is like this.

Then do to your advanced DNS settings and change your mail entry from CNAME to A record and then put the IP address of your mail server.


问:
How to push data into widget using dashing dashboard
I want to push numeric data from a file to my dashboard.

I am using the following .rb file as job for pushing the data

```<code>SCHEDULER.every '30s' do
var = File.open("/dashing/abhi/sample.txt", "r")
var.each_line do |line|
    puts line
send_event('polarion', { value: var })
end
end
</code>```

but the data is not being displayed in dashboard.

答:
I think this should be:</p>

```<code>SCHEDULER.every '30s' do
  var = File.open("/dashing/abhi/sample.txt", "r")
  var.each_line do |line|
    puts line
    send_event('polarion', { value: line })
  end
end
</code>```

Body:
I want to push numeric data from a file to my dashboard.

I am using the following .rb file as job for pushing the data

SCHEDULER.every '30s' do
var = File.open("/dashing/abhi/sample.txt", "r")
var.each_line do |line|
    puts line
send_event('polarion', { value: var })
end
end

but the data is not being displayed in dashboard.

Body:
I think this should be:

SCHEDULER.every '30s' do
  var = File.open("/dashing/abhi/sample.txt", "r")
  var.each_line do |line|
    puts line
    send_event('polarion', { value: line })
  end
end


问:
Swift 3 Attributed text solution
I have long string something like this:
"Q: what day is it?\nA: bla bla\nQ: what time is it?\nA: bla bla\nQ: what day is it?\nA: bla bla\nQ: what time is it?\nA: bla bla\n"

My problem is I need to show this text in textView but the question has to be orange color and answer has to be grey color. I get string from server and don't know what will I get but the format like this. How resolve this problem?

答:
The problem is there is no "\n" after first question.
I've solved this by a little another way:</p>

```<code>    let faqStr = "Q: what day is it?A: bla bla\nQ: what time is it?\nA: bla bla\nQ: what day is it?\nA: bla bla\nQ: what time is it?\nA: bla bla\n"
    var faqStrArray = faqStr.components(separatedBy: "Q:") //separate by Q+A

    faqStrArray.remove(at: 0) // [0]=""

    let attrText = NSMutableAttributedString()
    for i in 0..<faqStrArray.count {
        faqStrArray[i] = "Q:\(faqStrArray[i])" // append "Q:" that was taken by separator

        var array = faqStrArray[i].components(separatedBy: "A:") // separate to Question and Answer
        array[1] = "A:\(array[1])\n" // append "A:" that was taken by separator

        let attrStringOrange: NSMutableAttributedString = NSMutableAttributedString(string: array[0]) // orange string
        attrStringOrange.addAttribute(NSForegroundColorAttributeName, value: UIColor.orange, range: NSMakeRange(0, attrStringOrange.length)) // adding attribute
        let attrStringGrey: NSMutableAttributedString = NSMutableAttributedString(string: array[1]) // grey string
        attrStringGrey.addAttribute(NSForegroundColorAttributeName, value: UIColor.gray, range: NSMakeRange(0, attrStringGrey.length)) // adding attribute

        attrStringOrange.append(attrStringGrey) // appending answer to question

        attrText.append(attrStringOrange)
    }

    txtView.attributedText = attrText
</code>```

Title: Swift 3 Attributed text solution

Body:
The problem is there is no "\n" after first question.
I've solved this by a little another way:

    let faqStr = "Q: what day is it?A: bla bla\nQ: what time is it?\nA: bla bla\nQ: what day is it?\nA: bla bla\nQ: what time is it?\nA: bla bla\n"
    var faqStrArray = faqStr.components(separatedBy: "Q:") //separate by Q+A

    faqStrArray.remove(at: 0) // [0]=""

    let attrText = NSMutableAttributedString()
    for i in 0..<faqStrArray.count {
        faqStrArray[i] = "Q:\(faqStrArray[i])" // append "Q:" that was taken by separator

        var array = faqStrArray[i].components(separatedBy: "A:") // separate to Question and Answer
        array[1] = "A:\(array[1])\n" // append "A:" that was taken by separator

        let attrStringOrange: NSMutableAttributedString = NSMutableAttributedString(string: array[0]) // orange string
        attrStringOrange.addAttribute(NSForegroundColorAttributeName, value: UIColor.orange, range: NSMakeRange(0, attrStringOrange.length)) // adding attribute
        let attrStringGrey: NSMutableAttributedString = NSMutableAttributedString(string: array[1]) // grey string
        attrStringGrey.addAttribute(NSForegroundColorAttributeName, value: UIColor.gray, range: NSMakeRange(0, attrStringGrey.length)) // adding attribute

        attrStringOrange.append(attrStringGrey) // appending answer to question

        attrText.append(attrStringOrange)
    }

    txtView.attributedText = attrText


问:
DB2 - handling columns defined as null
Let's say you have three textboxes that you can use to search for data.  Each textbox will correspond to a column on the DB2 table.  The search string you enter will be inserted into the where clause.  For example, you have First-Name, Last-Name, and Phone Number.  If you don't enter data into a particular textbox, I default its value in the where clause to '_', the wildcard character to select everything.  Also, lets say Phone Number is defined as NULL on the table.

Cursor1 will be used if the user has entered a Phone number to search for.  So the where clause will look something like this:

Where FIRST_NAME like :firstname AND
      LAST_NAME like  :lastname  AND
      PHONE_NBR like  :number

This works when data is entered for phone number.  But if a search is done for First Name only, the cursor returns partial or no results because the :number host variable will be populated with the "_' wildcard.  PHONE_NBR like '_' will only return the rows that have a real value.  If there is a null for PHONE_NBR on a row that matches the First Name you searched for, that row won't show up.  So I created a second cursor.

Cursor2 will be used if the user HAS NOT entered a Phone number to search for.  The Where clause looks something like this.

Where FIRST_NAME like :firstname AND
      LAST_NAME like  :lastname  AND
      (PHONE_NBR like  :number OR
       PHONE_NBR IS NULL)

So again, if a search was done for a first name only, and some values in PHONE_NBR have data, some are null, EVERYTHING that matches the first name that is searched for will show in the results - which is good.  For the rows with values in PHONE_NBR, PHONE_NBR like '_' will get those.  For the rows with null in PHONE_NBR, PHONE_NBR IS NULL will get those.

This is a minor yet necessary difference.  Because of this minor difference, I would like to combine these two cursors into one.  How can that be done to achieve the same results?

答:
The way I'd recommend handling this is by building the query to supply conditions only on the columns where the user enters data.  That is:

If the user enters something in the First_Name text box, you have a condition such as:

```<code>FIRST_NAME LIKE '...'
</code>```

If the user enters something in the Last_Name text box, you have a condition such as:

```<code>LAST_NAME LIKE '...'
</code>```

If the user enters something in the Phone_Nbr text box, you have a condition such as:

```<code>PHONE_NBR LIKE '...'
</code>```

In each case, the 3 dots represent a string derived from the information typed into the text box, and the function that does that conversion is fully aware of quoting (to avoid SQL injection).

If the user types in two or three of the text boxes, the independent conditions are joined by an AND.  If the user types nothing, you can generate a tautology such as 1 = 1 as the condition.

You then append that condition to the WHERE clause of the SQL statement, and then arrange to execute it.

This is the technique made available by the CONSTRUCT statement in IBM Informix 4GL; it has been available there since 1986.  It allows for conditions other than just LIKE, such as equals, less than, greater than or equal to, ranges, or even a list of alternatives (for an IN ('val1', 'val2', ...) condition), and it can be used for all data types.

Title: DB2 - handling columns defined as null

Body:
The way I'd recommend handling this is by building the query to supply conditions only on the columns where the user enters data.  That is:

If the user enters something in the First_Name text box, you have a condition such as:

FIRST_NAME LIKE '...'

If the user enters something in the Last_Name text box, you have a condition such as:

LAST_NAME LIKE '...'

If the user enters something in the Phone_Nbr text box, you have a condition such as:

PHONE_NBR LIKE '...'

In each case, the 3 dots represent a string derived from the information typed into the text box, and the function that does that conversion is fully aware of quoting (to avoid SQL injection).

If the user types in two or three of the text boxes, the independent conditions are joined by an AND.  If the user types nothing, you can generate a tautology such as 1 = 1 as the condition.

You then append that condition to the WHERE clause of the SQL statement, and then arrange to execute it.

This is the technique made available by the CONSTRUCT statement in IBM Informix 4GL; it has been available there since 1986.  It allows for conditions other than just LIKE, such as equals, less than, greater than or equal to, ranges, or even a list of alternatives (for an IN ('val1', 'val2', ...) condition), and it can be used for all data types.


问:
extracting links from a website
So I want to go to http://www.medhelp.org/forums/list and then there are lots of links to different diseases there. Inside each link, there are several pages each one has some links again that I want.

I want to get some of the links. so I used this code:

```<code>myArray=[]
html_page = urllib.request.urlopen("http://www.medhelp.org/forums/list")
soup = bs(html_page)
temp =soup.findAll('div',attrs={'class' : 'forums_link'})
for div in temp:
  myArray.append('http://www.medhelp.org' + div.a['href'])
myArray_for_questions=[]
myPages=[]

#this for is going over all links on the main page. in this case, all
diseases
for link in myArray:

  # "link" is the URL for each link in the main page of our website
  html_page = urllib.request.urlopen(link)
  soup1 = bs(html_page)

  #getting the questions's links in the first page
  temp =soup1.findAll('div',attrs={'class' : 'subject_summary'})
  for div in temp:
     myArray_for_questions.append('http://www.medhelp.org' + div.a['href'])

  #now getting the URL for all next pages for this page
  pages = soup1.findAll('a' ,href=True, attrs={'class' : 'page_nav'})
  for l in pages:
    html_page_t = urllib.request.urlopen('http://www.medhelp.org'
    +l.get('href'))
    soup_t = bs(html_page_t)
    other_pages = soup_t.findAll('a' ,href=True, attrs={'class' :
    'page_nav'})
    for p in other_pages:
        mystr='http://www.medhelp.org' +p.get('href')
        if mystr not in myPages:
            myPages.append(mystr)
        if p not in pages:
            pages.append(p)

  # getting all links inside this page which are people's questions
  for page in myPages:
      html_page1 = urllib.request.urlopen(page)
      soup2 = bs(html_page1)
      temp =soup2.findAll('div',attrs={'class' : 'subject_summary'})
      for div in temp:
        myArray_for_questions.append('http://www.medhelp.org' +
        div.a['href'])
</code>```

but it takes forever to get all links I want from all pages. Any Ideas?

Thanks

答:
Try the scrapy tutorial, follow it trying to replace the example provided with your web page:

https://doc.scrapy.org/en/latest/intro/tutorial.html

Title: extracting links from a website

Body:
So I want to go to http://www.medhelp.org/forums/list and then there are lots of links to different diseases there. Inside each link, there are several pages each one has some links again that I want.

I want to get some of the links. so I used this code:

myArray=[]
html_page = urllib.request.urlopen("http://www.medhelp.org/forums/list")
soup = bs(html_page)
temp =soup.findAll('div',attrs={'class' : 'forums_link'})
for div in temp:
  myArray.append('http://www.medhelp.org' + div.a['href'])
myArray_for_questions=[]
myPages=[]

#this for is going over all links on the main page. in this case, all
diseases
for link in myArray:

  # "link" is the URL for each link in the main page of our website
  html_page = urllib.request.urlopen(link)
  soup1 = bs(html_page)

  #getting the questions's links in the first page
  temp =soup1.findAll('div',attrs={'class' : 'subject_summary'})
  for div in temp:
     myArray_for_questions.append('http://www.medhelp.org' + div.a['href'])

  #now getting the URL for all next pages for this page
  pages = soup1.findAll('a' ,href=True, attrs={'class' : 'page_nav'})
  for l in pages:
    html_page_t = urllib.request.urlopen('http://www.medhelp.org'
    +l.get('href'))
    soup_t = bs(html_page_t)
    other_pages = soup_t.findAll('a' ,href=True, attrs={'class' :
    'page_nav'})
    for p in other_pages:
        mystr='http://www.medhelp.org' +p.get('href')
        if mystr not in myPages:
            myPages.append(mystr)
        if p not in pages:
            pages.append(p)

  # getting all links inside this page which are people's questions
  for page in myPages:
      html_page1 = urllib.request.urlopen(page)
      soup2 = bs(html_page1)
      temp =soup2.findAll('div',attrs={'class' : 'subject_summary'})
      for div in temp:
        myArray_for_questions.append('http://www.medhelp.org' +
        div.a['href'])

but it takes forever to get all links I want from all pages. Any Ideas?

Thanks


问:
Centering text on video in CSS
I was trying to center the name of my blog in the video background I use but was unsuccesful even though I've tried positioning it absolute with 50% from the top. Can anyone help me center both horizontally and vertically the text on top of the video?

Here's the code: https://codepen.io/anon/pen/QgBZqd

HTML

```<code>    <!DOCTYPE html>
    <html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <title>SINEMACERA</title>
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Anton|Cabin" rel="stylesheet">
    </head>
    <body>

    <!--NAVBAR STARTS-->

    <nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">SINEMACERA</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav">

            <li class="active"><a href="#">Anasayfa</a></li>

          </ul>

          <ul class="nav navbar-nav navbar-right">
            <li><a href="#">Hakkımda</a></li>
            <li><a href="#">İletişim</a></li>

          </ul>
        </div><!-- /.navbar-collapse -->
        </div>
    </nav>

    <!--NAVBAR ENDS-->

    <div id="COVERPHOTO">

        <div id="COVER">
          <h1 id="COVERTEXT">TEXT ON VIDEO</h1>
          <video autoplay loop id="video-background" muted plays-inline>
            <source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
          </video>
          </div>
      </div>

    <div class="container">
        <div class="row">
        <div id="MAJORCONTENT">

            <div class="col-lg-12">
    <h1>Lorem Ipsum Üzerine</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <span class="readmore">
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </span>
    <button type="button" class="btn btn-primary wide-button">Devamını oku!</button>
    </div>

            <div class="col-lg-12">
    <h1>Lorem Ipsum Üzerine</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <span class="readmore">
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </span>
    <button type="button" class="btn btn-primary wide-button">Devamını oku!</button>
    </div>

    <div class="col-lg-12">
    <h1>Lorem Ipsum Üzerine</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <span class="readmore">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </span>
    <button type="button" class="btn btn-primary wide-button">Devamını oku!</button>
    </div>

    </div>
        </div>
    </div>

    <script
      src="https://code.jquery.com/jquery-3.2.1.js"
      integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
      crossorigin="anonymous"></script>

    <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="sinemacera.js"></script>
    </body>
    </html>
</code>```

CSS

```<code> body {
        background: black;
        color:white;
        font-family: Cabin;
    }

    .wide-button {
        width:100%;
    }

    h1 {
        text-align: center;
        text-shadow: 0px 2px 10px rgba(255, 255, 255, 0.4)

    }

    .row {
        float:left;
    }

    .readmore {
        display:none;
    }

    #COVERPHOTO {
        margin-top: 50px;
    }

    #COVER {
        position: relative;
        font-size: 40px;
        text-align: center;
    }

    #COVERTEXT {
        margin:0;
        font-family: Anton;
        font-size: 10vw;
        text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.7),
                 0px 8px 13px rgba(0, 0, 0, 0.3),
                 0px 18px 23px rgba(0, 0, 0,0.3);
                    }

    #MAJORCONTENT {
    text-align: justify;
    font-size: 1.5em;
    }

    video {
        width:100%;
        height: auto;
    }
</code>```

JS

```<code>$(".btn-primary").click(function() {

var thisBTN = $(this);
var RM = $(this).prev();

RM.slideToggle(1000, function() {
    thisBTN.toggleClass("btn-info")
    if(thisBTN.text()==="Küçült") {
        thisBTN.text("Devamını oku");
    }
    else {
        thisBTN.text("Küçült")
    }
});
});
</code>```

答:
A combination of position: absolute; top: 50%; transform: translateY(-50%); left: 0; right: 0; on #COVERTEXT will center the text over the video, relative to the parent #COVER

$(".btn-primary").click(function() {

var thisBTN = $(this);
var RM = $(this).prev();

RM.slideToggle(1000, function() {
 thisBTN.toggleClass("btn-info")
 if(thisBTN.text()==="Küçült") {
  thisBTN.text("Devamını oku");
 }
 else {
  thisBTN.text("Küçült")
 }
});
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
  background: black;
  color: white;
  font-family: Cabin;
}

.wide-button {
  width: 100%;
}

h1 {
  text-align: center;
  text-shadow: 0px 2px 10px rgba(255, 255, 255, 0.4);
}

.row {
  float: left;
}

.readmore {
  display: none;
}

#COVERPHOTO {
  margin-top: 50px;
}

#COVER {
  position: relative;
  font-size: 40px;
  text-align: center;
}

#COVERTEXT {
  margin: 0;
  font-family: Anton;
  font-size: 10vw;
  text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.7),
    0px 8px 13px rgba(0, 0, 0, 0.3),
    0px 18px 23px rgba(0, 0, 0, 0.3);
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
}

#MAJORCONTENT {
  text-align: justify;
  font-size: 1.5em;
}

video {
  width: 100%;
  height: auto;
}</code>```

      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        Toggle navigation

      </button>
      SINEMACERA

Anasayfa

Hakkımda

İletişim

TEXT ON VIDEO

      <video autoplay loop id="video-background" muted plays-inline>
        <source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
      </video>

Lorem Ipsum Üzerine

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>

Lorem Ipsum Üzerine

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>

Lorem Ipsum Üzerine

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>

```

Title: Centering text on video in CSS

Body:
I was trying to center the name of my blog in the video background I use but was unsuccesful even though I've tried positioning it absolute with 50% from the top. Can anyone help me center both horizontally and vertically the text on top of the video?

Here's the code: https://codepen.io/anon/pen/QgBZqd

HTML

    <!DOCTYPE html>

    <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <title>SINEMACERA</title>
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Anton|Cabin" rel="stylesheet">

          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            Toggle navigation

          </button>
          SINEMACERA

Anasayfa

Hakkımda

İletişim

TEXT ON VIDEO

          <video autoplay loop id="video-background" muted plays-inline>
            <source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
          </video>

Lorem Ipsum Üzerine

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

    <button type="button" class="btn btn-primary wide-button">Devamını oku!</button>

Lorem Ipsum Üzerine

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

    <button type="button" class="btn btn-primary wide-button">Devamını oku!</button>

Lorem Ipsum Üzerine

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
    tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
    quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
    cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

    <button type="button" class="btn btn-primary wide-button">Devamını oku!</button>

CSS

 body {
        background: black;
        color:white;
        font-family: Cabin;
    }

    .wide-button {
        width:100%;
    }

    h1 {
        text-align: center;
        text-shadow: 0px 2px 10px rgba(255, 255, 255, 0.4)

    }

    .row {
        float:left;
    }

    .readmore {
        display:none;
    }

    #COVERPHOTO {
        margin-top: 50px;
    }

    #COVER {
        position: relative;
        font-size: 40px;
        text-align: center;
    }

    #COVERTEXT {
        margin:0;
        font-family: Anton;
        font-size: 10vw;
        text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.7),
                 0px 8px 13px rgba(0, 0, 0, 0.3),
                 0px 18px 23px rgba(0, 0, 0,0.3);
                    }

    #MAJORCONTENT {
    text-align: justify;
    font-size: 1.5em;
    }

    video {
        width:100%;
        height: auto;
    }

JS

$(".btn-primary").click(function() {

var thisBTN = $(this);
var RM = $(this).prev();

RM.slideToggle(1000, function() {
    thisBTN.toggleClass("btn-info")
    if(thisBTN.text()==="Küçült") {
        thisBTN.text("Devamını oku");
    }
    else {
        thisBTN.text("Küçült")
    }
});
});

Body:
A combination of position: absolute; top: 50%; transform: translateY(-50%); left: 0; right: 0; on #COVERTEXT will center the text over the video, relative to the parent #COVER

$(".btn-primary").click(function() {

var thisBTN = $(this);
var RM = $(this).prev();

RM.slideToggle(1000, function() {
 thisBTN.toggleClass("btn-info")
 if(thisBTN.text()==="Küçült") {
  thisBTN.text("Devamını oku");
 }
 else {
  thisBTN.text("Küçült")
 }
});
});

body {
  background: black;
  color: white;
  font-family: Cabin;
}

.wide-button {
  width: 100%;
}

h1 {
  text-align: center;
  text-shadow: 0px 2px 10px rgba(255, 255, 255, 0.4);
}

.row {
  float: left;
}

.readmore {
  display: none;
}

#COVERPHOTO {
  margin-top: 50px;
}

#COVER {
  position: relative;
  font-size: 40px;
  text-align: center;
}

#COVERTEXT {
  margin: 0;
  font-family: Anton;
  font-size: 10vw;
  text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.7),
    0px 8px 13px rgba(0, 0, 0, 0.3),
    0px 18px 23px rgba(0, 0, 0, 0.3);
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
}

#MAJORCONTENT {
  text-align: justify;
  font-size: 1.5em;
}

video {
  width: 100%;
  height: auto;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>

<!--NAVBAR STARTS-->

<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">SINEMACERA</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">

        <li class="active"><a href="#">Anasayfa</a></li>

      </ul>

      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Hakkımda</a></li>
        <li><a href="#">İletişim</a></li>

      </ul>
    </div><!-- /.navbar-collapse -->
    </div>
</nav>

<!--NAVBAR ENDS-->

<div id="COVERPHOTO">

    <div id="COVER">
      <h1 id="COVERTEXT">TEXT ON VIDEO</h1>
      <video autoplay loop id="video-background" muted plays-inline>
        <source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
      </video>
      </div>
  </div>

<div class="container">
 <div class="row">
 <div id="MAJORCONTENT">

  <div class="col-lg-12">
<h1>Lorem Ipsum Üzerine</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<span class="readmore">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</span>
<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>
</div>

  <div class="col-lg-12">
<h1>Lorem Ipsum Üzerine</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<span class="readmore">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</span>
<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>
</div>

<div class="col-lg-12">
<h1>Lorem Ipsum Üzerine</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<span class="readmore">
 <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</span>
<button type="button" class="btn btn-primary wide-button">Devamını oku!</button>
</div>

</div>
 </div>
</div>
</body>
</html>


问:
Flickering of recyclerview when fetching imagerequests
I experienced a flickering of the imageviews in my recyclerview when scrolling very fast. All the imagerequests would be downloaded and showed. This would a weird effect on the imageviews.

I'm using Volley library to execute the downloads, together with Picasso to show the images. Yes this is a funny combination, but I needed to customise my headers & have authentication of my requests. Picasso not allowing me this easily.

I have experimented with a lot of possibilities;
 - Pausing the requestQueue when scrolling. Resume downloads when idle. This would result in the same issue, but delayed.
- Use of Volley's imageLoader/NetworkImageView. Imageloader cannot be customized like a volley request.
- Delete all requests when scrolling. Resume when idle. This would result with imageviews not being downloaded.

答:
So as I didn't find any easy solution online, I would like to share mine.
2 lines of code that are now perfectly working with my existing code;

```<code>MyApplication.mRequestqueue.cancelAll(imgView);
imageRequest.setTag(imgView);
</code>```

Then I add my request
    MyApplication.mRequestqueue.add(imageRequest);

the imgView is a... ImageView

I tried with a String but behind the scenes it is checking for == and not equal, resulting in not finding and cancelling the same requests going on.

Hope this will help someone!

Body:
So as I didn't find any easy solution online, I would like to share mine.
2 lines of code that are now perfectly working with my existing code;

MyApplication.mRequestqueue.cancelAll(imgView);
imageRequest.setTag(imgView);

Then I add my request
    MyApplication.mRequestqueue.add(imageRequest);

the imgView is a... ImageView

I tried with a String but behind the scenes it is checking for == and not equal, resulting in not finding and cancelling the same requests going on.

Hope this will help someone!


问:
Vagrant: Windows host and Windows guest - how to restrict smb share?
I have a Windows 7 host and a Windows Server 2016 guest.

I have the following line in my Vagrantfile:

```<code>config.vm.synced_folder ".", "c:/vagrant", type: "smb", smb_username: "xxx", smb_password: "xxx"
</code>```

Doing a vagrant up makes the folder containing theVagrantfile (on the host) readable for everyone. How can I restrict this to the vagrant guest?

答:
Putting here for visibility purpose but did not try with windows guest:</p>

```<code>config.vm.synced_folder '', 'c:/vagrant',
type: 'smb',
owner: 'vagrant',
smb_username: "xxx", smb_password: "xxx",
mount_options: [dir_mode=0775,file_mode=0664"]
</code>```

Body:
I have a Windows 7 host and a Windows Server 2016 guest.

I have the following line in my Vagrantfile:

config.vm.synced_folder ".", "c:/vagrant", type: "smb", smb_username: "xxx", smb_password: "xxx"

Doing a vagrant up makes the folder containing theVagrantfile (on the host) readable for everyone. How can I restrict this to the vagrant guest?

Body:
Putting here for visibility purpose but did not try with windows guest:

config.vm.synced_folder '', 'c:/vagrant',
type: 'smb',
owner: 'vagrant',
smb_username: "xxx", smb_password: "xxx",
mount_options: [dir_mode=0775,file_mode=0664"]