Skip to content

BitBook

  • Online Tools
  • Dev
  • Sysadmin
  • Reviews
  • Machine Learning
  • Home
  • Dev
  • Page 3

Dev

Developer tips, functions, and how-tos.

Query using Avg Ignoring Certain Values

December 3, 2018 mike MySQL

In this case we want to get the average of values but we also want to ignore certain values, say if when the deviceType column

Replace All Characters In a String that Aren’t Alphanumeric

November 30, 2018 mike PHP

Using the preg_replace function you can easily replace all characters in a string that are not alphanumeric. This can be useful for sanitizing a string

Auto Selecting Input Field Contents on Mouse Entering Field

February 21, 2018 mike HTML & UI, JavaScript

You can do this simply with an onclick event like below.

Add an Image to the DOM Dynamically

February 15, 2018 mike HTML & UI, JavaScript

This example will work fairly well cross-browser. In IE it will use new Image and everything else it will use createElement. There are bugs in

Select Last N Characters of a Field

February 12, 2018 mike MySQL

Using the substring function, this example below will select the leftmost 6 characters from a string field named “field_name” in the table tbl_stuff with mysql.

Seeing Full Warnings That Just Happened After a Query

January 4, 2018 mike MySQL

After you run a query on MySQL server you may get warning messages. To see the complete warnings you simply run the command show warnings.

How To Check the SHA Hash of Files

December 14, 2017 mike PHP

When you download software online often the publisher will also provide a file hash to make sure that the file hasn’t been modified or hacked

coalesce Function Handy for Outer Joins and Nulls

November 22, 2017 mike MySQL

The built-in function coalesce in MySQL is great for outer joins where the return or expected answer can be null. Coalesce can be used anytime

A Simple PhantomJS Screenshot Server

November 20, 2017 mike JavaScript

This is a simple screenshot server running over http. You append a url (a urlencoded url) to the server and it returns a PNG image

htmlentities() versus htmlspecialchars() – What’s Better For Emitting HTML?

November 18, 2017 mike PHP

Both htmlentities and htmlspecialchars work the same way in that they are used to emit a string of user input that may contain raw HTML

Posts navigation

«Previous Posts 1 2 3 4 5 6 Next Posts»

Bitbook

  • About
  • Privacy Policy
  • Terms of Service