openssl req -new -nodes -subj "/C=US/ST=Florida/L=Tampa/O=My Org Pvt Limited/OU=Some Dept/CN=abc.xyz.com" -keyout private.txt -out certreq.txt -newkey rsa:2048
Generate 2048 CSR using openssl
Minify/compress JavaScript, CSS compressor
Quick and easy way to minify/compress JavaScript and CSS
- JS Compress and Obfuscate : http://www.minifyjs.com/javascript-obfuscator/
- JS Compress only: http://www.minifyjs.com/javascript-compressor/
- CSS compressor : http://www.minifycss.com/css-compressor/
UNIX: Bash Keyboard shortcuts
Very useful neat shortcuts for traversing in Bash command line :)
Command Editing Shortcuts
- Ctrl + a – go to the start of the command line
- Ctrl + e – go to the end of the command line
- Ctrl + k – delete from cursor to the end of the command line
- Ctrl + u – delete from cursor to the start of the command line
- Ctrl + w – delete from cursor to start of word (i.e. delete backwards one word)
- Ctrl + y – paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
- Ctrl + xx – move between start of command line and current cursor position (and back again)
- Alt + b – move backward one word (or go to start of word the cursor is currently on)
- Alt + f – move forward one word (or go to end of word the cursor is currently on)
- Alt + d – delete to end of word starting at cursor (whole word if cursor is at the beginning of word)
- Alt + c – capitalize to end of word starting at cursor (whole word if cursor is at the beginning of word)
- Alt + u – make uppercase from cursor to end of word
- Alt + l – make lowercase from cursor to end of word
- Alt + t – swap current word with previous
- Ctrl + f – move forward one character
- Ctrl + b – move backward one character
- Ctrl + d – delete character under the cursor
- Ctrl + h – delete character before the cursor
- Ctrl + t – swap character under cursor with the previous one
Command Recall Shortcuts
- Ctrl + r – search the history backwards
- Ctrl + g – escape from history searching mode
- Ctrl + p – previous command in history (i.e. walk back through the command history)
- Ctrl + n – next command in history (i.e. walk forward through the command history)
- Alt + . – use the last word of the previous command
Command Control Shortcuts
- Ctrl + l – clear the screen
- Ctrl + s – stops the output to the screen (for long running verbose command)
- Ctrl + q – allow output to the screen (if previously stopped using command above)
- Ctrl + c – terminate the command
- Ctrl + z – suspend/stop the command
Bash Bang (!) Commands
- !! - run last command
- !blah – run the most recent command that starts with ‘blah’ (e.g. !ls)
- !blah:p – print out the command that !blah would run (also adds it as the latest command in the command history)
- !$ – the last word of the previous command (same as Alt + .)
- !$:p – print out the word that !$ would substitute
- !* – the previous command except for the last word (e.g. if you type ‘find some_file.txt /‘, then !* would give you ‘find some_file.txt‘)
- !*:p – print out what !* would substitute
jQuery: Select a radio button by name and value
Using jQuery, if you want to select a specific radio button based on name and value
$(':radio[name="radioBtnName"][value="radioValue"]');Example:
<div id="radioGrps">
<div id="setOne">
<input type="radio" name="orange" value="5" />
<input type="radio" name="orange" value="10" checked />
<input type="radio" name="orange" value="20" />
</div>
<div id="setTwo">
<input type="radio" name="peach" value="10" />
<input type="radio" name="peach" value="15" />
<input type="radio" name="peach" value="20" checked />
</div>
</div>
In the above example,
if you want to select radio button in div#setOne with value 10, then
$('#setOne :radio[name="orange"][value="10"]');
or
$(':radio[name="orange"][value="10"]');
//to make it checked
$(':radio[name="orange"][value="10"]').attr('checked', 'checked');
Eclipse color theme
Download eclipse color theme plugin for easy installation of several color themes for your Eclipse IDE.
If you are on Eclipse 3.5 (Galileo), go to Help→Install New Software..., press Add Site and enterEclipse Color Theme as the name and http://eclipse-color-theme.github.com/update as the URL. Then select the new entry from the select box labeled Work with, mark Eclipse Color Theme for installation and proceed.
After the installation, go to Window→Preferences→General→Appereance→Color Theme to change the color theme.
If you are on Eclipse 3.6 (Helios), the easiest way to install the plugin is from the Eclipse Marketplace. Go to Help→Eclipse Marketplace..., then search for Eclipse Color Theme and install it.
If you are on Eclipse 3.5 (Galileo), go to Help→Install New Software..., press Add Site and enterEclipse Color Theme as the name and http://eclipse-color-theme.github.com/update as the URL. Then select the new entry from the select box labeled Work with, mark Eclipse Color Theme for installation and proceed.
After the installation, go to Window→Preferences→General→Appereance→Color Theme to change the color theme.
Mac: Take a screenshot in different ways
In Mac OS X, there are 3 ways to take a screenshot.
1. Cmd+Shift+3 : Capture the entire screen.
2. Cmd+Shift+4 : Capture a selected area of your screen. The cursor will turn into a crosshair and you can drag around the area you want to capture.
3. Cmd+Shift+4+Spacebar : Capture a specific window or Dock or menu bar. The crosshair will turn into a little camera and highlight the window or objects you can capture. Left Click to capture.
You can use Expose shortcut to switch between windows. After you switch press alt or cmd key to get the little camera. Left Click to capture.
1. Cmd+Shift+3 : Capture the entire screen.
2. Cmd+Shift+4 : Capture a selected area of your screen. The cursor will turn into a crosshair and you can drag around the area you want to capture.
3. Cmd+Shift+4+Spacebar : Capture a specific window or Dock or menu bar. The crosshair will turn into a little camera and highlight the window or objects you can capture. Left Click to capture.
You can use Expose shortcut to switch between windows. After you switch press alt or cmd key to get the little camera. Left Click to capture.
jQuery: get specific list item by id
Consider the following html snippet
You can get a specific list item using jQuery
<div id="fruits"> <ul> <li id="5">Apples</li> <li id="29">Oranges</li> <li id="32">Peaches</li> <li id="47">Bananas</li> <li id="30">Grapes</li> </ul> </div>
You can get a specific list item using jQuery
$jq("#fruits ul li[id=32]");
Mac: Mac OS X 10.6.8 Printing Issue, and a Fix
With the recent update to Mac OS X 10.6.8, the printing does not work.
After updating to 10.6.8, you might be Getting “paused printer” message
Download Fix Here
For More details, View This Post
After updating to 10.6.8, you might be Getting “paused printer” message
Download Fix Here
For More details, View This Post
Unix: Get total size of mutliple folders or files
The following command gives the total size of the folders you have selected at the end of the list.
$ du -sch foo/ dummy/ data/ booger/
3G foo/
2G dummy/
9G data/
5G booger/
19G total
MySQL: Resetting auto-increment value of a table
During development, usually we want to delete records from the table manually, then the tables auto-increment column remains where it was. We might want to reset the auto-increment value for the table.
For example, if you delete records with id's 7,8,9
Now when you insert through application, it inserts the new record starting at 10. But we want it to start at 7.
Use the following SQL to reset to a specific value
If you want to delete all records from your table and restart auto-index at 1, then
For example, if you delete records with id's 7,8,9
Now when you insert through application, it inserts the new record starting at 10. But we want it to start at 7.
Use the following SQL to reset to a specific value
ALTER TABLE my_table AUTO_INCREMENT=7
If you want to delete all records from your table and restart auto-index at 1, then
TRUNCATE TABLE my_table
MySQL: Calculate DATE, TIME difference in SQL statement using MySQL DB
Following examples showing how to calculated DATE, TIME differences in SQL statement in MySQL database.
Functions used in the following examples are TIMEDIFF and DATEDIFF
Functions used in the following examples are TIMEDIFF and DATEDIFF
select TIMEDIFF('2011-10-31 12:50:56' , '2011-09-23 12:50:21')
The above outputs : 838:59:59
select TIMEDIFF('15:50:56' , '12:55:21')
The above SQL outputs: 02:55:35
select DATEDIFF('2011-10-31 12:50:56' , '2011-09-23 12:50:21')
The above SQL outputs: 38
select DATEDIFF('2011-10-31' , '2011-09-23')
The above SQL outputs: 38
JAVA: Read and Write PPM, PGM images in JAVA
Download the code library from HERE
Also you can download some sample PPM and PGM images from here.
The following helps to setup the project using Eclipse.
This requires 2 Image Processing libraries which are included in the zip. [jai_imageio.jar and clibwrapper_jiio.jar]
If you are not using eclipse, please add these 2 libraries to your project.
After opening Eclipse:
1. Goto File->New->Java Project
2. In the "contents" section, select the radio button "create project from existing source"
3. Click browse to point to the downloaded ImgProcTool folder (Assuming u have unzipped the file)
4. Click Finish on the "new Java Project" window.
TEST IT BY EXECUTING THE PROJECT
A simple sample program IpToolTester.java is included, which reads and writes a sample PGM image.
6. If everything is fine, there will be console output ending with "Done".
7. Refresh the project, you will see a new .pgm file "lena_write.pgm".
Also you can download some sample PPM and PGM images from here.
The following helps to setup the project using Eclipse.
This requires 2 Image Processing libraries which are included in the zip. [jai_imageio.jar and clibwrapper_jiio.jar]
If you are not using eclipse, please add these 2 libraries to your project.
After opening Eclipse:
1. Goto File->New->Java Project
2. In the "contents" section, select the radio button "create project from existing source"
3. Click browse to point to the downloaded ImgProcTool folder (Assuming u have unzipped the file)
4. Click Finish on the "new Java Project" window.
TEST IT BY EXECUTING THE PROJECT
A simple sample program IpToolTester.java is included, which reads and writes a sample PGM image.
public class IpToolTester {
public static void main(String[] args) {
ImageTool imageTool = new ImageTool();
String srcPath = "lena_384.pgm";
Image srcImg = new Image(srcPath);
Image tgtImg = new Image();
tgtImg.init(srcImg.getNumRows(), srcImg.getNumCols());
imageTool.copyImg(srcImg, tgtImg);
tgtImg.save("lena_write.pgm");
System.out.println("Done");
}
}
5. Right click on the project and select "Run as->java application"6. If everything is fine, there will be console output ending with "Done".
7. Refresh the project, you will see a new .pgm file "lena_write.pgm".
Mac: Installing OOMMF on Mac OS X Snow Leopard 10.6
Mac OS have TCL/TK already installed.
So it is very easy to install OOMMF(Object Oriented MicroMagnetic Framework)
The following steps installs OOMMF at directory ~/apps/oommf12a4pre-20091216
First you need to download the oommf SOURCE code.
Here is the link to download 1.2a4pre snapshots : http://math.nist.gov/~MDonahue/misc/oommf12a4pre-20091216.tar.gz
Once you have downloaded untar to ~/apps/ using the following command in the terminal.
gunzip -c oommf12a4_20040908.tar.gz | tar xvf -
To Install:
Open Terminal and goto to the folder where you untarred.
To launch the application
So it is very easy to install OOMMF(Object Oriented MicroMagnetic Framework)
The following steps installs OOMMF at directory ~/apps/oommf12a4pre-20091216
First you need to download the oommf SOURCE code.
Here is the link to download 1.2a4pre snapshots : http://math.nist.gov/~MDonahue/misc/oommf12a4pre-20091216.tar.gz
Once you have downloaded untar to ~/apps/ using the following command in the terminal.
gunzip -c oommf12a4_20040908.tar.gz | tar xvf -
To Install:
Open Terminal and goto to the folder where you untarred.
$ cd ~/apps/oommf12a4pre-20091216
Run the following 2 commands $ tclsh oommf.tcl +platform
The above command prints summary of your platform configuration. Make sure all the config files are located and listed. Example output will be like the following oommf.tcl 1.2.0.4 info:
OOMMF release 1.2.0.4, snapshot 2009.12.16
Platform Name: darwin
Tcl name for OS: Darwin 10.7.0
C++ compiler: /usr/bin/g++
Tcl configuration file: /usr/lib/tclConfig.sh
tclsh: /usr/bin/tclsh8.5
Tcl release: 8.5.7 (config) 8.5.7 (running)
Tk configuration file: /usr/lib/tkConfig.sh
wish: /usr/bin/wish8.5
Tk release: 8.5.7 (config) 8.5.7 (running)
Tcl threads: Yes
OOMMF threads: Yes
Default thread count: 2
Now you have all the configurations good, to compile and build run the following command $ tclsh oommf.tcl pimake
The above command runs for a while. If there is an error, it prints the error on the console.To launch the application
$ tclsh oommf.tcl
Mac: Set Up Apache Virtual Hosts on Mac OS X Snow Leopard 10.6
There 3 simple steps to set Up Apache Virtual Hosts on Mac OS X Snow Leopard (10.6.x)
If you dont have time or lazy to follow these 3 simple steps, you can use a script http://code.google.com/p/virtualhost-sh/
Step A:
2. Find the line #Include /private/etc/apache2/extra/httpd-vhosts.conf
Remove the "#" at the beginning.Now it must look like
Step B:
1. Open httpd-vhosts.conf located at
2. There will be 2 existing dummy examples, you could modify one of to suit your needs. For example I modified to as:
STEP C:
2. Add a new line to specify your new virtual host. For example, I added the following line
Final STEP D:
1. Save all the edited files : httpd.conf, httpd-vhosts.conf, hosts
2. Restart Apache web server: System Preferences > Sharing > Web Sharing, uncheck and check web sharing
3. DONE ! Your virtual host is ready to use.
If you dont have time or lazy to follow these 3 simple steps, you can use a script http://code.google.com/p/virtualhost-sh/
Step A:
1. Open httpd.conf located at /private/etc/apache2/httpd.conf
Open it using "vi" in terminal or open it using "text wrangler". Donot open using any word processing program, they will add unwanted characters into the file.2. Find the line #Include /private/etc/apache2/extra/httpd-vhosts.conf
Remove the "#" at the beginning.Now it must look like
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
Step B:
1. Open httpd-vhosts.conf located at
/private/etc/apache2/extra/httpd-vhosts.conf
Open it using "vi" in terminal or open it using "text wrangler". Donot open using any word processing program, they will add unwanted characters into the file.2. There will be 2 existing dummy examples, you could modify one of to suit your needs. For example I modified to as:
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents/mydemo"
ServerName mydemo.local
ErrorLog "/private/var/log/apache2/mydemo.local-error_log"
CustomLog "/private/var/log/apache2/mydemo.local-access_log" common
</VirtualHost>
STEP C:
1. Open hosts located at /private/etc/hosts
Open it using "vi" in terminal or open it using "text wrangler". Donot open using any word processing program, they will add unwanted characters into the file.2. Add a new line to specify your new virtual host. For example, I added the following line
127.0.0.1 mydemo.local
Final STEP D:
1. Save all the edited files : httpd.conf, httpd-vhosts.conf, hosts
2. Restart Apache web server: System Preferences > Sharing > Web Sharing, uncheck and check web sharing
3. DONE ! Your virtual host is ready to use.
XML: Simple internal DTD definition example
Best way to validate is using any browser. Open the XML file in any browser.
Also, if you open in Eclipse, you can right click on the .xml file and select "validate".
Also, if you open in Eclipse, you can right click on the .xml file and select "validate".
<?xml version="1.0"?>
<!DOCTYPE notes [
<!ELEMENT notes (note*)>
<!ELEMENT note (to,from,heading,body*)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<notes>
<note>
<to>Joe</to>
<from>Tom</from>
<heading>Hello</heading>
</note>
<note>
<to>Bob</to>
<from>Joe</from>
<heading>Reminder</heading>
<body>this is msg</body>
</note>
</notes>
Subscribe to:
Posts (Atom)
Python contextlib for Timing Python code
If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...
-
If you get the following error while installing FFMPEG or other packages on CentOS 7. Requires: libva.so.1(VA_API_0.33.0)(64bit) Follow...
-
Common error: fallocate: fallocate failed: Text file busy in ubuntu OS Check the allocation: free -m or sudo swapon --show Make sure ...
-
How to fix Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' Apparently, Ma...