Inline Styles as Classes (lol)

If you’re abhorred by using inline styles, just move that style to the class attribute! And then make sure you have CSS in place that, ya know, does what it says on the box.

OK lemme dig in and totally ruin the joke.

  • First off, it’s a joke, so don’t actually do this. I don’t even mind the occasional inline style for one-off stuff, but this is not that.
  • To me the weirdest part is that period (.) character. Escaping the more unusual characters with a backslash () feels normal, but what is that period about? UPDATE: It’s because of the space. It’s two classes in the HTML, not one. Derp.
  • The little period trick there doesn’t work when the following character is a number (e.g. .padding:.1rem;). UPDATE: Because classes that start with a number are invalid. Derp.
  • You can avoid the escaping and trickery if you go with an attribute selector like [class*="display: flex;"].
  • This reminds me of Mathias Bynens’ research: CSS character escape sequences. But… that doesn’t seem to work anymore? I wonder if browsers changed or if the tool broke and doesn’t output what it should anymore (e.g. does .color\3A \ #f06d06 look right?).

Here’s all that playing around:


The post Inline Styles as Classes (lol) appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

How To Give Your DevOps Feedback Loop The Update It Needs

Introduction

With the highest performing DevOps teams deploying on average four times a day, the pressure is on. Your team should always be looking to improve the speed and quality of your process. A solution may be closer than you think.

What Is a Feedback Loop?

In society, we receive feedback continuously, from friends, family, and colleagues. Companies often have office telephone systems or entire call centers dedicated to receiving feedback from their customers. So, what is it doing in your DevOps process?

Versioning Multiple Microservices in a Monorepo Using Maven

It is crucial that each piece of code you deploy have a unique version, it helps you track what your client is running, mark deployments with breaking changes, and makes your life so much easier — especially when trying to understand what changes are running at your client site in the middle of the night.

When you develop microservices, it is twice as important. Usually, you deploy your services individually and you need to know which version of which dependency is used by your service. Another requirement many developers face is how to automatically (or manually) update your dependencies when they change.

PHP unlink(); No such file or directory

hello, i have a probelm where i want to update my image in database using unlink(). The error is Warning: unlink(images/481933.jpg): No such file or directory. I try search the solution but nothing can solve my probelm. anyone can help me? thank you in advanced. this is my code:

$upload_dir='images/';

$imgExt=strtolower(pathinfo($images,PATHINFO_EXTENSION));

$valid_extensions=array('jpeg', 'jpg', 'png', 'gif', 'pdf');

$picProfile=rand(1000, 1000000).".".$imgExt;

unlink($upload_dir.$edit_row['prod_img']);

move_uploaded_file($tmp_dir, $upload_dir.$picProfile);

$stmt=$db_conn->prepare('UPDATE product SET prod_name=:prod_name, category=:category, prod_img=:prod_img, unit_price=:price, stock=:stock, min_limit=:min_limit, weight=:weight, description=:description, packaging=:packaging, size=:size, retail_price=:retail, agent_price=:agent WHERE prod_id=:prod_id');

Revolutionizing the Product Update With WSO2 Update 2.0

Every software application undergoes various changes over time and as a result, we get patches/ hotfixes, updates, and new version releases. Those changes can be either architectural/ technical changes to suit the current technology landscape or functional changes to meet end-users’ demanding needs. An update or a new release of a software application can consist of either of those changes or maybe both.

Software applications that do not meet time to market when releasing updates and new versions and take a long time to release updates or new versions become obsolete. They vanish into thin air without a trace. That’s why giants like Microsoft have reduced their major release cycle from 4 years to 3 years and also provide major Updates to the current release bi-annually so that the end-users are up-to-date and on track. Not only new releases and updates, but they also have to provide patches/ hotfixes for identified bugs/ vulnerabilities in order to stay competitive in the game.

MYSQL 8 Query Join Problem

I have the following query which has died after running over an hour on my local mysql 8 server:

UPDATE download
  LEFT JOIN lookup ON download.ip_address between lookup.start_ip AND lookup.end_ip
SET ref = (
    SELECT lookup.id FROM lookup WHERE download.ip_address between lookup.start_ip AND lookup.end_ip);

All ip fields are IPV4 and stored as unsigned integers and are indexed. The lookup table is approx. 3M rows, relating ip ranges to country, area, and city. The download table is approx. 2K rows. What I'm trying to do is get the id from the lookup table row that has the ip range that the download ip_address falls into.

Does someone see a problem with the query?

Database Fundamentals #23: Filtering Data

If you've been reading these Database Fundamentals posts, you've already seen the WHERE clause because of your use of it when manipulating data with DELETE and UPDATE statements. It's also been used several times earlier in this series to limit the values returned from a SELECT statement.

The primary places where people run into trouble with T-SQL is in the JOIN criteria and the WHERE clause criteria. This occurs because they don't understand well enough what the filters and operators they're using will do. They end up returning too much data because they didn't us the WHERE clause or misapplied it. They also filter too much data out. 

Testing a console input/output

Hi guys, I was trying to test a method which takes a user input, does something and then returns that input but I'm having some issues with it. I've attempted a few solutions, mostly described in SE, I will leaave them out of this
post and discuss instead the one that seemed the most likely to work instead.
This is the method that I'm trying to test (other code omitted for brevity):

public int getUserInput() {
        int choice = 0;
        boolean isValidInput = false;
        System.out.printf("Welcome. Select action: %d for READ, %d for CREATE, %d for UPDATE, %d for DELETE, %d for EXIT.", OperationOptions.READ.getValue(), OperationOptions.CREATE.getValue(), OperationOptions.UPDATE.getValue(), OperationOptions.DELETE.getValue(), OperationOptions.EXIT.getValue());
        while(!isValidInput)
            try {                 
                choice = scanner.nextInt();
                if(choice == OperationOptions.READ.getValue() || choice == OperationOptions.CREATE.getValue() || choice == OperationOptions.UPDATE.getValue() || choice == OperationOptions.DELETE.getValue() || choice == OperationOptions.EXIT.getValue())
                {
                    isValidInput = true;
                }
                else
                {
                    isValidInput = false;
                    System.out.println(String.format(Messages.NOT_ALLOWED_VALUES, OperationOptions.READ.getValue(), OperationOptions.CREATE.getValue(), OperationOptions.UPDATE.getValue(), OperationOptions.DELETE.getValue(), OperationOptions.EXIT.getValue()));
                }

                scanner.hasNextLine();
            }
            catch(InputMismatchException e) {
                 System.out.println(Messages.NOT_NUMERICAL_ERROR);
                 isValidInput = false;
                 scanner.nextLine();                 
            }
        return choice;
    }

A word about the test. What I had in mind was to test the actual input, so have a test that fakes the input, then calls the method and check that the fake input is the same as the one returned from that method. That would be
the first test, then chose another input and make sure it generates an exception and so on.

So this is my test class

package com.test.userInteraction;

import static org.junit.Assert.assertEquals;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.PrintStream;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class UserInputTest {
    UserInput userInput;
    private final InputStream systemIn = System.in;
    private final PrintStream systemOut = System.out;

    private ByteArrayInputStream testIn;
    private ByteArrayOutputStream testOut;

    @Before
    public void setUpOutput() {
        testOut = new ByteArrayOutputStream();
        System.setOut(new PrintStream(testOut));
    }
    private String getOutput() {
        return testOut.toString();
    }

    @After
    public void restoreSystemInputOutput() {
        System.setIn(systemIn);
        System.setOut(systemOut);
    }

    @Test
    public void testCase1() {
          int testString = 3;

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutput out;
        try {
            out = new ObjectOutputStream(bos);
            out.writeInt(testString);
            out.close();
            byte[] int_bytes = bos.toByteArray();
            provideInput(int_bytes);
            userInput = new UserInput();
            int userInput2 = userInput.getUserInput();
            assertEquals(testString, userInput2);

            bos.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    private void provideInput(byte[] int_bytes) {
        testIn = new ByteArrayInputStream(int_bytes);
        System.setIn(testIn);

    }
}

So the problem is that it fails when it reachesint userInput2 = userInput.getUserInput(); inside getUserInput when it reaches choice = scanner.nextInt(); it generates a InputMismatchException and then controls goes back to choice = scanner.nextInt(); and then fails but I can't quite figure out why
The stack trace in the test is

java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Scanner.java:862)
    at java.util.Scanner.next(Scanner.java:1485)
    at java.util.Scanner.nextInt(Scanner.java:2117)
    at java.util.Scanner.nextInt(Scanner.java:2076)
    at com.test.userInteraction.UserInput.getUserInput(UserInput.java:34)
    at com.test.userInteraction.UserInputTest.testCase1(UserInputTest.java:69)
    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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

Any idea what is going on? It's like it doesn't like the fake input somehow

Java 14

JDK 14 does not disappoint. In the latest JDK update, we see the usual API changes and low-level JVM enhancements, as well as exciting new language preview features and simplified debugging with NPE.

SQL INSERT, UPDATE, DELETE — Oh My!

SQL INSERTUPDATE, and DELETE statements — what are they all about? If you’re a data engineer, a database administrator, or even just your average data fanboy or girl, one day you’re going to find yourself with a database that becomes your “baby.” Charged with this special bundle of joy, you’re going to need to feed and change the little fella. Yes, we’re still talking about databases! INSERTUPDATE, and DELETE are all functions in SQL that help you ensure your data is up-to-date and kept clear of unnecessary or outdated information.

INSERTUPDATE, and DELETE, as well as SELECT and MERGE, are known as Data Manipulation Language (DML) statements, which let SQL users view and manage data. While data is, of course, often updated by the application itself, it regularly requires manual entry or maintenance, and this demands not only a good understanding of SQL Basics, but also how to INSERTUPDATE, and DELETE in SQL.

How Often Should You Update Your Mobile App?

Do you know?

For Android, iOS, and other apps, release frequencies vary. Managed app testing leader Testlio recently queried more than 75K client release records, covering a diverse range of industries (including Commerce, Education, Entertainment, Finance, Productivity, Sports, and Travel). Collectively, these Testlio clients have a user base of more than 1.5 billion people.

Java Annotated Monthly — May 2019

This month, we have a guest section on security since there were so many relevant security articles. We have the results of two developer surveys and a huge culture and community section that explores some of the factors that might contribute to the results of those developer surveys. Of course, May’s Annotated Monthly also includes your regular fix of Java news, tutorials, and tips.

Java News

Big news, everyone! Java EE is dead. Again. What year is it? Why are the same headlines popping up, again and again, every year?

Session variable is not updated when database gets updated

Hello,
So I have buttons on my site connected to a PHP code that updates the column "status" in "users" table with a value based on what button you press.
This is the PHP script for that:

<?php

include('functions.php');

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "emildeveloping";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$id = $_SESSION['user']['id'];

if (isset($_POST['108'])) {
$sql = "UPDATE users SET status = '10-8' WHERE id='".$id."'";
}

if (isset($_POST['107'])) {
    $sql = "UPDATE users SET status = '10-7' WHERE id='".$id."'";
    }

    if (isset($_POST['105'])) {
        $sql = "UPDATE users SET status = '10-5' WHERE id='".$id."'";
        }

        if (isset($_POST['1015'])) {
            $sql = "UPDATE users SET status = '10-15' WHERE id='".$id."'";
            }

            if (isset($_POST['1023'])) {
                $sql = "UPDATE users SET status = '10-23' WHERE id='".$id."'";
                }

                if (isset($_POST['1097'])) {
                    $sql = "UPDATE users SET status = '10-97' WHERE id='".$id."'";
                    }

                    if (isset($_POST['1042'])) {
                        $sql = "UPDATE users SET status = '10-42' WHERE id='".$id."'";
                        }

if (mysqli_query($conn, $sql)) {
    echo "Status was updated.";
    header( "refresh:2;url=index.php" );
} else {
    echo "Error: " . mysqli_error($conn);
}

mysqli_close($conn);
?>

And this is the HTML snippet with buttons:

 <form  method="post" action="status.php">
   <input type="submit" class="submit-108" name="108" value="10-8">
</form>

<form  method="post" action="status.php">
   <input type="submit" class="submit-107" name="107" value="10-7">
   </form>

   <form  method="post" action="status.php">
   <input type="submit" class="submit-105" name="105" value="10-5">
   </form>

   <form  method="post" action="status.php">
   <input type="submit" class="submit-1015" name="1015" value="10-15">
   </form>

   <form  method="post" action="status.php">
   <input type="submit" class="submit-1023" name="1023" value="10-23">
   </form>

   <form  method="post" action="status.php">
   <input type="submit" class="submit-1097" name="1097" value="10-97">
   </form>

 <form  method="post" action="status.php">
   <input type="submit" class="submit-1042" name="1042" value="10-42">
   </form>

This part works fine, the column gets updated and so on.
The thing is that I have a div on my site that have a php snippet in it that displays the data from the status column with session variable.
And this div dosen't update when I have updated the column status and refreshes the page?
How can I make this happen?
The HTML snippet for displaying the status column:

 <div id="status" class="status"><b>My Status: </b><font color="#6195ff"><?php echo $_SESSION['user']['status']; ?></div></font>

Best Regards Emil

How I use Google Analytics ‘Compare’ Feature to Motivate Me to Grow My Blog

This morning, a reader asked me this question:

“How do you motivate yourself to grow your blog traffic from day to day?”

We’ve covered a whole heap of techniques for growing the amount of traffic you attract to your blog in our Blog Promotion category (also check out this ‘how to find readers page‘ and listen to my recent finding reader webinar) but one thing that has helped me on the ‘motivation’ front lately is the report below in Google Analytics (click to enlarge).

comparing-traffic.png

What you’re looking at is the traffic so far today (the blue line) on Digital Photography School compared to the traffic on the site one week ago (the orange line) – arranged by the hour.

I’ll tell you how to get this report below but first, the reason I love this report is that it tells me whether I’m on track to get as much traffic to my site today as I had this time last week.

Having something to compare traffic keeps me motivated to better the previous week’s result.

Note: I always choose to compare traffic from exactly 1 week previous because on our site we see quite distinct rises and falls in traffic on different days of the week.

In the chart above you can see the day’s traffic started well, with the first 4 hours between 1.7% and 18.1% higher than the previous week.

This all happened while I was asleep so when I checked in at 9am I was pleased! However, I also saw that from 6am-8am that we were beginning to slip behind.

Knowing this gave me a little bit of motivation to find some ways to drive more traffic to the site today.

I took a look at the schedule of Facebook updates that I had planned for the day and decided to move a status update I thought would drive some traffic to be earlier in the day.

That status update went live at 9am and resulted in a nice bump in traffic to get the blue line trending up above the orange again.

I also identified some older posts from my archives that I then scheduled to be tweeted throughout the next 24 hours (based upon my advice from last month to promote old content), which I thought would help us to keep nudging the traffic up higher for the rest of the day.

Having this report open is a great little source of motivation to keep working not only at writing great content but also driving traffic to it.

I also find that having this comparison open during the day (and watching ‘real time’ stats) helps me to spot anomalies in traffic. It helps me to quickly spot if there’s a problem (server issues) or on the flip side it shows me when a post might have been shared on a big blog or social media account.

Knowing this information helps me to react quickly to fix a problem or leverage a traffic event.

UPDATE: here’s how the traffic looked at the end of the day in the comparison view:

Screen Shot 2013-11-21 at 8.56.20 am.png

Things slipped for the last hour or two but over the full day visitor numbers were up by 4.22%.

While a 4% increase in traffic isn’t the most spectacular result I see it is a small step in a larger race I’m running. I know if I can see even a 1% increase in traffic each week that over a year or longer that it’ll significantly grow the site over time.

How to Get This Report

For those of you new to Google Analytics here’s the easy process to get this report (it will only take you a couple of minutes).

1. Login to your Google Analytics Account

2. In the menu click on the ‘Overview’ link under ‘Audience’

Audience_Overview_-_Google_Analytics.png

3. By default you’ll be looking at the last months traffic. You want to drill down now to today so in the top right corner click on the date range and a calendar will open up like this:

Audience_Overview_-_Google_Analytics-6.png

4. Select today’s date.

Audience_Overview_-_Google_Analytics-5.png

5. Check the ‘compare to’ box and then in the new date field that opens up underneath you can put in last weeks date by clicking on the day you want to compare it to. Once you have – click ‘Apply’.

Audience_Overview_-_Google_Analytics-7.png

6. You’re almost done now. You should be looking at a report that compares the two days but by default it’ll be showing you the total of the days in the chart as two dots. You want to view this now as ‘hourly’ so hit the ‘hourly’ tab.

Audience_Overview_-_Google_Analytics-8.png

You now should be looking at the comparison of today’s traffic with the same day last week (note: your current days report won’t yet be complete unless the day is almost over and it does run an hour behind).

Variations on this report to check out

This comparison tool is really useful for a while heap of reports.

For example you can choose to compare one week with another:

Audience_Overview_-_Google_Analytics-10.png

In fact, any period of time can be compared with any other period.

Also, with a date range locked in you can drill down into many other metrics.

For example, earlier today I was doing some analysis comparing this last week with the corresponding week in September, which was just before we did our new redesign on Digital Photography School.

A day by day comparison showed a great improvement in overall traffic.

Audience_Overview_-_Google_Analytics-11.png

Drilling down further, and viewing the two weeks by the hour, was also fascinating and showed that the two weeks had remarkably similar patterns in traffic from hour to hour – so the increase in traffic was very even across the week.

Audience_Overview_-_Google_Analytics-12.png

Under that chart was some interesting data:

Audience_Overview_-_Google_Analytics-16.png

Not only were Visits and Page views well up – but being able to see that bounce rate was slightly down and that average visitor duration was up was encouraging. Seeing Pages Viewed Per Visit was down showed we have an area to improve on (we’re already working on this) and seeing that we had a good rise in ‘new’ visitors was something that should be investigated further.

To investigate the rise in ‘new’ visitors I moved into the ‘Acquisition’ menu on Google analytics. The same date range and comparison is still selected so now I’m able to compare the two periods when it comes to different sources of traffic and see why we’ve had rises in traffic:

It turns out we’ve seen increases in a few area:

Search Traffic is up:

All_Traffic_-_Google_Analytics_and_Preview_of_“Untitled”.png

Facebook Traffic is up (due to my recent experiments):

All_Traffic_-_Google_Analytics-2.png

But interestingly Feed traffic is down (giving us something to investigate).

All_Traffic_-_Google_Analytics-3.png

There are many other areas you can drill down into with the comparison tool – almost anything that Google Analytics has a report for you can compare from period to period and get a great overview of how that stat compares very quickly.

Have a go yourself – do some comparisons and let me know what you find in comments below!

How I use Google Analytics ‘Compare’ Feature to Motivate Me to Grow My Blog
http://www.problogger.net/archives/2013/11/21/how-i-use-google-analytics-compare-feature-to-motivate-me-to-grow-my-blog/
http://www.problogger.net/archives/category/blogging-tools-and-services/feed/
@ProBlogger» Blogging Tools and Services
Blog Tips to Help You Make Money Blogging – ProBlogger
http://www.problogger.net/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg