Author Archives: JRevell

Joys of Telesales

I’m starting to get a bit fed up of all the telesales calls which I get at work. There’s only so many companies which can bid for landlines/mobile phones/stationary/printer ink etc. All are very similar in price and although may save you 10p on your monthly line rental.. Is it worth it for your time spent messing about? Usually not!

For the usual telesales calls, I usually tell the truth and say that we get everything through the sister company, on some occasions be blunt and say that I’m not interested – but usually they ring back up a month later trying to get your business..!

On odd occasions I use the following Anti Telesales / Telemarketing script and see how far I can get. Using the script, strangely I rarely ever get them ringing back. The furthest I’ve ever got is asking about the toothpaste they use, but on most occasions after a few questions the person on the other end gets the picture and makes a note never to ring you again.

I’m not the original author of this document, not sure who the original author is.

EDIT: Here’s the original author.

Telesales Counter Script

Monitoring Azure SQL Database CPU Usage

Sometimes there is a need to monitor Microsoft’s Azure SQL database usage, but your after the raw figures rather than an impressive looking graph.

Running the following SQL against the master database will give you the recent information:

DECLARE @DatabaseName nvarchar(50);
SET @DatabaseName = 'databasename';

SELECT getdate() AS [Current Server Time];

SELECT start_time AS [Start of Period],
end_time AS [End of Period],
active_session_count AS [Sessions At End of Period],
avg_cpu_percent AS [Average CPU Usage %],
avg_physical_data_read_percent AS [Average Log Reads %],
avg_log_write_percent AS [Average Log Writes %]
FROM sys.resource_stats

WHERE start_time > DATEADD(minute, -240, GETDATE()) AND database_name = @DatabaseName
Order By start_time DESC;

Here’s an example of the results:
Azure SQL Database Processor Usage

Remote Vulnerability in BASH

There’s been a report of a new code injection attack in Linux, using environment variables. In order to test to see if your system is vulnerable, run the following code from SSH:

env x='() { :;}; echo vulnerable' bash -c "echo this is a test"

If your OK, you should get something like this:
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x'
this is a test

If not, you will get something like this:
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
vulnerable
this is a test

BASH Screenshot

If vulnerable, it’s recommended to patch the BASH installation.

Further Information

Common SQL Queries

Frequently I use SQL with the work I do with Orbis Taskcentre.

There’s some queries which I use quite a lot and have to always look up on the internet or work out how to do, so to save time, here’s my list:

Date Part of Date Time
DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))

First Day of This Month
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)

First Day of Last Month
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0)

First Day of Next Month
DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0)

Last Day of Current Month
DATEADD(DAY, -(DAY(DATEADD(MONTH, 1, GETDATE()))),DATEADD(MONTH, 1, GETDATE()))

Last Day of Last Month
DATEADD(DAY, -(DAY(GETDATE())), GETDATE())

Last Day of Next Month
DATEADD(DAY, -(DAY(DATEADD(MONTH,0,GETDATE()))),DATEADD(MONTH, 2, GETDATE()))

Select Text Before Space
This also checks to see if a space exists, if there’s no space it returns the full text in order to prevent an error
LEFT(@Column, CASE WHEN charindex(' ', @Column) = 0 THEN LEN(@Column) ELSE charindex(' ', @Column) - 1 END)

Count Workdays Between Two Dates
(DATEDIFF(dd, @StartDate, @EndDate) + 1)-(DATEDIFF(wk, @StartDate, @EndDate) * 2)-(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END)-(CASE WHEN DATENAME(dw, @EndDate) = 'Saturday' THEN 1 ELSE 0 END)

Get paid to shop

Dont really like using blogs for advertising, however a few friends and family have not heard of this, so here goes…

Services such as Top Cashback, Quidco etc allow you to get cash back when ever you buy something online.

There’s no guarantee that you will get paid, but every little helps. Typically you get like 5% back off what you buy.

Sometimes you can even get more cash back than your initial investment. For example depositing £25 on William hill got me £57 cash back.

Big wins are things such as sky, virgin media and insurance.

Finally…

This site has been up for many years, so I have decided that it’s about time that this site was used for something interesting…

Hopefully things should appear on here on a more regular basis. Time will tell!