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

BASH> Mass rename files

Mar04
2015
Written by Scott Rowley
for file in *.html; do mv -- "$file" "${file%.html}.php"; done
drwxrwxr-x 11 apache sas 4096 Mar 4 12:08 .
drwxrwxr-x 4 apache sas 4096 Feb 26 17:38 ..
-rw-rw-r-- 1 sasowner sas 10763362 Mar 4 11:48 AdminTheme.zip
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 bootstrap
-rw-rw-r-- 1 sasowner sas 18949 Dec 8 2012 calendar.html
-rw-rw-r-- 1 sasowner sas 20676 Dec 8 2012 charts.html
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 css
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 custom-plugins
-rw-rw-r-- 1 sasowner sas 15572 Dec 8 2012 error.html
drwxrwxr-x 2 sasowner sas 4096 Dec 8 2012 example
-rw-rw-r-- 1 sasowner sas 19769 Dec 8 2012 files.html
-rw-rw-r-- 1 sasowner sas 54023 Dec 8 2012 form_elements.html
-rw-rw-r-- 1 sasowner sas 48582 Dec 8 2012 form_layouts.html
-rw-rw-r-- 1 sasowner sas 48867 Dec 8 2012 form_wizard.html
-rw-rw-r-- 1 sasowner sas 29210 Dec 8 2012 gallery.html
-rw-rw-r-- 1 sasowner sas 26691 Dec 8 2012 grids.html
-rw-rw-r-- 1 sasowner sas 286390 Dec 8 2012 icons.html
drwxrwxr-x 3 sasowner sas 4096 Dec 8 2012 images
-rw-rw-r-- 1 sasowner sas 45088 Mar 4 12:08 index.php
drwxrwxr-x 5 sasowner sas 4096 Dec 8 2012 js
drwxrwxr-x 5 sasowner sas 4096 Dec 8 2012 jui
-rw-rw-r-- 1 sasowner sas 2998 Dec 8 2012 login.html
-rw-rw-r-- 1 sasowner sas 1780 Mar 4 12:08 navigation.php
drwxrwxr-x 2 sasowner sas 4096 Dec 8 2012 php
drwxrwxr-x 17 sasowner sas 4096 Dec 8 2012 plugins
-rw-rw-r-- 1 sasowner sas 69763 Dec 8 2012 table.html
-rw-rw-r-- 1 sasowner sas 27285 Dec 8 2012 typography.html
-rw-rw-r-- 1 sasowner sas 61362 Dec 8 2012 widgets.html

After

drwxrwxr-x 11 apache sas 4096 Mar 4 12:08 .
drwxrwxr-x 4 apache sas 4096 Feb 26 17:38 ..
-rw-rw-r-- 1 sasowner sas 10763362 Mar 4 11:48 AdminTheme.zip
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 bootstrap
-rw-rw-r-- 1 sasowner sas 18949 Dec 8 2012 calendar.html
-rw-rw-r-- 1 sasowner sas 20676 Dec 8 2012 charts.html
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 css
drwxrwxr-x 4 sasowner sas 4096 Dec 8 2012 custom-plugins
-rw-rw-r-- 1 sasowner sas 15572 Dec 8 2012 error.html
drwxrwxr-x 2 sasowner sas 4096 Dec 8 2012 example
-rw-rw-r-- 1 sasowner sas 19769 Dec 8 2012 files.html
-rw-rw-r-- 1 sasowner sas 54023 Dec 8 2012 form_elements.html
-rw-rw-r-- 1 sasowner sas 48582 Dec 8 2012 form_layouts.html
-rw-rw-r-- 1 sasowner sas 48867 Dec 8 2012 form_wizard.html
-rw-rw-r-- 1 sasowner sas 29210 Dec 8 2012 gallery.html
-rw-rw-r-- 1 sasowner sas 26691 Dec 8 2012 grids.html
-rw-rw-r-- 1 sasowner sas 286390 Dec 8 2012 icons.html
drwxrwxr-x 3 sasowner sas 4096 Dec 8 2012 images
-rw-rw-r-- 1 sasowner sas 45088 Mar 4 12:08 index.php
drwxrwxr-x 5 sasowner sas 4096 Dec 8 2012 js
drwxrwxr-x 5 sasowner sas 4096 Dec 8 2012 jui
-rw-rw-r-- 1 sasowner sas 2998 Dec 8 2012 login.html
-rw-rw-r-- 1 sasowner sas 1780 Mar 4 12:08 navigation.php
drwxrwxr-x 2 sasowner sas 4096 Dec 8 2012 php
drwxrwxr-x 17 sasowner sas 4096 Dec 8 2012 plugins
-rw-rw-r-- 1 sasowner sas 69763 Dec 8 2012 table.html
-rw-rw-r-- 1 sasowner sas 27285 Dec 8 2012 typography.html
-rw-rw-r-- 1 sasowner sas 61362 Dec 8 2012 widgets.html
Posted in Web Development

Objective-C> Set all iOS keyboard to black (Alert)

May01
2014
Written by Scott Rowley

iOS coding black keyboard

In each view (.m file) you’ll just need to add the following to either the viewWillAppear or viewDidLoad section:

for(UIView *view in self.view.subviews){
if([view isKindOfClass:[UITextField class]]){
UITextField *txt = (UITextField *)view;
[txt setKeyboardAppearance:UIKeyboardAppearanceAlert];
}
}
Posted in Objective-C - Tagged alert, black, class, ios, keyboard, objective-c, setKeyboardAppearance, subview, UIKeyboardAppearancealert, uitextfield, view, xcode

Objective-C> NSDateFormatter formatting options

Dec29
2013
Written by Scott Rowley

I needed to know these for my current project. I found the following here (http://www.alexcurylo.com/blog/2009/01/29/nsdateformatter-formatting/) which was originally posted elsewhere and credit given but that page no longer exists. I figured I’d keep a copy here so I’m sure to always have it available.

a: AM/PM
A: 0~86399999 (Millisecond of Day)

c/cc: 1~7 (Day of Week)
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday

d: 1~31 (0 padded Day of Month)
D: 1~366 (0 padded Day of Year)

e: 1~7 (0 padded Day of Week)
E~EEE: Sun/Mon/Tue/Wed/Thu/Fri/Sat
EEEE: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday

F: 1~5 (0 padded Week of Month, first day of week = Monday)

g: Julian Day Number (number of days since 4713 BC January 1)
G~GGG: BC/AD (Era Designator Abbreviated)
GGGG: Before Christ/Anno Domini

h: 1~12 (0 padded Hour (12hr))
H: 0~23 (0 padded Hour (24hr))

k: 1~24 (0 padded Hour (24hr)
K: 0~11 (0 padded Hour (12hr))

L/LL: 1~12 (0 padded Month)
LLL: Jan/Feb/Mar/Apr/May/Jun/Jul/Aug/Sep/Oct/Nov/Dec
LLLL: January/February/March/April/May/June/July/August/September/October/November/December

m: 0~59 (0 padded Minute)
M/MM: 1~12 (0 padded Month)
MMM: Jan/Feb/Mar/Apr/May/Jun/Jul/Aug/Sep/Oct/Nov/Dec
MMMM: January/February/March/April/May/June/July/August/September/October/November/December

q/qq: 1~4 (0 padded Quarter)
qqq: Q1/Q2/Q3/Q4
qqqq: 1st quarter/2nd quarter/3rd quarter/4th quarter
Q/QQ: 1~4 (0 padded Quarter)
QQQ: Q1/Q2/Q3/Q4
QQQQ: 1st quarter/2nd quarter/3rd quarter/4th quarter

s: 0~59 (0 padded Second)
S: (rounded Sub-Second)

u: (0 padded Year)

v~vvv: (General GMT Timezone Abbreviation)
vvvv: (General GMT Timezone Name)

turbobit premium account. how to buy expired domains

w: 1~53 (0 padded Week of Year, 1st day of week = Sunday, NB: 1st week of year starts from the last Sunday of last year)
W: 1~5 (0 padded Week of Month, 1st day of week = Sunday)

y/yyyy: (Full Year)
yy/yyy: (2 Digits Year)
Y/YYYY: (Full Year, starting from the Sunday of the 1st week of year)
YY/YYY: (2 Digits Year, starting from the Sunday of the 1st week of year)

z~zzz: (Specific GMT Timezone Abbreviation)
zzzz: (Specific GMT Timezone Name)
Z: +0000 (RFC 822 Timezone)

Example 1:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//NSDate *date = [NSDate date];
[dateFormatter setDateFormat:@"MMM d y (cccc)"];
NSDate *date = self.ApptDatePicker.date;
NSString *dateString = [dateFormatter stringFromDate:date];
_datePicked.text = dateString;

Result 1

DEC 26 2013 (SATURDAY)

Example 2:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"h:m a"];
NSDate *date = self.ApptTimePicker.date;
NSString *dateString = [dateFormatter stringFromDate:date];
_timePicked.text = dateString;

Result 2:

11:22 PM
Posted in Objective-C - Tagged apple, Format, formatting, ios, nsdateformatter, obj-c, objc, objective-c, xcode

osTicket> “First Client” Theme

Nov11
2013
Written by Scott Rowley

Up for grabs by donation ($25) is the “First Client” theme. Every page has been gone over to rework the design to the beautiful result below! Recently updated for use with 1.9.14!

First Client osTicket Home Page

First Client osTicket Home Page

First Client osTicket Home Page

First Client osTicket Home Page

First Client osTicket Home Page

Posted in Web Development

Creating a Deployment Plan in Oracle WebLogic

Oct10
2013
Written by Ben Garin

Deployment Plans

Deployment plans can be used by administrators to override application settings and variables without modifying the actual jar/war/ear file contents.

Creation

Creating a deployment plan for a deployed application.

  1. Open a Web browser and go to http://<hostname>:<port>/console.
  2. Log in as the administrator.
  3. In the Change Center, click Lock & Edit to enable configuration changes.
  4. Navigate to <domain_name>, then Deployments.
  5. Click on the <application_name> you are creating a deployment plan for.
  6. Click on the Configuration tab.
  7. Click Save.
  8. Enter the path and name of the deployment plan and Click OK.
  9. In the Change Center, click Release Configuration.

Customization

Customizing a deployment plan involves 2 parts, creating variables and assigning them.

Creating Variables:

Variable definitions should be entered below <application-name> inside the <variable-definition> tag.
Each variable requires a <name> and <value> tag.

Example:

Apostille document - apostille documents. Birth certificate apostille. Georgia apostille.

 <application-name>upload</application-name>
<variable-definition>
<variable>
<name>secureCookie</name>
<value>true</value>
</variable>
</variable-definition>

Assigning Variables:

Variable assignment needs to take place in the correct <root-element>, which in most cases is weblogic-web-app.
Depending on the variable assignment, it needs to be in the correct <uri> tag. The example below shows a variable assignment which would normally exist in the WEB-INF/weblogic.xml file.
Each variable assignment requires a <name> and <xpath>. The <name> is the name of the variable with a value created above and the <xpath> is the context path or tags in which the variable exists.

So normally in the weblogic.xml file this would look like:

<weblogic-web-app>
<session-descriptor>
<cookie-secure>SOME_VALUE</cookie-secure>
</session-descriptor>
</weblogic-web-app>

But in the <xpath> each tag is separated by a / resulting in:

/weblogic-web-app/session-descriptor/cookie-secure

Example:

 <root-element>weblogic-web-app</root-element>
<uri>WEB-INF/weblogic.xml</uri>
<variable-assignment>
<name>secureCookie</name>
<xpath>/weblogic-web-app/session-descriptor/cookie-secure</xpath>
</variable-assignment>

Full Deployment Plan Example:

<?xml version='1.0' encoding='UTF-8'?>
<deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd">
<application-name>upload</application-name>
<variable-definition>
<variable>
<name>secureCookie</name>
<value>true</value>
</variable>
</variable-definition>
<module-override>
<module-name>SOME_APPLICATION.ear</module-name>
<module-type>ear</module-type>
<module-descriptor external="false">
<root-element>weblogic-application</root-element>
<uri>META-INF/weblogic-application.xml</uri>
</module-descriptor>
<module-descriptor external="false">
<root-element>application</root-element>
<uri>META-INF/application.xml</uri>
</module-descriptor>
<module-descriptor external="true">
<root-element>wldf-resource</root-element>
<uri>META-INF/weblogic-diagnostics.xml</uri>
</module-descriptor>
</module-override>
<module-override>
<module-name>SOME_APPLICATION.war</module-name>
<module-type>war</module-type>
<module-descriptor external="false">
<root-element>weblogic-web-app</root-element>
<uri>WEB-INF/weblogic.xml</uri>
<variable-assignment>
<name>secureCookie</name>
<xpath>/weblogic-web-app/session-descriptor/cookie-secure</xpath>
</variable-assignment>
</module-descriptor>
<module-descriptor external="false">
<root-element>web-app</root-element>
<uri>WEB-INF/web.xml</uri>
</module-descriptor>
</module-override>
<config-root>DOMAIN_HOME/servers/AdminServer/upload/plan</config-root>
</deployment-plan>
Posted in Web Development

Middleware> Secure Liferay Session Cookie (JSESSIONID) in WebLogic

Aug19
2013
Written by Scott Rowley

Extract the WEB-INF/weblogic.xml file from your liferay.war:

jar -xvf WEB-INF/weblogic.xml

Edit WEB-INF/weblogic.xml

vi WEB-INF/weblogic.xml

Add the following to the <session-descriptor> tag:

<cookie-secure>true</cookie-secure>

Update your liferay.war file

jar -uf liferay.war WEB-INF/weblogic.xml

Now redeploy your liferay.war (update or delete/install) and your cookie should be changed to Secure: Yes.

Secure Liferay session cookie

Posted in liferay, middleware, Security - Tagged cookie, cookie-secure, liferay, liferay.war, middleware, secure, session, session-descriptor, weblogic, weblogic.xml

osTicket> Reports 6.x Change Log

Jul29
2013
Written by Scott Rowley

6.0.8
Fixed issue with Help Topic not reporting correctly, effected files: reports.php, reports_includes/functions.php, reports_includes/groups.php, reports_includes/reportGraph.php. Also removed several unneeded files that reduced the MOD zip file from over 4mb to just over 1mb.

Posted in MySQL, osTicket, Web Development - Tagged 6.x, change, change log, log, reports, reports mod, track, tracker, tracking, updates

osTicket> Reports 7.5 (1.10+)

Jun17
2013
Written by Scott Rowley

The reporting plugin has been moved to http://www.software-mods.com/reports.html

Thanks,
Scott

Posted in MySQL, osTicket, PHP, Web Development - Tagged 1.10, 1.7, 1.7 Release, 1.8, 1.9, 6.0, osTicket, osTicket Reports Plugin, release, reports, Reports Plugin, support, ticket, ticketing, version

BASH> Fix vi arrow keys in insert mode

Mar28
2013
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.

FNFmod.online

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
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

BASH> Functions

Mar22
2013
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. If you you do not specify a number and instead just type ‘up’ by itself you will automatically go up just one directory.

function up ()
{
if (( $#> 0 )); then
COUNTER=$1;
else
COUNTER=1;
fi;
while (( ${COUNTER}> 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 (updated to work with pipes!)

function mywatch () {
while true
do
clear
date +'%D %r'
echo ''
cmd=`echo $@`
#echo "Command is '$cmd'"
last=`echo $@ | awk {'print $NF'}`
num='^[0-9]+$'
if [[ $last =~ $num ]]; then
cmd=`echo $cmd | sed "s^$last^^g"`
eval "$cmd"
sleep $last
else
eval "$cmd"
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.

Easily locate problem directories when space is low on a server. Add the following function to your profile (.profile / .bashrc / etc)

function spaceHog ()
{
du -k | sort -n | awk '
BEGIN {
split("KB,MB,GB,TB", Units, ",");
}
{
u = 1;
while ($1>= 1024) {
$1 = $1 / 1024;
u += 1;
}
$1 = sprintf("%.1f %s", $1, Units[u]);
print $0;
}'
}

Useage:

[17:25:51][user@server][ ~ ]
[$]> spaceHog | tail -10 # To show the 10 largest, change this number as desired.
247.5 MB ./bin
247.8 MB ./.cache/google-chrome/Default
247.8 MB ./.cache/google-chrome
283.4 MB ./.cache
293.2 MB ./.wine/drive_c/Program Files (x86)
423.5 MB ./Downloads
653.6 MB ./IOS_APPS
655.1 MB ./.wine/drive_c
658.2 MB ./.wine
2.7 GB .

Delete (rm) a file by it’s inode number

Occassionally I will (or others will) run a command that ends up accidentally creating some goofy named files such as ‘?[01’. This is actually a character so you can’t just type it in to delete it. For this you can lookup the file name by it’s inode and then delete it.

You can do an ls with an -i option to get the inodes, for example:

[$]> ls -ali
total 8
295188 drwxr-xr-x 2 sasowner sas 4096 Dec 30 11:26 .
295064 drwx------ 23 sasowner sas 4096 Dec 30 11:26 ..
295406 -rw-r--r-- 1 sasowner sas 0 Dec 30 11:26 file1
295407 -rw-r--r-- 1 sasowner sas 0 Dec 30 11:26 file2
295408 -rw-r--r-- 1 sasowner sas 0 Dec 30 11:26 file3
295409 -rw-r--r-- 1 sasowner sas 0 Dec 30 11:26 file4

You could then follow this up with a command such as:

[$]> find . -inum 295409 -exec rm {} \;

However, you probably won’t use this command often enough to remember it unless you are regularly familiar with the find command. Instead, I’ve create the following simple function:

function rmi ()
{
find . -inum $1 -exec rm -i {} \;
}

Then simply type the following after getting the inode of the file

[$]> rmi ######
Posted in BASH, Ubuntu - Tagged alias, bash_profile, bashrc, cd, clear, COUNTER, date, directory, function, monitor, move, navigate, profile, sleep, up, watch
« 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

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top