How to only clear the language cache in Moodle
Sometimes, I only want to clear the language cache in Moodle while leaving the other cached stuff (CSS/JS files, for example) alone. Here's how:
- As administrator, go to Site administration -> Language -> Language settings
- Uncheck the box beside "Cache all language strings" and click "Save changes".
- When the page ...
Fedora 20 desktop setup
Here's what I do after a fresh Fedora 20 install:
No password sudo
$ sudo su -
$ visudo
Add this line at the bottom:
myusername ALL=(ALL) NOPASSWD: ALL
Update everything
Duh.
$ yum update
Install some nice programs
$ yum install vim rxvt-unicode-256color zsh mplayer
Add rpmfusion repo and install some good ...
Fedora 20 Steam OpenGL not using direct rendering
I had this problem after installing steam from rpmfusion:
https://support.steampowered.com/kb_article.php?ref=9938-EYZB-7457
I'm on 64-bit and this seems to be a 32-bit nvidia issue. The solution was to install the 32-bit nvidia drivers:
$ yum install xorg-x11-drv-nvidia-libs.i686
Samsung CLX-3300 series "Install Imaging Unit" message after power outage
I recently had a power outage, and when I turned on my Samsung CLX-3300 printer, it didn't work and gave me an "Install Imaging Unit" message. I accessed my printer through a browser to see if I could get any more information. There was a critical error:
C3-6410 An ...
Bulk Rename Files in Bash
Let's say I have a set of files that all have the same thing wrong with the filename.
$ ls -1 *.ext
badname.other.stuff1.ext
badname.other.stuff2.ext
badname.other.stuff3.ext
I can substitute "badname" with "goodname" for all the files with the following command:
for i ...
Setting up mpd and mpc to use with dmenu and i3 on Arch Linux
- Install mpd and mpc:
[jason@jason ~]$ pacman -S mpd mpc
- I copied the
/usr/share/mpd/mpd.conf.example
file to/etc/mpd.conf
and bent it to my will. Here's what it looks like:[jason@jason ~]$ cat /etc/mpd.conf music_directory "/var/lib/mpd/music" playlist_directory "/var/lib ...
Cups and PostScript problem: lpr file.ps not printing
I was having an issue with a perfectly valid postscript file that wasn't being printed when sending it to the printer with the lpr
command.
It turns out that cups likes to run postscript files through filters before sending it to the printer. Consider this from my /var/log ...
Hostapd on CentOS 6
Here's how I got hostapd working on my CentOS 6 box. This article (if you could call it that) is just a running commentary. I wrote it while figuring things out, so all the silly issues I encountered are included here. Yes, I could write this properly so that ...
Ignoring yum dependency errors on CentOS
I have a machine I manage that has the php53* packages installed, and when phpmyadmin needs to be updated, yum craps out, complaining about phpmyadmin needing php-mysql, etc. I have php53-mysql installed, so these types of error can be safely ignored.
To solve the issue, I downloaded the latest phpmyadmin ...
NFS (v4) Shares on CentOS 6
Here's a few I had to do while trying to set up read-write NFS shares between a CentOS 6 NFS server and an Arch Linux client. The Arch Wiki NFSv4 page was a huge help.
Set up NFS domain
Edit /etc/idmapd.conf
on both the client and the ...
VIM: Open multiple files at once in separate tabs
When I use vim, sometimes I like to open multiple files, each in its own tab. To do this, use the -p option:
[jason@jasonmaur.com]$ vim -p file1 file2
I love the -p option but don't like typing it, so I added the following to my .bashrc file ...
VIM: Remember cursor position
For those who like how vim under CentOS remembers the previous cursor position when you open a file, here's the relevant code from /etc/vimrc. Just put it in your ~/.vimrc file:
if has("autocmd")
augroup redhat
"When editing a file, always jump to the last cursor position
autocmd ...
Arch Linux: Open files directly from Chromium in i3 or Awesome
These instructions are for i3 without using a desktop environment like gnome or KDE. My problem was that I would download a file in Chromium, and when I tried to open it, it would open the file in firefox before being opened in the appropriate application. Here's the solution ...
Install rxvt-unicode on CentOS 5
Here's how to enable the EPEL repository and use it to only install the rvxt-unicode terminal.
Get the EPEL RPM package:
jason@jason:~ [322]$ wget -c http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Install the .rpm:
jason@jason:~ [323]$ rpm -i epel-release-5-4.noarch.rpm ...
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 ...
Awesome WM widget tooltip example
I thought I'd post a simple example of how to set up a custom tooltip for a widget in Awesome.
This example will add an icon to a wibox, and when the user hovers over it, that machine's internal and external IP addresses will be shown. To do ...
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 ...
Problems with Ethernet RTL8111/8168B controller in Arch Linux
Problem
After a fresh Arch Linux install, I was having problems with my ethernet card: it kept flaking out and ifconfig was showing a ridiculous number of dropped packets and errors.
Here's the exact card I have, as described by "lspci | grep -i ethernet":
07:00.0 Ethernet controller ...
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 ...
An Example of Troubleshooting in Arch Linux
I recently had a rather obscure problem with my Intel 5100 wireless card in Arch Linux. I doubt you had the same problem--this post is meant to illustrate the thought process (or lack thereof) while troubleshooting a random issue in Arch Linux.
The Problem
I went about a month without ...
Awesome WM widgets configuration
I've been using Awesome WM for about six months, and I love it. The hard part was configuring everything--especially the widgets. Before using Awesome, I'd never seen nor heard of lua--the scripting language that awesome uses for its configuration files--but I am a programmer by trade, so it ...
Django: convert an application from sqlite to mysql
Thanks to Steve Lord for this one.
Here's how to take a local django application in sqlite and deploy it into a mysql production environment.
First, use django's manage.py script to dump the data to a json file.
cd <django-project-dir>
python2 manage.py dumpdata <appname> > <appname>.json ...
Replace tabs with spaces in Linux
Here's how to replace tabs with spaces in linux. There are 2 ways.
Method 1: the 'expand' command
If you don't mind juggling temporary files around, then the expand command might do:
expand -t 4 -i myfile.txt
This command takes all tabs and converts them into 4 ...
Find and Delete Files Recursively from Linux Command Line
Here's a basic example of how to find files and delete them, recursively.
find -name -exec rm -rf {} \;
That command will look under the directory
Play it safe
You ...
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 ...
Diagnosing Special Character Issues in Mysql
Any webmaster who deals with Mysql and some website that uses PHP has probably run into character encoding issues at some point. Whether it's a user copying and pasting from Microsoft Word and getting those "curly quotes", converting a database from latin1 to utf8, importing data from another source ...
Make SSH stop asking for a login password
Here's how to set things up so that typing "ssh user@host" will just log you in and not ask for a password. You should probably only do this with trusted machines.
- Open a terminal
- Go to your .ssh folder
- Check if you have a 'id_rsa.pub ...
cd ~/.ssh
Testing a Website Before DNS Propogates
When I want to migrate a website to a new server--or even launch a new site--I like to do it well in advance and make sure everything is behaving as expected.
As an example, if I migrate jasonmaur.com to a new server that has shared hosting with Apache VirtualHosts ...
VIM, Xdebug, and PHP 5.3 (compiled from source) on Arch Linux
I finally got sick of using echo statements to debug my PHP scripts, so I decided to install xdebug and use it from within VIM. I followed this guide, but there were some things that were specific to my setup--namely, using Arch Linux with PHP 5.3 compiled from source ...
My VIM Configuration
I use VIM as my main IDE when doing any sort of dev work. So, I invested a few hours configuring things so that it would behave a bit more friendly for me. Here are some features in my configuration:
- Tab completion
- Syntax highlighting
- Capital "H" and "L" move left ...
Nginx + Uwsgi + Django
Wow, I just set up my machine with Nginx and Uwsgi to run this site (which uses Django), and the difference is staggering. This site just got ten times faster. Now, if I could only get everyone in the world to switch to Django and use the same server setup....
Kindle 3 pissing me off
Let me preface this post by saying I love my Kindle. There are, however, some major problems I encountered recently.
The first incident occurred last week. I connected to the internet for the first time in ages, and shortly after, my Kindle became unusable. It was stuck in a perpetual ...
Django: First Impressions
Well, I recently dove back into Django development. I wrote this site from scratch using Django, and wow, is it ever easy to do things.
The learning curve is a little steep: creating a simple page requires you to add a few line of code in a few different files ...