Skip to main content

Posts

Showing posts with the label web development

Setting up a simple LAMP stack in WSL/Ubuntu

As I've mentioned before, I've been running WSL (Windows Subsystem for Linux) for roughly a year now. It's still a little mind-blowing to me - when I got started Microsoft was about as anti-linux as can be. Weird times! Anyways, I have a fairly simple setup right now that's been working well for me. I'm using an older version of WSL right now, and apparently the newer version is much faster - but this works well enough for my needs right now. This guide assumes you already have WSL set up and working, and can get a bash command line... Install Apache and MySQL This is easy, just run: sudo apt install apache2 and sudo apt install mysql-server and while you're at it, you can start them up: sudo service apache2 start sudo service mysql start You may run into some weird issues - I used this guide if you need any other info. Now you have the most basic bits set up, it's time to get your actual sites up and running locally! Setting up your projec...

WSL and Windows Terminal

I've been back on Windows now for awhile, and WSL has made it quite an easy adjustment. You still get the occasional "WTF Windows" moment, especially after a big update - but I'm pretty happy with it. At the time I just couldn't justify splashing out for a pricy macbook with no escape key and a stupid "hotbar" thing... Anyways, if you're used to working in the LAMP stack and haven't tried out the combo of WSL and windows terminal, give it a try! Or at least try WSL if you don't use command line much. WSL (Windows Subsystem for Linux) basically lets you run linux inside windows. I use it to then run MySQL and Apache/PHP - and I'm good to go. Most of my work happens inside a Windows Terminal window, which has become a pretty slick, configurable terminal. I have a 'projects' directory set up, in which each of my various projects reside. When I want to work on one, all I have to do is edit the apache config to use that particular ...

Security Tips - Incognito Window

A lot of people know what incognito mode (or private mode) is at some basic level. They should use it when they want to do something "private" on the web. But I think most people don't actually understand what it means and how/why to use it. Perhaps this will help. Before we start - cookies are little bits of data used to track you between page loads. Think of it like a fingerprint. They're extremely important for session handling, so that a site can remember who you are from one page to the next. But they're also really handy for things like advertising services to track your activity on the web. When you open a new incognito window (and don't have one open already) - you're starting a new session in your web browser that doesn't have any of the cookies or caching that your "normal" browser window has. In practical terms, this means that when you visit a site, they won't have any history of you (mostly) and you may need to relogin, ...

My Setup - updated

Reading through my old posts, I found it ironic that one of them was about how I was back to using Macs again for work. Ironic because after eight years of using a mac, I switched back to Windows about a year ago. The reason was that my old mac laptop was getting long in the tooth, and I absolutely hated the new macbooks with their janky keyboard and stupid touchbar. Apparently the keyboard has gotten better since then... but I still feel that the macs are just too expensive for what you get. So I switched to Windows, thinking I'd dual-boot with Linux to give me an appropriate development environment. I still spend most of my time at the command line or in vim anyways. But I decided to try out WSL in Windows just to see what it was all about. What a pleasant surprise! I ended up getting a nice 13" gaming laptop that packs quite a punch in a lightweight package. Windows 10 is decent enough. It still has a lot of those annoying Windows quirks, but I can live with that. ...

Handy Perl Functions: Automatically create a form from a database table

Back after a much needed vacation with another perl code snippet. This one creates a simple form using information pulled from the structure of a database table. The form it creates is not meant to be the end product - rather it gets a lot of the "grunt work" done, and you can then edit the resulting form to change fields to drop-downs, remove fields that shouldn't be edited, etc. It will also try to guess at a decent label for each field, based on the table name. This script uses the same get_fields() function that outlined in my previous post. As always, I'm sure this isn't the "perfect" code, and of course it can be improved - but it does work, and may perhaps be a useful starting block for someone else... Usage - pretty simple - run the script and give it a database table name to use. It'll spit the html back out, which you can save in a text file or whatever. #!/usr/bin/perl # creates a basic form from the database table specified use DBI; # ...

Handy Perl Functions: get_fields()

This is the first of what may be a recurring theme - handy custom perl functions. These are custom pieces of code that I find myself using in a wide variety of places, both in dynamic websites and in maintenance scripts. This first one is called get_fields() and its function is quite simple - it returns an array of field names for the table name passed to it. I've used it for things like generating edit/new record form templates, or when writing scripts to convert from database format to another, etc. It uses the perl DBI module, and assumes that $dbh is the database handle that has been set up for use. #--------------------------------------------------------------- sub get_fields { # returns array of fields for the table name passed to it my $table = $_[0]; my (@fields, @tmp) = (); my $qry = "describe $table"; $qry = $dbh->prepare($qry); $qry->execute; while (@tmp = $qry->fetchrow_array) { ...