How to Use Periscope to Drive Business for Your Brand

By Pete Schauer Video is only getting bigger in terms of digital marketing, and if you’re looking to drive engagement and brand awareness through live-streaming video, then Periscope is your answer. Follow these tips to get the most out of Periscope for your brand.

Source: Social Media Today

    

How to define a token which is all those characters in set A, except those in sub-set B?

By David Bullock

In RFC2616 (HTTP/1.1) the definition of a ‘token’ in section ‘2.2 Basic Rules’ is given as:

token          = 1*<any CHAR except CTLs or separators>

From that section, I’ve got the following fragments, and now I want to define ‘TOKEN’:

lexer grammar AcceptEncoding;

TOKEN: /* (ASCII excluding (CTRL | SEPARATORS | SP | HT)) */

fragment ASCII: [u0000-u0127];
fragment CTRL: [u0000-u0031];
fragment SEPARATORS: [()<>@,;:\;"/[]?={|}];
fragment SP: ' ';
fragment HT: 't';

How to I approximate my hypothetical ‘excluding’ operator for the definition of TOKEN?

Source: Stack Overflow

    

Code after NSURLSession runs before session is over – Swift

By Jaxon

I have an app that accesses a website and downloads the HTML from that site, converts it to a string, grabs some information from the string, and then uses that for the app. My problem is that the code extracting the string runs before the data can actually be loaded. I tried putting that code in the completion handler, but that either didn’t fix the problem, or I did it wrong. Here is my code:

            let url = NSURL(string: "websitename.com" + currentWord)

            var request: NSURLRequest = NSURLRequest(URL: url!)
            let config = NSURLSessionConfiguration.defaultSessionConfiguration()
            let session = NSURLSession(configuration: config)

            let task : NSURLSessionDataTask = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in

                if error == nil {
                    //Getting String From URL Data
                    let urlContent = NSString(data: data!, encoding: NSUTF8StringEncoding)!

The urlContent constant is assigned its value before the website data is loaded. I need a way to stop that from happening. I am fairly new to programing, so keep that in mind with your answer, thank you in advance.

Source: Stack Overflow

    

Five Mistakes to Avoid When Doing Mobile SEO [Infographic]

By Charles Crawford Because the use of cell phones has skyrocketed and continues to outpace other technology, you have to ensure your search engine optimization techniques account for smart phone usage. In other words, if you’re not mobile-friendly, you are missing a large part of the population that could be using your services or buying your products. If you’re new to mobile SEO, you will want to avoid these mistakes.

Source: Social Media Today

    

Every time i refresh page it inserts same user into database

By Kolibrok

Here is PHP code

<?php
if(isset($_POST['Murad'])){
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$userName=$_POST['username'];
$password=$_POST['pwd1'];
$userName = stripslashes($userName);
$password = stripslashes($password);
$email=$_POST['email'];
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "123";
$mysql_databse = "websiteusers";
$prefix = "";
$bd = mysqli_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
$sql = "INSERT INTO websiteusers 
       (fullname,lastname,userName,email,pass) 
       VALUES ( '$firstname', '$lastname','$userName', '$email','$password')";
        mysqli_select_db($bd,'websiteusers');
$retval = mysqli_query($bd,$sql );
if(! $retval )
{
  die('Could not enter data: ');
  return false;
}
else {echo "Entered data successfullyn";
   }

   $usernamecheck=mysqli_query($bd,"SELECT `userName` FROM `websiteusers` 
                             WHERE userName='$userName'");
if(mysqli_num_rows($usernamecheck)>=1){
   echo $userName." is already taken";
 return false;
 }header("Location: Main.php");}

?>

User registers then when he is in his profile page as soon as he refreshes it inserts same username again.And also username and email are unique in my dt it cant insert it and gives an error

Source: Stack Overflow

    

Sympy – integrate then plot an expression

By cqcn1991

enter image description here

Here is the equation that I want to integrate, I want to integrate the theta, it will be a function of y = f(V), then plot the y - V. All other parameters are known.

How can I do it?

Here is what I’ve done:

# Part 1: Create integ_expr y=f(V)
from sympy import *
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
V, theta = symbols('v theta')
# U, phi, sigu, sigv = symbols('U phi sigu sigv')
u,v = -2.63582726849, 0.562272364634
sigu, sigv = 7.9369982103, 6.56056711043
U = (u)**2 + (v)**2
phi = atan(u/v)
expr = exp(((V*cos(theta)-U*cos(phi))**2/sigu**2+(V*sin(theta)-U*sin(phi))**2/sigv**2)*-1/2)
integ_expr = integrate(expr, (theta, 0, 2*np.pi)) # this can return a result

# Part 2: plot `y-V`
lf = lambdify(V, integ_expr)
fig = plt.figure()
x_vals = np.linspace(-20.,20.)
y_vals = lf(x_vals) # reports TypeError: can't convert expression to float

axes.grid()
axes.plot(x_vals, y_vals)

plt.show();

I can get the integ_expr, but y_vals = lf(x_vals) gives me TypeError: can't convert expression to float.

I think it’s maybe the integ_expr is still an expression not a function that can directly return a result?

I just get started with Sympy, the above code may feel childish to most of you, so I’m wondering if there is a right way to plot expressions?

Source: Stack Overflow

    

Repaint NSView when mainWindow changes

By Laszlo Korte

I would like to change the background of an NSView depending on if the the window is focused.

I found this question: Change NSView background color when window has focus

And the first answer works fine except the redraw is not triggered when the windows loses or gains focus.

How can I trigger the redraw when the mainWindow changes?

Source: Stack Overflow