Renaming within filenames

Renaming within filenames

I have renamed a Moodle module I’m writing from mod_dumgalinduction to mod_dumgalchecklist because it seems to have more use beyond the original idea (move the student induction checklist off the paper form). To search and replace all of the text within the php files is quite easy: I renamed the lang file from dumgalinduction.php to dumgalchecklist.php manually. I always get in a muddle changing the names of the files in the backup folder so I used this rename command to…

Read More Read More

Prepare a block of text to display in php

Prepare a block of text to display in php

I need to append the contents of a text file to a string in php line by line. awk and sed are very useful for such things. Here is the content of the file. It’s a fairly standard bit of bootstrap HTML. I need to replace all of the ” characters with ‘, then start each line with $string.=” and end each line with \n”; Cat divs.txt simply prints the content of the file. This is piped into the sed…

Read More Read More

ssh login with no password

ssh login with no password

It’s really inconvenient to continually enter your password when ssh’ing among internal servers. Especially if your password is long. I have set up password-less login on some of our linux servers using this excellent guide. I had already set up a private/public key pair on my mac in the .ssh folder in my /Users/ folder: It’s necessary to send your public key to the server you intend to log into. The provided command does not work because the hidden directory…

Read More Read More

Blob problems

Blob problems

I have recently encountered a problem loading BLOBs from SQL server 2012. Until moving to PHP 7.x we previously used the mssql libraries. Now we are using the dblib driver in PDO the php_mssql libraries are gone for good. It appeared that, once again, files were being truncated to 60Kb (an old problem). It’s not clear why this started to break again. No new packages have been installed. Using php_mssql it was possible to: These ini_set statements don’t have any…

Read More Read More

Randomise column in CSV using awk

Randomise column in CSV using awk

In packaging our learning analytics automation system I have provided test data in CSV files on the Virtualbox machine. These CSV files contained actual student ID numbers from our College so I needed to replace them with random, non-repeating information. I have substituted these with Student(n) to represent the real students for this post. I found an excellent AWK entry on the evergreen Stack Overflow which fit my particular use case. This is very close to what I need to…

Read More Read More

Date offsets in PHP

Date offsets in PHP

I have been alerted to a problem with some of our CTS course search results which were displaying the wrong availability times. The times for the sessions are held in UNIX timestamp form which turned out to be the root of the problem. Each of the courses are due to start at 9am but two were presented as 8am on the website. Adding to the confusion was the fact that the HTML web service output showed the correct times where…

Read More Read More

Alternatives for directory listing in shell scripts

Alternatives for directory listing in shell scripts

I often have to repeat a process for every file of a certain type in a given directory. I have been use to using this ls dialogue: #!/bin/bash for file in `ls /data/video`;do   ffmbc – i $file -vcodec prores $file.mov done; This has some drawbacks as it tends to print the entire path to the file so you are restricted to where you put the output files. I have recently spotted a topic discussing this and their solution gives…

Read More Read More

I’m working solely on a Mac

I’m working solely on a Mac

I have shifted all of my work on to my Mac. The keyboard is nice but I need to use some new shortcut keys to achieve the things I used to do on my Linux workstation. In particular the nano editor has some peculiarities when navigating around. I can still use CTRL+shift+_ and type a line number but I couldn’t find Page Up, Page Down, Top, Bottom and skip a word forward and backward so here they are (After working…

Read More Read More

Delay UI Elements in iOS

Delay UI Elements in iOS

In my iOS app for the front reception desk I provide a staff sign in/out facility for staff visiting another campus site. The theory is that anyone who works at Dumfries campus visiting Stranraer will sign in via the iPad. The problem is that there are 200+ records to be loaded from web service on the screen with the sign in / sign out buttons. It is possible if you are very fast to attempt to load one of the…

Read More Read More