...
  • Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp
KEEP IN TOUCH

Most Popular

  • osTickets > Reports v3.4 (10594)
  • HTPC > Setup Windows 7 as a Media Center with XBMC (5658)
  • osTicket > Auto-Assignment Rules (3295)
  • osTicket > View headers for original email message (2042)
  • Ubuntu 10.10 VNC Login Screen (1939)

WebDev > Allow PHP in WordPress Widgets

Jan26
2012
Leave a Comment Written by Scott Rowley

The following will allow for you to post PHP in your widgets:

Place in your functions.php file
Appearance > Editor > Theme Functions (functions.php)

add_filter('widget_text', 'php_text', 99);

function php_text($text) {
 if (strpos($text, '<' . '?') !== false) {
 ob_start();
 eval('?' . '>' . $text);
 $text = ob_get_contents();
 ob_end_clean();
 }
 return $text;
}

Now you can place php code so long as its within its <?php and ?> tags.
Credit

ajax loader
Posted in Web Development - Tagged allow, functions, php, theme, widget, wordpress
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

WebDev > CSS Stylings

Jan25
2012
Leave a Comment Written by Scott Rowley

Just starting to make a note of some of my CSS creations:

Informational Box

SudoBash is proud to announce our newest office location

123 Kittens Street conveniently located 1 mile from LOLcat lane.

 <style type='text/css'>
.info {
  border: 2px solid #D8D8D8;
  margin: 10px 0px;
  background-repeat: no-repeat;
  padding: 10px 0 10px 150px;
  background-position: 10px center;
  color: #00529B;
  background-color: #E0E0E0;
  background-image: url('/images/info.png');
}
</style>

<div class="info"><strong>SudoBash is proud to announce our newest office location</strong><br><br>

123 Kittens Street conveniently located 1 mile from LOLcat lane.</div>
ajax loader
Posted in Web Development - Tagged css, dev, development, html, info, information, web, Web Development
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

BASH > Recursively set file/directory permissions

Jan19
2012
Leave a Comment Written by Scott Rowley

Move to the directory you want to start chmodding files in and run the following:

Recursively set FILE permissions.

find . -type f -exec chmod 644 {} \;

Recursively set DIRECTORY permissions.

find . -type d -exec chmod 755 {} \;

*Note, obviously you can change the chmod number to whatever you want, 777, 600, etc.

ajax loader
Posted in BASH - Tagged chmod, chmodding, directory, file, files, find, permission, recursive, recursively, set, type
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Web Dev > Select first n words of a sentence

Jan16
2012
Leave a Comment Written by Scott Rowley

Useful for giving a teaser of a post and then including … on the end followed by “Read More”.

$sentence = "This is my sentence, there are many like it but this one is mine. What do you think of it?";
$n = 10; // Customize to however many words you want to actually show
$teaser = implode(' ', array_slice(explode(' ', $sentence), 0, $n));

echo $teaser."...READ MORE

Which should result in:
This is my sentence, there are many like it but…READ MORE

ajax loader
Posted in PHP, Web Development - Tagged array_slice, customize, echo, explode, implode, n, php, post, read more, sentence, teaser
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Web Dev > Keep your copyright date current automatically

Jan12
2012
Leave a Comment Written by Scott Rowley

Here’s a quick little tip I’ve been using recently with the new year having rolled around. I’ve started replacing all of my © 2011 code with the following. This will always return the date of the current year. That way you don’t have to remember to update it all over the place every time we “celebrate” a new year.

<?php echo date('Y'); ?>

So now I don’t ever have to update this post and the current year should always be reflected here: 2012

ajax loader
Posted in PHP, Web Development - Tagged automagically, automatic, automatically, copy, copyright, current, date, echo, php, year
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Web Dev > Populate PHP/HTML table from MySQL database

Jan11
2012
Leave a Comment Written by Scott Rowley

Hey again all, for this post I’ll be covering how to populate a PHP/HTML table by way of looping through a table in mysql. I’ll be using the sample database provided by http://www.mysqltutorial.org/mysql-sample-database.aspx which has to do with models (cars, planes, ships, etc). Everyone has differing levels of knowledge so I’ll be including some basics as well such as connecting to the mysql database (and closing it later on).

The table we’ll be using in the database is ‘products’. It has the following columns:

productCode        - A unique inventory number
productName        - Name of the product
productLine        - Basic descriptor, 'Motorcycles', 'Classic Cars', etc
productScale       - This models scale size
productVendor      - Company that built the model
productDescription - Detailed description of product
quantityInStock    - Current number of quantity in stock
buyPrice           - Listed price on the "website"
MSRP               - Manufacturers Suggested Retail Price

If I know I’m going to be using my mysql database in multiple files I’ll always throw the connection in something like a ‘dbconnect.php’ file. Here’s an example:

<?php
  mysql_connect("localhost", "MYSQL_USERNAME", "MYSQL_PASSWORD") or die(mysql_error());
  mysql_select_db("MYSQL_TABLE") or die(mysql_error());
?>

Now you can include this in every file, or better yet in your header file which will get included everywhere else. So for example in your header.php file you could throw in:

<?php
  require_once('dbconnect.php');
?>

Alright, so now you’ve got your connection to your database and the appropriate database selected. We’ll skip over the other content that you want to eventually add and say (for this example) that we want to list all of our models. We’ll look at doing this a few different ways, first off we’ll go simple and just request everything from the database and then we’ll tell php how to spit that all out to us.
READ MORE »

ajax loader
Posted in MySQL, PHP, Web Development - Tagged connect, html, limit, loop, MySQL, nest, nested, php, query, result, select, sql, where, while
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Web Dev > Validate Password creation with PHP

Dec06
2011
Leave a Comment Written by Scott Rowley

The following can be used to test for different criteria in passwords.

<?php

$min = 6;
$max = 20;
$password = $_POST['password'];
$confirmpw = $_POST['confirmpw'];

if($password != $confirmpw){
    $error .= "Password and Confirm password do not match! <br />";
}

if( strlen($password) < $min ) {
    $error .= "Password too short! <br />";
}

if( strlen($password) > $max ) {
    $error .= "Password too long! <br />";
}

if( !preg_match("#[0-9]+#", $password) ) {
    $error .= "Password must include at least one number! <br />";
}

if( !preg_match("#[a-z]+#", $password) ) {
    $error .= "Password must include at least one letter! <br />";
}

if( !preg_match("#[A-Z]+#", $password) ) {
    $error .= "Password must include at least one CAPITAL! <br />";
}

if( !preg_match("#\W+#", $password) ) {
    $error .= "Password must include at least one symbol! <br />";
}

if($error){
        echo "Password Failure: $error";
} else {
  // Code to execute on success.
}
?>
ajax loader
Posted in PHP, Security, Web Development - Tagged check, confirm, password, php, secure, security, validate, validation, verify
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

vmWare > Boot to fullscreen VM after host boots.

Nov02
2011
Leave a Comment Written by Scott Rowley

Create a shortcut with the following TARGET.

“C:\Program Files\VMware\VMware Workstation\vmware.exe” -X “C:\Users\YOUR_USER\Documents\Virtual Machines\VMNAME\FILENAME.vmx”
New Shortcut

The -X opens in Full screen (before you go looking, I’ll save you the trouble – there is no dual screen option as of the writing of this article.)
Replace “C:\Users\YOUR_USER\Documents\Virtual Machines\VMNAME\FILENAME.vmx” with your vmx file location.
The quotes are required.

Put the shortcut into the Windows Startup folder
Windows Startup Folder

Voila!
Ubuntu

ajax loader
Posted in Ubuntu, vmWare, Windows - Tagged fullscreen, host, vmware, workstation boot
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Web Dev > Use onClick to clear a value

Oct17
2011
Leave a Comment Written by Scott Rowley

The following can be used to clear a value. I regularly use this for website search bars.

onclick="this.value=''"

Of course if you wanted to you could also have it change the value to something else instead of blanking it out.

onclick="this.value='New Value'"
ajax loader
Posted in Web Development - Tagged clear, dev, development, html, Javascript, onclick, this, value, web
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Recursively set group permissions to match owner permissions

Oct10
2011
Leave a Comment Written by Scott Rowley

I have had need of this multiple times in the past, just making a note of it here:

chmod -R g=u directory_name/
ajax loader
Posted in BASH - Tagged chmod, directory, group, owner, permissions, recursive
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« Older Entries

Be Heard!

Authors needed! Feel like sharing your tech wisdom with the world? We are looking to expand our writer base and would love to hear from you. We need articles on any relevant technology/software/media/howto/etc (Well...lets at least hold to the legal stuff ;)

Just email scott (at) sudobash (dot) net

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

RSS HowToGeek

  • Chun-Li in Battle [Wallpaper]
  • The Best Tools to Check for Windows Software Updates – Analysis Report
  • Geek Trivia: What Popular 1980s Computer Game Blatantly Ripped Off Super Mario Bros?
  • Juice Boxes, Watermelons, and More Slo-Mo Exploding in a Microwave [Video]
  • What You Said: Your Battery Life Maximizing Tips

RSS TheGeekStuff

  • C Pointer to Pointer, Pointer to Functions, Array of Pointers Explained with Examples
  • Linux Time Command Examples
  • How to Setup Rsyslog Remote Logging on Linux (Central Log Server)
  • 6 Nagios Command Line Options Explained with Examples
  • TCP Attacks: TCP Sequence Number Prediction and TCP Reset Attacks

RSS LifeHacker

  • This Week’s Most Popular Posts: January 21-27 [Highlights]
  • Belvedere Updates, Can Now Automate Your Folders and Automatically Send Files to iTunes [Belvedere]
  • Daily App Deals: Get Mobitee Golf Assistant for iOS for Free in Today's App Deals [Deals]
  • SwitchMe Dual Boots Your Android with Multiple Profiles for Better Battery Life, Extra Privacy, and More [Android Downloads]
  • The Nerdist Way: A Self-Help Guide For Me (and Probably You) [Book Review]

EvoLve theme by Blogatize  •  Powered by WordPress Sudo Bash
By Geeks - For Geeks

Back to Top