Sometimes I want to duplicate a Subversion-ed directory, without the .svn folders in each subdirectory. The reason for this is when I want to add/commit this newly duplicated folder, I get an error message because the .svn directory indicates that the files are already in the repository — when it is NOT.
We can do this easily by using tar and the exclude flag:
$ tar -cvf foo.tar ./* --exclude=.svn
When in the command shell, it is too easy to press Tab to autocomplete too many times. I love the text auto complete feature — it saves my fingers — but I overuse it. This results in the annoying “beep” from the system buzzer. Mute it with the command:
$ /usr/bin/setterm -blength 0
You could also append it to the end of your .bashrc — assuming you’re using bash of course — so it runs every time you login.
If, like most Linux users you use Gnome Terminal or KDE Konsole, try exploring around, there are options to mute the system buzzer (or bell), and save the option to mute it as default.
Now this may be common practice for some of you all, but not all.
I’d recommend the (security) practice of having separate databases for your different environments; e.g. development, testing and production. Say for a given user ‘kzhiwei’, I should have up to three databases available for use:
PHPMyAdmin provides excellent support for this function by means of its database selector dropdown, it displays databases the logged in user has access to like:
The following is MySQL syntax with the following points:
- localhost-only access is provided
- usage of the MySQL server, sans access to other databases
- wildcard access to ALL databases that are named like “kzhiwei_”
CREATE USER 'kzhiwei'@ 'localhost' IDENTIFIED BY 'password';
GRANT USAGE ON * . * TO 'kzhiwei'@ 'localhost' IDENTIFIED BY 'password' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT ALL PRIVILEGES ON `kzhiwei_%` . * TO 'kzhiwei'@ 'localhost';
This functions (somewhat) like the rcx.d scripts that run upon startup on a Unix machine. Click “Start > Run…”. Type “regedit” in the text box to open the Registry Editor.
HKEY_LOCAL_MACHINE > Software > Microsoft > Windows > CurrentVersion > Run
You should see a list of applications that run on startup in the right panel. Right-click, and choose “New > String Value”. Name it anything you want, then double-click this new entry and enter in the “Value Data” field:
regedit /s D:\path\to\registry\file.reg
You will need to change the path, of course. The /s basically indicates a silent import of the specified registry file.
I was writing a url-based access control hook for this CI web app recently, and I was scratching my head how to access a database from the hook.
The standard $this->load->database() call doesn’t work because we are not within a controller, and then I stumbled upon the get_instance() method:
$CI =& get_instance();
$query = $CI->db->get("groups");
Now I began my development on the frontend to setup the permissions itself, so I had always thought that the 2nd statement was working well.
When I began applying the hook to the actual app, I found that $ci->db actually referred to the default database that is specified in system/application/config/database.php even if I put in a argument.
Seems like there’s nothing posted about this, so here’s the solution, in case anybody needs it:
$CI =& get_instance();
$db = $CI->load->database("access", true);
$query = $db->get("groups");
Note the semantic differences between the two. I would have much appreciated it if my call to $ci->load->database() triggered some kind of CI error, since it does not, in fact, work correctly.
Tested successfully in v1.5.3. Your mileage will vary.