If we have 2 column matrices A, B.
>>A = [10;20;30]
A =
10
20
30
>> B = [1;2;3]
B =
1
2
3
>> A+B
ans =
11
22
33
>> A*B
??? Error using ==> mtimes
Inner matrix dimensions must agree.
In order to perform "element-wise" operations, we have to use ".", so for multiplication ".*", division "./"
>> A.*B
ans =
10
40
90
>> A./B
ans =
10
10
10
CakePHP : Error: The requested address “/” was not found on this server
I was moving my cakephp application to a new server and had this issue: Error: The requested address “/” was not found on this server.
The following keys might resolve your issue:
1. Check your DATABASE_CONFIG (/app/config/database.php)
2. Delete all the cache files from all of your tmp subfolders (/app/tmp)
3. Make sure your /app/tmp folder (and all of its sub folders) are writable
If you still have issues with the app, you might have to change the debug switch to 2 or 3 in the /app/config/core.php
Find the line which says "Configure::write" and replace with the following:
Configure::write('debug', 3);
This would spit all the errors on your webpage. You can debug from there.
The following keys might resolve your issue:
1. Check your DATABASE_CONFIG (/app/config/database.php)
2. Delete all the cache files from all of your tmp subfolders (/app/tmp)
3. Make sure your /app/tmp folder (and all of its sub folders) are writable
If you still have issues with the app, you might have to change the debug switch to 2 or 3 in the /app/config/core.php
Find the line which says "Configure::write" and replace with the following:
Configure::write('debug', 3);
This would spit all the errors on your webpage. You can debug from there.
Mac: removing known hosts/ ssh-rsa keys /RSA key fingerprint.
1. Open known_hosts file located at /Users/username/.ssh/known_hosts or ~/.ssh/known_hosts
2. Delete the CONTENTS of the file.
Since .ssh is a hidden folder, you can show/hide hidden folders using directions at mac-showhide-files-in-mac
2. Delete the CONTENTS of the file.
Since .ssh is a hidden folder, you can show/hide hidden folders using directions at mac-showhide-files-in-mac
Kernighan’s Law !
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
Comparing Intel Core i3, i5, i7 processors
Intel Core i3
• Dual Core processor
• Hyper Threading Support (HT)
• Due to HT, this has 2 virtual cores.
• 2 physical cores, 2 virtual cores
• Turbo Boost (dynamic overclocking)
• Integrated graphics processor
• Fabrication : 32nm technology
Intel Core i5 – Dual Core
• Dual Core Processor
• Hyper Threading Support (HT)
• Due to HT, this has 2 virtual cores.
• 2 physical cores, 2 virtual cores
• Turbo Boost (dynamic overclocking)
• Integrated graphics processor
• Fabrication : 32nm technology
Intel Core i5 – Quad Core
• Quad Core Processor
• 4 physical cores.
• Turbo Boost (dynamic overclocking)
• Fabrication : 45nm technology
Intel Core i7
• Quad Core Processor
• Hyper Threading Support (HT)
• Due to HT, this has 8 virtual cores
• 4 physical cores, 8 virtual cores
• Turbo Boost Technology
• Fabrication : 45nm technology
Intel Core i7-980X and i7-970 have 6 physical cores and 12 virtual cores.
• Dual Core processor
• Hyper Threading Support (HT)
• Due to HT, this has 2 virtual cores.
• 2 physical cores, 2 virtual cores
• Turbo Boost (dynamic overclocking)
• Integrated graphics processor
• Fabrication : 32nm technology
Intel Core i5 – Dual Core
• Dual Core Processor
• Hyper Threading Support (HT)
• Due to HT, this has 2 virtual cores.
• 2 physical cores, 2 virtual cores
• Turbo Boost (dynamic overclocking)
• Integrated graphics processor
• Fabrication : 32nm technology
Intel Core i5 – Quad Core
• Quad Core Processor
• 4 physical cores.
• Turbo Boost (dynamic overclocking)
• Fabrication : 45nm technology
Intel Core i7
• Quad Core Processor
• Hyper Threading Support (HT)
• Due to HT, this has 8 virtual cores
• 4 physical cores, 8 virtual cores
• Turbo Boost Technology
• Fabrication : 45nm technology
Intel Core i7-980X and i7-970 have 6 physical cores and 12 virtual cores.
CakePHP: Multiple Inserts - Insert multiple rows using single statement.
Using the method saveAll(), we can achieve the desired goal. http://book.cakephp.org/view/75/Saving-Your-Data
Example:
If you want to save multiple records/rows into the same table.
This would result in inserting 3 rows in the "mymodelname" table.
Example:
If you want to save multiple records/rows into the same table.
$multipleRowData = Array(
Array('name' => 'Bob', 'phone' => "123-123-7777"),
Array('name' => 'Ann', 'phone' => "987-123-5555"),
Array('name' => 'Tom', 'phone' => "788-123-4569")
);
$this->Mymodelname->saveAll($multipleRowData);
This would result in inserting 3 rows in the "mymodelname" table.
CakePHP: Adding/deleting columns in the database after the application is Baked
If you had already baked the application and now if you made changes to the database by adding or deleting columns, then do the following:
1. Open "core.php" located at : app/config/core.php
2. Find the line which looks like: Configure::write('debug', 0);
3. Change it to Configure::write('debug', 2);
4. Refresh your application webpage.
5. Reset the line in core.php to Configure::write('debug', 0);
What basically this will do is refreshing the "model" cache.
Changing the debug level will ensure that all your databases changes are reloaded.
Following are the notes related to which debug level, you want to set.
/**
* CakePHP Debug Level:
*
* Production Mode:
* 0: No error messages, errors, or warnings shown. Flash messages redirect.
*
* Development Mode:
* 1: Errors and warnings shown, model caches refreshed, flash messages halted.
* 2: As in 1, but also with full debug messages and SQL output.
* 3: As in 2, but also with full controller dump. (NOTE: Not in CakePHP 1.3)
*
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
1. Open "core.php" located at : app/config/core.php
2. Find the line which looks like: Configure::write('debug', 0);
3. Change it to Configure::write('debug', 2);
4. Refresh your application webpage.
5. Reset the line in core.php to Configure::write('debug', 0);
What basically this will do is refreshing the "model" cache.
Changing the debug level will ensure that all your databases changes are reloaded.
Following are the notes related to which debug level, you want to set.
/**
* CakePHP Debug Level:
*
* Production Mode:
* 0: No error messages, errors, or warnings shown. Flash messages redirect.
*
* Development Mode:
* 1: Errors and warnings shown, model caches refreshed, flash messages halted.
* 2: As in 1, but also with full debug messages and SQL output.
* 3: As in 2, but also with full controller dump. (NOTE: Not in CakePHP 1.3)
*
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
jQuery: Count number of visible divs
$("div:visible").length
or
$("div:visible").size()
If we need for a specific 'class', then
$(".myclass div:visible").length
or
$(".myclass div:visible").size()
HTML : Easiest way to create simple tooltips
Tooltips are the ones which appear as little bubbles with text, when you mouse hover over an item on Web-page.
In HTML, it is very easy to create them.
Simply add 'title' attribute to the element.
Examples:
In HTML, it is very easy to create them.
Simply add 'title' attribute to the element.
Examples:
<a title="Tooltip for Anchor !" href="someLink" >Gliding Phenomena Blog </a>
<img title="Tooltip on an Image..." src="myPic.jpg" />
<div title="This is tooltip for the entire DIV">
Some content.
Blah
Blah
</div>
SQL : Update only year in the date field
UPDATE mytable SET datefield = CONCAT('2012','-',MONTH(datefield),'-',DAYOFMONTH(datefield)) WHERE YEAR(datefield) = 2006;
Javascript: Regex for Email Validation
function isValidEmail(email){
var emailRegx = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
return emailRegx.test(email);
}
Mac: Show/hide Hidden files in Mac OS
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
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
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...