Feature request for Notepad++ Function List plugin
Jun 30, 2010 PHP Coding, Technology, Web Development
As the number of visitors continues to increase to my Notepad++ Function List for PHP development post I have frequently been asked if this plugin can do a certain task. This task would be to add multiple rules to one main category. So for instance you have a file that has multiple classes located in it and each class has its own set of variables and functions. The Function List plugin allows us to parse these out and find them. However, in its current state we can only link one parsing rule to another.
Example:
Current State:
-Classes
–Training model extends Model
—Functions
—-__construct
—-EventListing
-Class Variables
–$Month
–$Day
–$Year
What we would like:
-Classes
–Training model extends Model
—Class Variables
—-$Month
—-$Day
—-$Year
—Functions
—-__construct
—-EventListing
I have sent an email to the creator of the plugin(Jens Lorenz) about asking the possibility of changing the plugin and that correspondence is listed below:
Sent from Me on March 17, 2010 7:57 AM
I have used the Function List plugin for Notepad++ for some time now and really enjoy it. My question to you is if it would be possible to add multiple subgroups under one group? For instance I am a PHP developer; I have parsing rules for Classes, Class Variables and Functions. I would love to be able to put Class Variables along with the Functions rules under the classes tree. So instead of having:
-Classes
–printer extends resources
—Functions
—-__construct
—-sqlInsert
-Class Variables
–$security
–$dbI would have:
-Classes
–printer extends resources
—Class Variables
—-$security
—-$db
—Functions
—-__construct
—-sqlInsertI have put up a blog posting of what my current FunctionListRules.xml section looks like at: http://www.danielkassner.com/2010/01/22/using-notepads-function-list-plugin-for-php-development
If you have any ideas that would be great. Thanks!
Sent by Jens Lorenz on March 18, 2010 at 3:27 AM
Hello Daniel,
currently it isn’t possible. Only one level of subgrouping is possible at the moment.
Best Regards
Jens
Sent by me on March 18, 2010 at 7:41 AM
Do you think that this desired functionality will or could be added to a future release? I am sure that it will take some time to accomplish but it would be nice.
Thank you for the quick response.
I did not get a response back from that last email. I wish that I knew more about C++ to modify and send the changes I would make to him for everyone else to enjoy. I am sure he is a busy man just like me which is why I probably did not get a response back.
If you would like to see this feature potentially get added please contact him via email and or post comment here on this posting. You can find his email by opening Notepad++, selecting the Plugins > Function List > Help menu item.
Tags: Function List, Notepad++
Disable web browser tab previews in Windows 7
Jun 24, 2010 Technology, Work
Recently I upgraded my work machine from Windows Vista to Windows 7. While learning the new features of 7 I found that Aero likes to show tab previews of each tab I have open in Firefox, Internet Explorer and Opera. I am the kind of guy that keeps multiple tabs open almost all day long looking up items, coding, … the list could go on so I found this “feature” a pain. As you can see in the below image that I have multiple websites open but you cannot tell if it is multiple windows or multiple tabs.
Now with the picture below you can easily see I have only one window open but four tabs.
To disable tab previews in Firefox you need to do the following:
- Open the about:config page in a new tab or window
- Filter for: browser.taskbar.previews.enable
- By default this is set to true so double click on the true to swap the value to false
- Your done!
Now for Internet Explorer you have to open the the Internet Options. You will do this by opening Internet Explorer and in the toolbar look for the Tools icon which looks like a gear and then select Internet Options at the very bottom.
Once in the Internet Options click on the Settings button in the Tabs section.
Once in the Tabbed Browsing Settings un-check the option that says: Show previews for individual tabs in the taskbar*, then click OK on all the open windows and close out of Internet Explorer.
Now for Opera we have to open the opera:config page in a new tab or window.
Scroll down to a section titled User Prefs and expand this section.
Scroll down towards the bottom of the User Prefs section and un-check the check box: “Use Windows 7 Taskbar Thumbnails”
Once you have unchecked this box scroll down to the bottom of the User Prefs section and click the save button. You will eventually be presented with the following dialog box once complete.
That is how you disable tab previews in Windows 7 for popular browsers.
Tags: Firefox, Internet Explorer, Opera, Web Browser, Windows 7
Get user operating system with PHP
Jun 11, 2010 PHP Coding
Ever wanted to find out what operating system your visitors are using? The following function will allow you to get the user operating system so you can use in a statistics application or show certain content on your website. This will allow server side decisions on what stylesheets to show or any other operating system specific content to be shown/hide.
/* Author: Daniel Kassner Website: http://www.danielkassner.com */ function getOS($userAgent) { // Create list of operating systems with operating system name as array key $oses = array ( 'iPhone' => '(iPhone)', 'Windows 3.11' => 'Win16', 'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)', // Use regular expressions as value to identify operating system 'Windows 98' => '(Windows 98)|(Win98)', 'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)', 'Windows XP' => '(Windows NT 5.1)|(Windows XP)', 'Windows 2003' => '(Windows NT 5.2)', 'Windows Vista' => '(Windows NT 6.0)|(Windows Vista)', 'Windows 7' => '(Windows NT 6.1)|(Windows 7)', 'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)', 'Windows ME' => 'Windows ME', 'Open BSD'=>'OpenBSD', 'Sun OS'=>'SunOS', 'Linux'=>'(Linux)|(X11)', 'Safari' => '(Safari)', 'Macintosh'=>'(Mac_PowerPC)|(Macintosh)', 'QNX'=>'QNX', 'BeOS'=>'BeOS', 'OS/2'=>'OS/2', 'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)' ); foreach($oses as $os=>$pattern){ // Loop through $oses array // Use regular expressions to check operating system type if(eregi($pattern, $userAgent)) { // Check if a value in $oses array matches current user agent. return $os; // Operating system was matched so return $oses key } } return 'Unknown'; // Cannot find operating system so return Unknown }
An example of how this would be used:
echo getOS($_SERVER['HTTP_USER_AGENT']);
This script can be used with the Get Browser Type, which also has the same structure as this script.
Change outgoing BlackBerry PIN message sender email address
Jun 9, 2010 Cell Phones, Technology, Work
At the organization I work for we have a BlackBerry server setup with around 30 users. Works great for those employees that don’t get computer access but still need access to get emails to stay up to date on daily schedules and patient care. However when there is a problem that affects email on the devices it is best to notify those staff there is an issue or that the issue has been resolved. This is where using PIN messaging comes in very handy. This last time I had a device in my hand and I noticed that the email address on the PIN message was from admin@yourcompanydomain.com instead of something related to our organization. Below I will show you how to change this so that your outgoing PIN messages have an email address that actually correlates with your own business.
* I am doing these processes on BlackBerry Server 5 and not 4. The process for 4 will be different as it is not a browser based management.
- Open your BlackBerry Administration Service page and log in.
- Navigate to the Devices > Wireless activations > Device activation settings
- You will notice at the top of this page there is a Email initialization message section with the Sender address by default as: admin@yourcompanydomain.com. Select the Edit activation settings button to change this
- Change the Sender address field to an actual email of your company and then select Save all
Once you have changed this all of your outgoing PIN messages will have the new email address as the sender name.
Tags: BlackBerry, Cell Phones, Email
Prevent direct file access
Jun 4, 2010 PHP Coding
Do you have PHP files that you do not want visitors to directly run but would still like to use them in your code? Here is a little trick picked up from the code in the phpBB forum code.
Create a file named config.php or some other file that you are going to include before any other code. In this file put the following:
define('INMYSCRIPT', 1);
This code creates a defined variable INMYSCRIPT which can be named as anything that you want. Then on every other page in your script that you do not want to be ran on their own put the following: (This filename is code.php)
if(!defined('INMYSCRIPT')){ echo 'You cannot access this file directly.'; die; } // Whatever other code you wish goes below here echo 'This file is safe to be ran';
Now, instead of the file outputting any data to the browser that could be harmful, the only content output is: “You cannot access this file directly”. You could very easily create a re-direct script to transfer them to a specific page or you could modify the text to any other HTML or other content you wanted.
Open up your web browser and try accessing code.php. You should get that error message that we created. Now if you create one last file that we will name as test.php, place the following:
require('config.php'); require('code.php');
Now if you try accessing the test.php file from your web server you will be shown: “This file is safe to be ran”.
Calculate a percentage
Jun 4, 2010 PHP Coding
Below is a quick function that simplifies the process of calculating a percentage in PHP.
function percent($Amount = 0, $Total = 0, $Decimal = 0) { // Make sure our numbers are actually numbers $Amount = (INT) $Amount; $Total = (INT) $Total; $Decimal = (INT) $Decimal; // Cannot divide by zero so check if Total = 0 if ($Total === 0) { return 0; } $p = $Amount / $Total; // Multiply by 100 to move decimal point to correct location $p *= 100; // Return the percentage with specified decimal places return number_format($p, $Decimal); }
Then to use this code you can do:
// prints out 10% on the screen echo percent(10, 100),'%';
Trip up the Blue Star Highway in Michigan
Jun 2, 2010 Photography, Transportation
Back on May 22 I took a nice trip up the Blue Star Highway in Michigan. The section I was riding was from Hagar Shore Rd (Exit 7 on US 31/196) north of Benton Harbor to Glenn Michigan. I just had to stop and take a few shots with the Canon 7D I was carrying in my backpack. As you can tell from the photos it was kind of foggy and it was a bit chilly but a great escape for a ride.
Tags: Canon 7D, Google Map, Michigan, Photography, Suzuki, SV650
Add suffix to a number
Jun 1, 2010 PHP Coding, Technology
Have you ever had to dynamically add the suffix to a number? (ie. st, nd, rd, th)
/* Author: Daniel Kassner Website: http://www.danielkassner.com */ function number_suffix($i) { switch( floor($i/10) % 10 ) { default: switch( $i % 10 ) { case 1: return 'st'; case 2: return 'nd'; case 3: return 'rd'; } case 1: } return 'th'; }
Then to use the code you would do like:
$number = 10; // This will display 10th echo $number,number_suffix($number);
Get Browser Type
Jun 1, 2010 PHP Coding, Technology
Have you ever wanted to create a stats application that identifies the users browser type? The following function will allow you to easily do just that. This function can be expanded by adding more values to the $browser array so you can match other browsers. This getBrowser() function parses the $_SERVER['HTTP_USER_AGENT'] variable to get the current browser.
/* Author: Daniel Kassner Website: http://www.danielkassner.com */ function getBrowser($userAgent) { // Create list of browsers with browser name as array key and user agent as value. $browsers = array( 'Opera' => 'Opera', 'Mozilla Firefox'=> '(Firebird)|(Firefox)', // Use regular expressions as value to identify browser 'Galeon' => 'Galeon', 'Mozilla'=>'Gecko', 'MyIE'=>'MyIE', 'Lynx' => 'Lynx', 'Netscape' => '(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)', 'Konqueror'=>'Konqueror', 'SearchBot' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)', 'Internet Explorer 8' => '(MSIE 8\.[0-9]+)', 'Internet Explorer 7' => '(MSIE 7\.[0-9]+)', 'Internet Explorer 6' => '(MSIE 6\.[0-9]+)', 'Internet Explorer 5' => '(MSIE 5\.[0-9]+)', 'Internet Explorer 4' => '(MSIE 4\.[0-9]+)', ); foreach($browsers as $browser=>$pattern) { // Loop through $browsers array // Use regular expressions to check browser type if(eregi($pattern, $userAgent)) { // Check if a value in $browsers array matches current user agent. return $browser; // Browser was matched so return $browsers key } } return 'Unknown'; // Cannot find browser so return Unknown }
How to use this code:
echo getBrowser($_SERVER['HTTP_USER_AGENT']); $browserType = getBrowser($_SERVER['HTTP_USER_AGENT']); echo '<br />I am currently running '.$browserType.' as my web browser';
This would produce the following if I were(and am) running Mozilla Firefox:
Mozilla Firefox
I am currently running Mozilla Firefox as my web browser
If you wanted to see a larger list of browser user agent strings to expand this code you can find them at: User Agent String dot com
Tags: Coding, PHP, Web Browser
