Wednesday 24 April 2019

Deleting Multiple Tables from your Database using Terminal

Here's a really simple way fo getting all your Database table and deleting them, without having to write and scripts.

I'm using Terminal on a Mac here and I've SSH'd into the server. And then accessed my database so I can type in my queries directly .

What you want to do here is write a 'DROP TABLE' command that will include all of your tables.
Like

DROP TABLE IF EXISTS A,B,C;

To get a full list of all of your tables you can use.

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE';

Using this list I've copy and pasted this into a text editor. You'll need one the has a decent copy and paste facility.

You'll get something like

| table_one |
| table_two |


Replace
"|"
for
","

And then Replace
" ,"
for
""

AND then replace the first "," for "DROP TABLE IF EXISTS "

And the last "," for ';"

You can now copy and paste this into terminal.

Friday 5 April 2019

Google Sheets Scripts - A basic helloworld example

I've written this note after an issue has been noted due to one of my scripts not working in Google Sheets.   And this is a pretty helpful way of troubleshooting any issues.   To work backwards from this. 

Troubleshooting Google Scripts
If you've got an issue you'll see "#NAME?" 

Hover over this and you'll see a report of the issue.




One way to run a test is to build up you're function from scratch .  

Let's just run a 'hello world ' example.
So let's use a function call 'SwapStringTest' .

we can call this using a SUM in the cell A1


=SwapStringTest("Hello World")
In our Scripts ( Tools > Scripts )

We'd use

function SwapStringTest(string){
 
 return  string
 }
This will simple print out 'Hello World' into our first cell.



From here I could pass every section of the function I had and found that the  STARTDATE was producing a NaN value.

to fix is I used
$start = end_date_obj.setDate(0);
 
// for the month prior to
 
$end = end_date_obj.setDate(1);

Tuesday 2 April 2019

How to save for that family holiday

Actually this is more a ‘How I’m going to save’ for my holiday. Everyone’s different and theres a wealth of information online. For example; you may buy 2 coffees a day at £5 . That’d be a saving of £1300 a year, you’re almost done !

I’ve priced it up and we should be able to go on our next snowboarding holiday for around £2,000, a blog on that will follow shortly.

Here’s some things that I’m going to be following. Pretty much all this can be found at moneysavingexpert.com, so be sure to check there for more inspiration for your own savings that can be made.

Moving Bank Accounts . I’ve done this every year for the last 2 years. It’s work £150 ish. Nationwide is a good one to have . I recommended a couple of friends last year and received £200

If you want a Nationwide account then why not email me and I’ll send you a link :)

Compare all your bills against comparison sites. You’ll be able to bring one down by £10 a month for sure. That’s £120 off for the year.

Nectar ( Bonus ) Card. As I work next to Sainsburys and use BP.me I get to collect about £120 a year.

Make you own Cider / Champagne - this is a decent saving for us , I’m putting down for £200 a year.

Micro managing spending. Using Google sheets keep a close eye on what coming in and going out . Monitor the 1st month and then try and stock check and tweak to save £10 a month. I’m taking £110 off the total for this one.

Re ignite my blog and get Adsense vouchers. The aim is to get a £60 voucher for the next holiday. I did want to also reignite my YouTube channel , but you now have to fulfil a fairly high criteria to able to add advertisements.

Sale stuff on Ebay . I’ve taken off all the above calculated amounts from my £2k total and it’s left me with £21.50 a week to raise through Ebay. So every weekend I’ll try and add £20+ off stuff on there. This I fear is going to be too difficult a target to reach, as I'm a few weeks in and have hardly made a penny. So Nuumber 9 here may well come into play.

Promote other offers online a receive bonuses. Like AirBnB you get £15 if others complete a stay - plus they get £25 off . So if you’re thinking of using AirBnb then let me know ;)

Overtime - if all else fails I’ll just have to do a little bit more work ! :(

TaskProfit
Moving Bank Account£150
Compare Bills£120
Nectar Card£120
Make own Cider / Champagne £200
Micro manage spending£110
Re ignite Blog£60
Sell stuff on eBay200
Promote offers for Bonuses.£200
Overtime£840

I'll report back with how I get on.