Enabling error reporting in cPanel

Posted by & filed under PHP, Programming.

Error reporting is disabled server wide. But for a development project, we need it turned on. Adding a php.ini file with the following directives will get the job done: display_errors = off log_errors = On error_log = “error.log” This will cause PHP to write out the error to a file in the same directory as… Read more »

Yii: Returning array data from a ActiveRecord object

Posted by & filed under PHP, Programming.

Two simple ways to convert a ActiveRecord object into a array: Using cHTML::ListDatause CHtml::listData (see www.yiiframework.com/wiki/48/by-example-… ) $users = User::model()->findAll(); $usersArr = CHtml::listData( $users, ‘id’ , ‘city’); print_r( $usersArr ); It will give you array id => city Array { 2 => ‘Paris’, 102 => ‘Riga’, // … } Using array_map (used this method last time, array_map rocks): $words… Read more »

Chocolatey: Windows Package Management

Posted by & filed under Software, Windows.

Chocolatey is similar to yum or apt-get for linux users, but for windows users. It allows the user to quickly install a variety of packages (apps) from the command line… as of this writing there are 1375 unique packages available. Running Chocolatey is cake… heh heh heh. For example, to install Firefox: c:\> cinst Firefox… Read more »

Linux — Finding top n large files

Posted by & filed under Linux, Server Admin.

As a followup to my previous note , I am adding an additional one-liner that is extremely helpful. du -a /path | sort -n -r | head -n 10 Obviously, you can adjust the -n param in the head command to return the top 20 for example.

Backing up a cPanel account via the console

Posted by & filed under Server Admin.

Backing up the account – Log-in via SSH as Root user – Run the pkgacct command to package the account into a tar file: /scripts/pkgacct username The account backup will be created in the current working directory. Restoring the account – Log-in via SSH as Root user – Run the restorepkg command to restore the… Read more »

Migrating MySQL databases from one server to another

Posted by & filed under Server Admin.

Today I needed to begin migrating databases from my live server to the new dedicated database server. The first step is to identify the tables to be moved. Login to the server as per normal me@dev:~$ mysql -u root -p Then list out the tables to find the one(s) we need to move: mysql> show… Read more »

Introduction to PID Control

Posted by & filed under Automotive, EFI Tuning.

DTN0003_Introduction_to_PID_Control%5B1%5D What is PID? PID stands for Proportional, Integral, and Derivative and is a type of feedback control system. It compares a measured value (from a sensor, say) against a desired value (the setpoint or aim) and adjusts outputs to reduce the difference (error) between the two. The controller (or ECU in our case) uses… Read more »

Creating large files on windows

Posted by & filed under Server Admin.

I typically use the dd utility in linux to create large files for testing various things. Today I needed to create a large file in a windows machine. One option is to use dd on a linux box to create the file, and then scp the file over to the windows box. This would work,… Read more »

Quickly renaming multiple file extensions with bash

Posted by & filed under Uncategorized.

I needed to quickly rename a bunch of file extensions in a directory. This one liner made quick work of it: for old in *.JPG; do cp $old `basename $old .JPG`.jpg; done basename, when given a file name and a extension spits out something like this: user@server$ basename derp.txt .txt derp user@server$ Which we then… Read more »

Easiest “check all” ever with jQuery

Posted by & filed under Javascript, Programming, Web Development.

How does it work? This code checks/unchecks all checkboxes within the same fieldset. Simple and semantic. HTML Setup Add checkboxes however you like, just make sure they are within the same fieldset. <fieldset> <!– these will be affected by check all –> <div><input type=”checkbox” class=”checkall”> Check all</div> <div><input type=”checkbox”> Checkbox</div> <div><input type=”checkbox”> Checkbox</div> <div><input type=”checkbox”>… Read more »