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

Most Popular

  • osTickets > Reports v5.0 (68716)
  • osTicket > Send reply to alternate/additional email address(es). (53639)
  • Web Dev > Populate PHP/HTML table from MySQL database (37469)
  • HTPC > Setup Windows 7 as a Media Center with XBMC (29496)
  • osTicket > Auto-Assignment Rules (25776)

BASH > Fix vi arrow keys in insert mode

Mar28
2013
Leave a Comment Written by Scott Rowley

Full credit to Michael S. Kirkpatrick

The following fix saved my sanity

I prefer using vi as my text editor, because it is clean and simple. I don’t have to go searching for commands from drop-down boxes and other GUI crap. But arrow keys and backspace are sometimes problematic, depending on the OS you’re using. In my case, I frequently ssh from Linux to SunOS, and the SunOS vi doesn’t like my keyboard mappings.

Here is my (partial) solution. Open ~/.exrc and add the following lines. In case it is not obvious, do not type the letters inside brackets, but press those keys instead (i.e., [ctrl-v] means you hold the Ctrl key while pressing v).

– Michael S. Kirkpatrick

:map! [ctrl-v][backspace] [ctrl-v][esc]xa
:map! [ctrl-v][up-arrow] [ctrl-v][esc]ka
:map! [ctrl-v][down-arrow] [ctrl-v][esc]ja
:map! [ctrl-v][right-arrow] [ctrl-v][esc]la
:map! [ctrl-v][left-arrow] [ctrl-v][esc]ha

When you type these in (assuming you’re using vi or vim, these lines will look like this.

:map! ^? ^[xa
:map! ^[OA ^[ka
:map! ^[OB ^[ja
:map! ^[OC ^[ha
:map! ^[OD ^[la
ajax loader
Posted in BASH - Tagged arrow, backspace, control, ctrl, down, editor, esc, escape, exrc, fix, key, keys, left, map, Michael S. Kirkpatrick, right, up, vi, vim
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

BASH > Functions

Mar22
2013
Leave a Comment Written by Scott Rowley

The beginning of a list of any functions I have created or found and deem useful:

This function will allow you to type “up ANY_NUMBER” and move that many directories up in the current directory tree you are in.

up () {

        COUNTER=$1
        while [[ $COUNTER -gt 0 ]]
         do
          UP="${UP}../"
          COUNTER=$(( $COUNTER -1 ))
         done
        echo "cd $UP"
        cd $UP
        UP=''
}

Some servers don’t have ‘watch’ installed so I’ve made my own function to replicate it’s basic functionality

mywatch () {

while true 
 do
  clear
  date +'%D %r'
  echo ''
  $1
  if [[ ! $2 ]]; then
   sleep 2
  else
   sleep $2
  fi
  clear
 done

}

Useage:

mywatch "ls -al" 5

If a second parameter ($2) is not supplied (in this case 5) then 2 will be used and your watch will refresh every 2 seconds.

ajax loader
Posted in BASH, Ubuntu - Tagged alias, bashrc, bash_profile, cd, clear, COUNTER, date, directory, function, monitor, move, navigate, profile, sleep, up, watch
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Usenet > Newznab backfilling

Jan31
2013
2 Comments Written by Scott Rowley

I’ve recently been checking out newznab plus. I’ve found that while it’s nice as it slowly builds, it’s a bit annoying not having any older posts already loaded. Fortunately nn+ (nnp, newznab plus) comes with an option for backfilling. The instructions are useful but I’d like to expand on them to make it less of a hassle to update more than one particular group.

Please note that I’ve only been using nn+ for a few days now so there may indeed be easier ways to do things but this is the best way I’ve found so far. For example, I’m not exactly sure what the update_binaries_threaded.php file does but I don’t believe it does what I’m discussing here. I’m guessing from the “threaded” that it simply makes multiple threads of the same process to make the entire task faster.

The following is taken from http://newznab.readthedocs.org/en/latest/readme/#backfilling-groups

Backfilling Groups
Since most usenet providers have 800+ days of retention indexing all that information in one shot is not practical. Newznab provides a backfill feature that allow you to index past articles once your initial index has been built. To use the feature first set the back fill days setting in the group(s) to be backfilled to the number of day you wish to go back, making sure to set it higher than the number of days listed in the first post column. Once set run the backfill.php script in misc/update_scripts. Groups can be backfilled to a particular date using the script misc/update_scripts/backfill_date.php using the syntax:

php backfill_date.php 2011-05-15 alt.binaries.groupname.here

You can use the _threaded version of this script if on linux.

For more information on backfilling, see Update Scripts.

First off, what we need to do is to activate any groups we want. More than likely you’ve already done this. What you’ll want to do in order to backfill those groups is to change the ‘Backfill Days’ entry. This can be done through the webpage but if you are wanting to backfill all of them then this following command will make it much faster than manually clicking through a dozen or more groups.

You’ll need to be on the command line and then log into mysql

mysql -u root -p
Enter password:

mysql> use newznab; (or whatever your database name is)
mysql> update groups set backfill_target=365 where active=1;

You have now just changed all active groups to have a backfill of 365 days (1 year). Now we just need to run our backfill_date.php on each group. If we’ve got dozens of groups or more though this can be tedious to repeat over and over with each group. So instead we are going to get a list of all the active groups by running the following command:

mysql -u root -p newznab -e 'select name from groups where active=1;' > groups.txt

You can now go into the groups.txt file and remove and additional groups you want or just leave it intact if you want everything.

Finally we want to run the php backfill.php command to backfill each of our selected groups back 365 days (or whatever number you’ve selected, alternatively you can also skip updating the database with the amount of days to backfill and simply substitute the backfill_date.php as noted from the link.)

Normally this command would be run like so for a single group:

php backfill.php alt.binaries.groupname.here

But this is much too slow for multiple groups so we are going to use a ‘for’ function with our data from the groups.txt file we created.

for group in `cat groups.txt`; do php backfill.php $group; done

If you are like me and like to see your code before it runs then simply add an echo beforehand to view the results and then remove it when you are ready:

for group in `cat groups.txt`; do echo "php backfill.php $group"; done

The use of the backticks (`) around ‘cat groups.txt’ tells it to run the command in a subshell and then use the information from that back in the shell command.

ajax loader
Posted in BASH, PHP, Ubuntu - Tagged backfill, backfill days, BASH, for, groups, MySQL, newznab, newznab plus, nn+, nnp, php, update, usenet
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

MAN PAGE > ‘date’ (8.4)

Jan30
2013
Leave a Comment Written by Scott Rowley

Note that this man page is regarding date version ‘date (GNU coreutils) 8.4′, your mileage may vary when using other versions.

I’m going to expand this section to include examples of every entry from the man page. Note that some examples include additional commands to demonstrate the information we are working with.

NAME
date – print or set the system date and time

SYNOPSIS
date [OPTION]… [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

DESCRIPTION
Display the current time in the given FORMAT, or set the system date.

-d, –date=STRING
display time described by STRING, not ‘now’

date
Wed Jan 30 10:08:18 CST 2013

date -d "1 year ago"
Mon Jan 30 10:08:33 CST 2012

-f, –file=DATEFILE
like –date once for each line of DATEFILE

cat years.txt
1 year ago
2 years ago
3 years ago

date -f years.txt
Mon Jan 30 10:19:17 CST 2012
Sun Jan 30 10:19:17 CST 2011
Sat Jan 30 10:19:17 CST 2010

READ MORE »

ajax loader
Posted in BASH - Tagged BASH, cat, date, example, Format, man, man page, page, shell, time
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

BASH > Modify file/directory timestamp

Jan28
2013
Leave a Comment Written by Scott Rowley

In order to modify the timestamp of any file or directory you can run the following commands

Modify timestamp to “right now”

touch filename

Modify timestamp to a past or future time

touch -t 201301281030 filename
ajax loader
Posted in BASH
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Google > Search by Image instead of text (Identify Image)

Sep12
2012
Leave a Comment Written by Scott Rowley

So the other day someone on facebook asked who someone was and supplied a picture. As it happens I had no idea who it was so I started wondering how I could still identify the person and supply the answer. Well, as is often the case, Google has already thought this up and supplied the answer. Take a look at the following short video to see how this is easily done.

ajax loader
Posted in Web Development - Tagged google, image, images, photo, picture, result, search, text
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

osTicket > Show external ticket ID in browser title.

Aug13
2012
2 Comments Written by Scott Rowley

 

At my full time job we often reference the ticket ID that we are working on in our daily log, notes or when just when referencing it from person to person. The following will allow for showing the external ticket ID in the browser title.

First we need a new function to reference, find the following in
include/class.ticket.php

/*============== Functions below do not require an instance of the class to be used. To call it use Ticket::function(params); ==================*/

And add the following right after it:

function getExtIdById($id){
        $sql ='SELECT  ticketID FROM '.TICKET_TABLE.' ticket WHERE ticket_id='.db_input($id);
        $res=db_query($sql);
        if($res && db_num_rows($res))
            list($extid)=db_fetch_row($res);

        return $extid;
    }

Now open up
include/staff/header.inc.php and add the following just after your <title> tag:

 <?if(Ticket::getExtIdById($id)){ echo Ticket::getExtIdById($id)." - "; }?> 

Update!
There are a couple of pages you may be on (like “My Preferences”) where the ticket class is not loaded. In order to make sure it’s loaded for use you can added the following just before the title tag:

require_once('../include/class.ticket.php');
ajax loader
Posted in MySQL, osTicket, PHP - Tagged browser, class, external id, function, internal id, osTicket, php, reference, title
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

osTicket > Refresh ticket page every N seconds (1.6RC5)

Aug07
2012
Leave a Comment Written by Scott Rowley

Just a simple one today to show you how to get the ticket page to automatically refresh itself every n seconds:

scp/tickets.php
Insert the following just after the requires at the top of the file:

define('MAIN_PAGE',1);
if(defined('MAIN_PAGE') && !isset($_GET['id']) && !isset($_GET['status']) && !isset($_GET['a'])) {
    echo "<meta http-equiv='refresh' content='60'>";
}

*60 seconds is my recommendation, you can of course change this number as desired.

ajax loader
Posted in osTicket, Web Development - Tagged content, meta, osTicket, page, refresh, reload, seconds, ticket
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Web Dev > pChart WriteValues text color

Jun07
2012
Leave a Comment Written by Scott Rowley

Just a quick post since I started toying around with pChart 2.x to add emailed reports to my osTickets Reports MOD. This took me awhile to locate and that was including 20 minutes of googling failing me.

In order to change the font color of the WriteValues (the values that show up over your generated charts). You can modify the numbers in the following file
pChart/class/pRadar.class.php

     $ValueR        = isset($Format["ValueR"]) ? $Format["ValueR"] : 0;
     $ValueG        = isset($Format["ValueG"]) ? $Format["ValueG"] : 0;
     $ValueB        = isset($Format["ValueB"]) ? $Format["ValueB"] : 0;

Setting the above to 0′s instead of 255 will change the text from white to an easier to read black.

ajax loader
Posted in PHP, Web Development - Tagged Charts, Format, pChart, php, ValueB, ValueG, ValueR, WriteValues
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Web Dev > Obtaining Google PageRank

Jun06
2012
3 Comments Written by Scott Rowley

As a part of Search Engine Optimization (SEO) you may want to be aware of your websites (or clients websites) page rank on Google. After some researching I’ve found the following solutions to be best. I’ll be presenting a few options here, first we’ll cover how to look it up on prchecker.info. Second we’ll be covering how to look up the page rank using a perl script and finally we’ll cover how to look up your page rank with the perl script and update a mysql database with the information (for long term tracking and/or tracking multiple websites.)
READ MORE »

ajax loader
Posted in MySQL, Perl, PHP, SEO, Web Development - Tagged database, google, MySQL, page, page rank, Perl, php, prchecker.info, rank, script, search engine optimizaiton, SEO
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« Older Entries

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

Sudo Bash Member sites

Iowa SAR
Ooo-er
Des Moines, Iowa Tattoo & Piercing
QualifiedImpressions.com
Visibility Max
The Man In Black

Meta

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

RSS HowToGeek

  • Geek Trivia: What Is The Only Day Of The Week That Derives Its Name From Roman Mythology?
  • New 36 Page ‘Windows 8 End User Training Brochure’ Available for Download
  • How to Migrate Your Google Account to a New One
  • Bill Shock: How to Avoid $22,000 or More in International Roaming Fees
  • Why Does Firefox Use the “chrome://” Protocol in Internal Schemas?

RSS TheGeekStuff

  • 5 Modem At Command Examples in Linux (How to Configure Minicom)
  • 7 Linux Date Command Examples to Display and Set System Date Time
  • How to Install AMQP PHP Extension and RabbitMQ Client on Linux
  • How Email Works? – Email Basic Concepts Explained
  • How to Use C++ Reference Variables (C++ Reference Vs Pointer Example)

RSS LifeHacker

  • Twitter Gets Two-Factor Authentication, Enable It Now
  • Hacker Challenge: Share Your Best Vacation Hack
  • I'm Daniel Pink, and This Is How I Work
  • Ask Yourself These Two Questions to Prioritize Your Tasks
  • Where Do You Keep Important Family Documents?

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

Back to Top