Interesting Prof at MIT
David Wingate
http://web.mit.edu/~wingated/www/index.html
Tuesday, December 28, 2010
Monday, October 18, 2010
Linux memory and 64bit useful commands
file
ulimit
if get error like Program received signal SIGSEGV, Segmentation fault.
0x000000380ee62184 in fwrite () from /lib64/libc.so.6
using gdb for non root user but works fine for root user on
RHEL 5.4
try
export MALLOC_CHECK_=3
and recompile the program with gcc
That should solve the problem
ulimit
if get error like Program received signal SIGSEGV, Segmentation fault.
0x000000380ee62184 in fwrite () from /lib64/libc.so.6
using gdb for non root user but works fine for root user on
RHEL 5.4
try
export MALLOC_CHECK_=3
and recompile the program with gcc
That should solve the problem
Sunday, September 6, 2009
Use GMail SMTP to send mail in PHP
An example to use phpmailer class to send email using a gmail account.
<?php include("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // use ssl $mail->Host = "smtp.gmail.com"; // GMAIL's SMTP server $mail->Port = 465; // SMTP port used by GMAIL server $mail->Username = "your_gmail_account@gmail.com"; // GMAIL username $mail->Password = "password"; // GMAIL password $mail->AddReplyTo("other_email@hotmail.com","FirstName LastName"); // Reply email address $mail->From = "your_gmail_account@gmail.com"; $mail->FromName = "FirstName LastName"; // Name to appear once the email is sent $mail->Subject = "Subject of the email"; // Email's subject //$mail->Body = "Hello World,<br />This is the HTML BODY<br />"; //HTML Body $mail->AltBody = "This is a test email"; // optional, comment out and test $mail->WordWrap = 50; // set word wrap $mail->MsgHTML($body); // [optional] Send body email as HTML $mail->AddAddress("abc@email.com", "Test email"); // email address of recipient //$mail->AddAttachment("files/files.zip"); // [optional] attachment $mail->IsHTML(true); // [optional] send as HTML if(!$mail->Send()) echo "Mailer Error: " . $mail->ErrorInfo; else echo "Message sent!"; ?>
Friday, August 14, 2009
Modify PMapper Map File from url
Simply use mapscript to modify the contents from the globals.php after roughly line 60:$map = ms_newMapObj($PM_MAP_FILE);
Documentation on PHP MapScript
Use the following to get capabilities on a WMS
http://SERVICE-ENDPOINT/?request=GetCapabilities&service=WMS&version=DESIRED-VERSION
Documentation on PHP MapScript
Use the following to get capabilities on a WMS
http://SERVICE-ENDPOINT/?request=GetCapabilities&service=WMS&version=DESIRED-VERSION
Friday, July 24, 2009
Printing Google Visualization
Google Visualization Api does not provide an api to print them. One way is to convert your codes to Google chart api which renders images.
The other way is to use the following:
Website Thumb Generator can be used to create website thumbnails for your needs, or start your own website thumbnail generation service.
Requirements:
Windows hosting
PHP GD library (installed on most hostings)
Permissions to execute third-party applications (i.e. exe files)
Permissions to execute Internet Explorer
How it works:
Website Thumbnail Generator checks if it already has website image in the cache, and shows it in the browser.
If no cached image then IECapt would be run from the script.
IECapt would run Internet Explorer, grab full sized website screenshot from it, and save image into the folder you specified in script settings.
Then Website Thumbnail Generator would resize image, and show it in the browser.
Installation:
Download IECapt from http://iecapt.sourceforge.net Place it in some folder on your server.
Download Website Thumbnail Generator using link below, and unzip it to the same folder.
Update webthumb.php with your settings for thumbnails folder, cache time, default thumbnail size, etc.
Sample usage:
webthumb.php?url=http://www.microsoft.com
webthumb.php?url=http://www.thumbnails.com&x=150&y=150
Website Thumbnail Generator
The other way is to use the following:
Website Thumb Generator can be used to create website thumbnails for your needs, or start your own website thumbnail generation service.
Requirements:
Windows hosting
PHP GD library (installed on most hostings)
Permissions to execute third-party applications (i.e. exe files)
Permissions to execute Internet Explorer
How it works:
Website Thumbnail Generator checks if it already has website image in the cache, and shows it in the browser.
If no cached image then IECapt would be run from the script.
IECapt would run Internet Explorer, grab full sized website screenshot from it, and save image into the folder you specified in script settings.
Then Website Thumbnail Generator would resize image, and show it in the browser.
Installation:
Download IECapt from http://iecapt.sourceforge.net Place it in some folder on your server.
Download Website Thumbnail Generator using link below, and unzip it to the same folder.
Update webthumb.php with your settings for thumbnails folder, cache time, default thumbnail size, etc.
Sample usage:
webthumb.php?url=http://www.microsoft.com
webthumb.php?url=http://www.thumbnails.com&x=150&y=150
Website Thumbnail Generator
Wednesday, July 22, 2009
JNI example
A simple example of JNI
Java Native Interface (JNI) is a standard programming interface for writing Java native methods and embedding the JVM into native applications. Simply, it is a Java technology with which a Java application can call a method written with such as C, C++ and assembly.
Adopting JNI is very simple. You need two components -- a Java program, and a native library. The native library is written in other languages and compiled on corresonding platforms.
A function defined in the native library should be declared in Java code as a 'native' function. And the native library needs to be load in Java code with the System.loadLibrary method. The natvie function could be referced by other regular functions in the Java code.
Following is an example of the Java Code.
JNIFoo.java
===========
public class JNIFoo {
public native String nativeFoo();
static {
System.loadLibrary("foo");
}
public void print () {
String str = nativeFoo();
System.out.println(str);
}
public static void main(String[] args) {
(new JNIFoo()).print();
return;
}
}
# javac JNIFoo.java
# javah -jni JNIFoo
A file named as JNIFoo.h is created by running the above two commands. A function of 'JNIEXPORT jstring JNICALL Java_JNIFoo_nativeFoo (JNIEnv *, jobject)' is in the JNIFoo.h file. The function must be implemented in a source code file (e.g. a C file), and it is the actually entry to do what the funtion of natvieFoo() in Java code do.
foo.c
======
#include
#include
#include
#include
#include "JNIFoo.h"
JNIEXPORT jstring JNICALL Java_JNIFoo_nativeFoo (JNIEnv *env, jobject obj)
{
int i;
int ds_ret;
char* newstring;
jstring ret = 0;
newstring = (char*)malloc(30);
if(newstring == NULL)
{
return ret;
}
memset(newstring, 0, 30);
newstring = "foo: Test program of JNI.\n";
ret = (*env)->NewStringUTF(env, newstring);
free(newstring);
return ret;
}
JNI libraries are named with the library name used in the System.loadLibrary method of your Java code with a prefix and a suffix. On different OS, the prefix and suffix might be different.
On Solaris OS, it is prefixed by 'lib' and suffixed with '.so'
# cc -Kpic -G -o libfoo.so -I/usr/java/include -I/usr/java/include/solaris foo.c -z text
On Linux OS, it is prefixed by 'lib' and suffixed with '.so'.
# gcc -shared -fpic -o libfoo.so -I/usr/java/include -I/usr/java/include/linux foo.c
On Windows OS, it is prefixed by nothing and suffixed with '.dll'.
It could be compiled with Visual Studio automatically and create a file named as foo.dll.
On Mac OS, it is prefixed by 'lib' and suffixed with '.jnilib'.
# gcc -dynamiclib -o libfoo.jnilib -I/System/Library/Frameworks/JavaVM.framework/Headers foo.c -framework JavaVM
To run the JNI program locally, the following command is fine:
# java -Djava.library.path= JNIFoo
Java Native Interface (JNI) is a standard programming interface for writing Java native methods and embedding the JVM into native applications. Simply, it is a Java technology with which a Java application can call a method written with such as C, C++ and assembly.
Adopting JNI is very simple. You need two components -- a Java program, and a native library. The native library is written in other languages and compiled on corresonding platforms.
A function defined in the native library should be declared in Java code as a 'native' function. And the native library needs to be load in Java code with the System.loadLibrary method. The natvie function could be referced by other regular functions in the Java code.
Following is an example of the Java Code.
JNIFoo.java
===========
public class JNIFoo {
public native String nativeFoo();
static {
System.loadLibrary("foo");
}
public void print () {
String str = nativeFoo();
System.out.println(str);
}
public static void main(String[] args) {
(new JNIFoo()).print();
return;
}
}
# javac JNIFoo.java
# javah -jni JNIFoo
A file named as JNIFoo.h is created by running the above two commands. A function of 'JNIEXPORT jstring JNICALL Java_JNIFoo_nativeFoo (JNIEnv *, jobject)' is in the JNIFoo.h file. The function must be implemented in a source code file (e.g. a C file), and it is the actually entry to do what the funtion of natvieFoo() in Java code do.
foo.c
======
#include
#include
#include
#include
#include "JNIFoo.h"
JNIEXPORT jstring JNICALL Java_JNIFoo_nativeFoo (JNIEnv *env, jobject obj)
{
int i;
int ds_ret;
char* newstring;
jstring ret = 0;
newstring = (char*)malloc(30);
if(newstring == NULL)
{
return ret;
}
memset(newstring, 0, 30);
newstring = "foo: Test program of JNI.\n";
ret = (*env)->NewStringUTF(env, newstring);
free(newstring);
return ret;
}
JNI libraries are named with the library name used in the System.loadLibrary method of your Java code with a prefix and a suffix. On different OS, the prefix and suffix might be different.
On Solaris OS, it is prefixed by 'lib' and suffixed with '.so'
# cc -Kpic -G -o libfoo.so -I/usr/java/include -I/usr/java/include/solaris foo.c -z text
On Linux OS, it is prefixed by 'lib' and suffixed with '.so'.
# gcc -shared -fpic -o libfoo.so -I/usr/java/include -I/usr/java/include/linux foo.c
On Windows OS, it is prefixed by nothing and suffixed with '.dll'.
It could be compiled with Visual Studio automatically and create a file named as foo.dll.
On Mac OS, it is prefixed by 'lib' and suffixed with '.jnilib'.
# gcc -dynamiclib -o libfoo.jnilib -I/System/Library/Frameworks/JavaVM.framework/Headers foo.c -framework JavaVM
To run the JNI program locally, the following command is fine:
# java -Djava.library.path=
Drupal Anonymous user access denied for view
INSERT INTO node_access VALUES (0, 0, 'all', 1, 0, 0);
Ignore any error shown.
update node n set status=1 where nid in (x);
where x contains all the newly created node is ex: 1,2
Subscribe to:
Posts (Atom)