To Show Hidden files run the following 2 commands in the terminal
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
To Hide Hidden files run the following 2 commands in the terminal.
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
Draw Smooth Circles in JAVA instead of jagged edge circles.
Usually when we draw circles/ovals using Graphics2D in JAVA, we get jagged edges.
Following example creates smooth edges to the circle.
The key is g2d.setRenderingHint (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Following example creates smooth edges to the circle.
The key is g2d.setRenderingHint (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class DrawSmoothCircle {
public static void main(String[] argv) throws Exception {
BufferedImage bufferedImage = new BufferedImage(100,100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bufferedImage.createGraphics();
g2d.setRenderingHint (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setPaint(Color.green);
g2d.fillOval(10, 10, 50, 50);
g2d.dispose();
ImageIO.write(bufferedImage, "png", new File("newimage.png"));
}
}
Multidimensional Scaling (MDS) Basic Tutorial, Introduction
A very pleasant and quick introduction to Multidimensional(MDS) scaling can be found at
http://homepages.uni-tuebingen.de/florian.wickelmaier/pubs/Wickelmaier2003SQRU.pdf
http://www.tonycoxon.com/KUB/mds_menu.htm
http://homepages.uni-tuebingen.de/florian.wickelmaier/pubs/Wickelmaier2003SQRU.pdf
http://www.tonycoxon.com/KUB/mds_menu.htm
Unix: Check unix/linux machine hardware configurations
$ uname -a
Linux comp0.abc.xyz.org 2.6.18-164.11.1.el5 #1 SMP Wed Jan 20 07:32:21 EST 2010 x86_64 x86_64 x86_64 GNU/Linux
$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 65
model name : Dual-Core AMD Opteron(tm) Processor 2220
stepping : 3
cpu MHz : 2800.098
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips : 5600.19
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc
Mac : check if my intel based Mac is 32-bit or 64-bit
1. Choose About This Mac from the Apple () menu in the upper-left menu bar
2. See what Processor it has.
3. Compare your Processor Name to information below to determine whether your Mac has a 32-bit or 64-bit processor.
Source: Extracted from http://support.apple.com/kb/ht3696
2. See what Processor it has.
3. Compare your Processor Name to information below to determine whether your Mac has a 32-bit or 64-bit processor.
Processor Name
|
32- or 64-bit
|
Intel Core Solo
|
32 bit
|
Intel Core Duo
|
32 bit
|
Intel Core 2 Duo
|
64 bit
|
Intel Quad-Core Xeon
|
64 bit
|
Dual-Core Intel Xeon
|
64 bit
|
Quad-Core Intel Xeon
|
64 bit
|
Unix: Running processes in parallel in unix shell
By using the ampersand '&' , we can run processes in parallel.
Example 1:
Consider the following script
for i=0; i<10;i++
do
cat inp$i.txt;
done
The above script would run sequentially executing cat inp1.txt; cat inp2.txt; cat inp3.txt' .....
We can issue these processes in parallel by using '&' instead ';'
for i=0; i<10;i++
do
cat inp$i.txt &
done
Example 2:
$ runprog1; runprog2; runprog2;
Above statement would execute sequentially.
$ runprog1&runprog2&runprog2&
Above statement would execute all in parallel
$ (runprog1; runprog2; runprog2;)&
Above statement would start processes sequentially and then execution is parallel.
Displaying the AJAX content in a separate window
Write the following piece of code in your call back function to display the AJAX content in a separate browser window.
Note: You need to make sure your browser pop up blocker has disabled.
function(data) {
var myWindow = window.open('','Name of the Window','');
myWindow.document.open();
myWindow.document.write(data);
myWindow.document.close();
}
Note: You need to make sure your browser pop up blocker has disabled.
CakePHP: remove cakePHP Flash messages using JQuery
Typically you would have all the cakePHP flash messages inside the div - alert_messages.
By using JQuery, we can remove these after intended time period.
The following example removes the cakePHP flash message after 5 seconds time period.
By using JQuery, we can remove these after intended time period.
The following example removes the cakePHP flash message after 5 seconds time period.
$(document).ready(function() {
$('#alert_messages').animate({opacity: 1.0}, 5000).fadeOut();
});
style.display=‘none’ doesnt work on option tags in Chrome, IE
We cannot set a style, display:none on OPTION TAG in Chrome and IE, It can be done in Firefox !
Kinda Solutions :
1. Use disabled attribute for the OPTION
2. If you want to remove them permanently, use removeChild to delete the option.
3. If you want them to show/hide, then u might have to save the removed options into a javascript variable.
Kinda Solutions :
1. Use disabled attribute for the OPTION
2. If you want to remove them permanently, use removeChild to delete the option.
3. If you want them to show/hide, then u might have to save the removed options into a javascript variable.
jQuery: Select all options in a Multiple-option Select Box
The following code will programmatically select all the options in a multiple-option Select box. Assuming you have jQuery setup.
The following code will programmatically UN-Select all the options in a multiple-option Select box.
$("#selectAllButt").click(function() { $("#mySelectList option").each(function() { $(this).attr("selected","selected"); }); });
The following code will programmatically UN-Select all the options in a multiple-option Select box.
$("#selectNoneButt").click(function() { $("#mySelectList option").each(function() { $(this).removeAttr("selected"); }); });
jQuery: Get checked checkboxes, radio buttons using Pseudo selectors
jQuery Pseudo Selectors are very efficient way to get the checked checkboxes or radio buttons.
The Pseudo Selector used is - :checked
Following are some simple examples to follow:
The Pseudo Selector used is - :checked
Following are some simple examples to follow:
$("#chkBoxIdOrRadioButtId").is(":checked");- returns a boolean true if checked or false
$("#chkBoxIdOrRadioButtId").not(":checked");- returns a boolean true if unchecked or false
$("#chkBoxIdOrRadioButtId").attr('checked','checked');- programmatically check the desired.
$("input:radio[name='myRadioGrpName']:checked").val();- return the value of the checked radio from the 'myRadioGrpName' group.
$("input[name='myChkBoxGrp']:checked").length;- returns the count of the checked
$("input[name='myChkBoxGrp']:not(:checked)").length;- returns the count of the unchecked
jQuery : Get the number of options in a select box
Using jQuery to get the number of options in a select box
Using jQuery to get the number of options that are selected in a select box
$('#mySelectBoxId option').length;
Using jQuery to get the number of options that are selected in a select box
$('#mySelectBoxId option:selected').length;
jQuery, CakePHP: Submit a form using ajax; implementing "quick save"
In CakePHP, If you want to submit a FORM using an AJAX request, use jQuery Form Plugin.
You can find a detailed example at http://marcgrabanski.com/article/cakephp-ajax-quick-save-jquery
An alternative to this plugin is invoking a javascript function, when a submit button is clicked, and which would read all the input data inside the form and send it to the controller.
You can find a detailed example at http://marcgrabanski.com/article/cakephp-ajax-quick-save-jquery
An alternative to this plugin is invoking a javascript function, when a submit button is clicked, and which would read all the input data inside the form and send it to the controller.
Tcl/Tk: How to find out the Tcl version
How to find out the Tcl version
[yourLoginPrompt]$ tclsh
% info patchlevel
8.4.13
% puts $tcl_version
8.4
% info tclversion
8.4
%
[yourLoginPrompt]$ tclsh
% info patchlevel
8.4.13
% puts $tcl_version
8.4
% info tclversion
8.4
%
Javascript: Make indexOf function working in IE
The indexOf function is a recent addition to the ECMA-262 standard and newly introduced in JavaScript 1.6, hence it may not work in some browsers. You can work around this by inserting the following piece of code at the beginning of your scripts.
Note: This function will work in FF1.5 or above, because this algorithm is exactly the one used in Firefox and SpiderMonkey(is the code-name for the Mozilla's C implementation of JavaScript).
Note: This function will work in FF1.5 or above, because this algorithm is exactly the one used in Firefox and SpiderMonkey(is the code-name for the Mozilla's C implementation of JavaScript).
if(!Array.indexOf) {
Array.prototype.indexOf = function(obj) {
for(var i = 0; i < this.length; i++) {
if(this[i] == obj) { return i; }
}
return -1;
}
}
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...