Get all files in the directory as a comma separated list
You can use the ls command to get a list of all the files in the current directory as a comma separated list using the following:
ls -m
If you want to exclude any subdirectories, try this:
ls -mp | grep -v "/"
Note you may end up with a trailing comma depending on whether the last item is a directory or not.
Google Keyboard
If you own a Samsung Galaxy tablet, I’d highly recommend switching over to Google Keyboard (installed, free from the Google Play store).
In my experience, I’ve had issues with the standard Samsung keyboard application, where a copy and paste operation has actually broken the entire OS and required a reset. Not fun.
Plus, google keyboard works really well.
Replacing Google Reader
After some investigation, I’ve settled on my replacement for Google Reader, InoReader. It authenticates and synchronises with your existing Google account and reader subscriptions (although I had to go through and mark some subscriptions to unread which I had already read). To make things easier, get your existing google reader to 0, or simply mark all as read when you make the switch.
Note along the way I tried Feedly, but I couldn’t get comfortable with the interface and gave up in the end. However I think other people will quite like it, and it does have a lot of platform support.
For larger articles that I want to read on my tablet or archive, I use Pocket. I find this much better than “starring” articles.
On iOS I use Byline to read my subscriptions. On Android I have been using EasyRSS.
These are just my personal preferences, there are hundreds of options out there and they all depend on how you consume RSS feeds.
Follow files with less
Like tail -f which almost everyone seems to use, you can also follow files with less, which I find better for navigating through bigger files using:
$ less +F example.log
You can abort when you need to with ctrl+c and then scroll around.
Another good option if you want syntax highlighting is multitail.
Filezilla synchronised browsing
Filezilla, has a cool feature where you can set up your FTP/SFTP accounts to use synchronised browsing. What this means is that if your local and remote directory structures have the same structure (which they usually do when doing things like uploading web sites), then it will browse both your local and remote directories together.
This is set in Site Manager, select the relevant site, and look in the advanced tab. Make sure you also set your default local directory and default remote directories so they match up to give you the same “root”. That is, they are at the same level for synchronised browsing.
Show staged differences in git
You can use git diff to also show staged (cached) changes and compare them to the last committed change as follows:
$ git diff --staged example.php
This will show you the differences between the last committed change and the changes you have made, but not yet committed (i.e. are staged). Note you can use (—cached which means the same thing).
Select Users from Alfresco Database
The following SQL (designed for MySQL as it uses group_concat) pulls out a list of users from the Alfresco database by searching for the appropriate nodes in the Alfresco node table and pulling user node properties including username, firstName, lastName and email address.
select
node_id,
group_concat(string_value)
from (
select
node_id,
qname_id,
(select local_name from alf_qname where id = qname_id) as qname_type,
string_value
from alf_node_properties
where node_id in (
select id from alf_node
where type_qname_id = (
select id from alf_qname where local_name = 'person'
)
and qname_id in (
select id
from alf_qname
where local_name in (
'username',
'firstName',
'lastName',
'email'
)
)
)
) alf_users
group by node_id;
MySQL group_concat()
The group_concat() function in MySQL is really nifty. It concatenates all rows that match your group by statement into a single, comma separated string. Essentially, it transposes rows to columns.
Take this example. Say you have a table that stores a set of locations by country, state and city.
You could then write SQL as follows:
select
country,
state,
group_concat(city) as cities
from locations
group by country, state
What this is saying is bring back 3 columns, country, state, and for each combination of country and state, a list of all of the cities in that country and state as the third column (called cities).
This is actually a phenomenally handy thing to be able to do, and something that is much harder to do in any other DBMS.
Git undo modifications
Much like you can get a list of deleted files, you can also get a list of modifications and then check them all out (undo) in one command using the following:
git checkout $(git ls-files -m)
This is effectively an “undo” of all modifications in the given branch (but it doesn’t impact added or deleted files).
Access Last Command Line Result
A nifty command to access the last result is $(!!).
For example you can do something like this:
$ find . -type f -name example.txt*
./a/folder/example.txt
$ vim $(!!)
As I only had one result from the find, I can that result and call vim on that file.
Alfresco Logs when using Alfresco Service
One very handy feature for Alfresco system administration is the alfresco service that is automatically installed on Linux environments. However, there is a catch when using this service, your various logs (e.g. alfresco.log, share.log, solr.log) can end up in the very root of your file system.
One partial workaround is to modify the various log4j configuration files and hardcode them to a specified location. However, there is a better way: edit the alfresco service.
By convention, I like logs to go somewhere sensible like /opt/alfresco/4.1.4/logs (or appropriate based on your Alfresco version). This folder doesn’t exist out of the box so you will need to create it. If choose another location, be sure to adjust the steps in this article accordingly.
Modify your service (e.g. /etc/init.d/alfresco — this depends on your Linux distribution) as follows:
Step 1:
First stop alfresco if it is currently running.
At the top of this script after RETVAL=0 add the following line (and adjust to match your installation path):
ALF_HOME=/opt/alfresco/4.1.4
Step 2:
Change the start() command to go to your logs folder (make sure it exists) and then start the alfresco.sh script (which is one level above the logs folder). You could also use $ALF_HOME/alfresco.sh as a full path. Obviously adjust these lines to suit.
cd $ALF_HOME/logs
../alfresco.sh start “$2”
Step 3:
In the same way as start(), change stop() to do a similar thing:
cd $ALF_HOME/logs
../alfresco.sh stop “$2”
Step 4:
Near the end of the script there inside the case … esac statement also change the script as follows:
cd $ALF_HOME/logs
../alfresco.sh “$@”
Step 5:
Clean up / move your old log files around as appropriate and then start alfresco. You should find all log files are now in the logs folder, without having to modify any of the delivered log4j configuration files.
Git remove multiple deleted files
Sometimes when you are committing changes in git you’ll find that a number of files have been deleted.
You could manually set these files to delete by individually issuing the command:
$ git rm filename
However, there is a shortcut. If you issue the command:
$ git ls-files --deleted
It will return a list of all files that are flagged as deleted.
You can then simply pass that list to git rm, using a combined syntax like this:
$ git rm $(git ls-files --deleted)
(Just don’t forget the —deleted parameter!).
Disallowed Key Characters Error
I loaded a CodeIgniter site today and received a blank page with just the message “Disallowed Key Characters”.
There are myriad of scenarios that can cause this to occur. In my particular example, it occurred due to the fact that my application/config.php file had the following set:
$config['cookie_prefix'] = "<CHANGEME>_";
I had put that in as a placeholder, but the “<” and “>” symbols are not allowed in this particular config value and throw this error. There are other symbols that will also cause this, so something to watch out for.
After you change this, remember to clear your browser cookies too.
“If you follow the herd, you’ll end up stepping in a lot of shit!”
jQuery Reveal Tips
I’ve mentioned the jQuery reveal modal plugin before, and I think there are two really good tips about how to use it that aren’t clear on their site which might come in handy to people who use it.
To trigger jQuery reveal on page load for the relevant reveal element (e.g a div):
$(document).ready(function() {
$('div#your-reveal-div').reveal();
}
Similarly to close on clicking of the “close” (X) button:
$('a.close-reveal-modal').on("click", function(e) {
$('div#your-reveal-div').trigger('reveal-close');
});