Linux command line: recursively find all files with a given string
Here's a little script I wrote that I install on any linux server that I do any programming on:
#!/bin/sh
find . -type f -iregex '.*\.\(php\|html\|js\|css\|py\|lua\)$' -print0 | xargs -0 grep -n -i -H "$1"
Note that this searches all .php, .html, .js, .css, .py ...
Bash scripting: rename upper case file extensions to lower case
I recently had one of my quick-and-dirty bash scripts broken because I wasn't expecting to receive a bunch of files named *.JPG as opposed to *.jpg. "Yay! I get to improve my bash script!" I thought to myself. Here's a script that will look at the files in ...
Fun with VIM, regex, and PHP
Introduction
I've been having a lot of fun with regular expressions and vim lately, specifically while programming in PHP. Here are a couple of real-world examples where I saved myself a lot of time and increased my vim+regex skills in the process.
These examples are simple: I just ...
Merge PDF files using Python
Let me start this post with a disclaimer: I know there are tons of tools to do what I've done here, but I love python and look for any opportunity to write python scripts to keep my skills sharp. The script is 27 lines long, it does what I ...
Moodle 2: Get number of students in a course
I searched around and couldn't find anything about getting the # of students in a course in Moodle 2. So I wrote a function to do it. I basically just copy-pasted the needed stuff from the /user/index.php file. Yes, this function is ridiculously long, considering the simple question ...