The software hurdles, blockers and bugs that I come across at workplace and don't want to solve all over again next time if and ever I face them.
Wednesday, December 15, 2010
Wednesday, December 8, 2010
KWAAK
http://code.google.com/p/kwaak3/
Someone says there's lot of cool code inside it. Will post more when I check it out.
Someone says there's lot of cool code inside it. Will post more when I check it out.
JNI calling java code from C++
http://groups.google.com/group/android-ndk/browse_thread/thread/96077556a5434005
http://groups.google.com/group/android-ndk/browse_thread/thread/96077556a5434005/80c242fb2bdc1f05/80c242fb2bdc1f05?pli=1
Method Signature:
http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/method.html
Other resources:
http://download.oracle.com/javase/6/docs/technotes/guides/jni/spec/functions.html#wp16660
http://www.public.iastate.edu/~java/docs/guide/nativemethod/functions.doc.html#16656
http://groups.google.com/group/android-ndk/browse_thread/thread/96077556a5434005/80c242fb2bdc1f05/80c242fb2bdc1f05?pli=1
Method Signature:
http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/method.html
Other resources:
http://download.oracle.com/javase/6/docs/technotes/guides/jni/spec/functions.html#wp16660
http://www.public.iastate.edu/~java/docs/guide/nativemethod/functions.doc.html#16656
Tuesday, December 7, 2010
Fix android activity screen orientation
In your activity class insert code:
@Override
public void onConfigurationChanged(Configuration newConfig)
{ super.onConfigurationChanged(newConfig);
}
In your manifest activity tag, declare attribute:
android:screenOrientation="portrait"
@Override
public void onConfigurationChanged(Configuration newConfig)
{ super.onConfigurationChanged(newConfig);
}
In your manifest activity tag, declare attribute:
android:screenOrientation="portrait"
Friday, December 3, 2010
How to implement the source's relative path or absolute unix format path in subdir.mk automatically
How to implement the source's relative path or absolute unix format path in subdir.mk automatically :
eclipse subdir.mk target pattern contains no `%'. Stop.:
http://www.eclipse.org/forums/index.php?t=tree&th=164513&
eclipse subdir.mk target pattern contains no `%'. Stop.:
http://www.eclipse.org/forums/index.php?t=tree&th=164513&
Thursday, December 2, 2010
Predator sound in android
Configure AudioRecord input as stereo and AudioTrack output as mono. You will get sound as if a predator's listening.
Wednesday, December 1, 2010
Monday, November 1, 2010
Problems solved while Making CPP app work on eclipse CDT with cygwin
On Windows.
Using libsndfile to decode wav file to raw pcm.
Problem1: Linking to the external library libsndfile.
Extracting/installing libsndfile gave me the header and DLL.
In Eclipse, Set [Project->Properties->C/C++ General->"Paths and Symbols"->include] and [Libraries] to the .h and .dll files respectively.(F:\libsnd\includes\libsndfile-1.h and F:\libsnd\libsndfile-1.dll)
Result: While linking "File not found: libsndfile-1.h"
Solution:
Added folder containing libsndfile-1.dll (F:\libsnd\) to [Project->Properties->C/C++ General->"Paths and Symbols"->Library Paths] and added "sndfile-1" to [Libraries] {"libsndfile-1.dll" - ["lib", ".dll"]}
Using libsndfile to decode wav file to raw pcm.
Problem1: Linking to the external library libsndfile.
Extracting/installing libsndfile gave me the header and DLL.
In Eclipse, Set [Project->Properties->C/C++ General->"Paths and Symbols"->include] and [Libraries] to the .h and .dll files respectively.(F:\libsnd\includes\libsndfile-1.h and F:\libsnd\libsndfile-1.dll)
Result: While linking "File not found: libsndfile-1.h"
Solution:
Added folder containing libsndfile-1.dll (F:\libsnd\) to [Project->Properties->C/C++ General->"Paths and Symbols"->Library Paths] and added "sndfile-1" to [Libraries] {"libsndfile-1.dll" - ["lib", ".dll"]}
Solved.
Problem2: Now EXE is generated but on "Run" throws "multiple target patterns. Stop." in some ".d" file
http://dev.eclipse.org/newslists/news.eclipse.tools.cdt/msg12202.html : The ":" in path to header file is detected as a new target.
Solution:
Changed "F:\libsnd\includes\libsndfile-1.h" to "/cygdrive/f/libsnd/includes/libsndfile-1.h" in [Project->Properties->C/C++ General->"Paths and Symbols"->include]
Solved.
Problem3: While debugging it says "gdb unknown target exception"
Add path to DLL file in environment variable "PATH". Restart eclipse.
Or Copy the dll to the project folder
Tried editing the path variable.
Solved.
Thursday, October 21, 2010
Monday, October 18, 2010
Thursday, October 7, 2010
Android services
http://mindtherobot.com/blog/37/android-architecture-tutorial-developing-an-app-with-a-background-service-using-ipc/
http://www.helloandroid.com/tutorials/musicdroid-audio-player-part-ii
http://marakana.com/forums/android/examples/60.html
http://www.androidcompetencycenter.com/2009/01/basics-of-android-part-iii-android-services/
http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/
http://www.helloandroid.com/tutorials/musicdroid-audio-player-part-ii
http://marakana.com/forums/android/examples/60.html
http://www.androidcompetencycenter.com/2009/01/basics-of-android-part-iii-android-services/
http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/
Android multithreading
http://developerlife.com/tutorials/?p=290 -How to build a service-enabled Android app – Part 3/3 Multithreading
http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html -Multithreading For Performance
http://developer.android.com/resources/articles/painless-threading.html - thats it
http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html -Multithreading For Performance
http://developer.android.com/resources/articles/painless-threading.html - thats it
Wednesday, October 6, 2010
Reactable -digital audio processing
http://www.youtube.com/watch?v=Mgy1S8qymx0&feature=related -reactable live performance @ submixpro studio torino 02
http://www.youtube.com/watch?v=PGiasLiGTX4&feature=related
http://www.youtube.com/watch?v=PGiasLiGTX4&feature=related
Tuesday, September 28, 2010
Digital Audio Processing notes - from basics to who knows
http://en.wikipedia.org/wiki/Amplifier - basically wanted to check why gain can't be increased to infinity without affecting the information in audio(quality).
The gain of an amplifier is the ratio of output to input power or amplitude, and is usually measured in decibels.
The bandwidth of an amplifier is the range of frequencies for which the amplifier gives "satisfactory performance". The definition of "satisfactory performance" may be different for different applications. However, a common and well-accepted metric is the half power points (i.e. frequency where the power goes down by half its peak value) on the output vs. frequency curve.
In ultra high fidelity amplifier design, the amp's frequency response should extend considerably beyond this (one or more octaves either side) and might have −3 dB points < 10 and > 65 kHz.
Professional touring amplifiers often have input and/or output filtering to sharply limit frequency response beyond 20 Hz-20 kHz; too much of the amplifier's potential output power would otherwise be wasted on infrasonic and ultrasonic frequencies, and the danger of AM radio interference would increase.
Modern switching amplifiers need steep low pass filtering at the output to get rid of high frequency switching noise and harmonics.
Efficiency is a measure of how much of the power source is usefully applied to the amplifier's output.
Commercially available Class D switching amplifiers have reported efficiencies as high as 90%.
An ideal amplifier would be a totally linear device, but real amplifiers are only linear within limits.
When the signal drive to the amplifier is increased, the output also increases until a point is reached where some part of the amplifier becomes saturated and cannot produce any more output; this is called clipping, and results in distortion.
Noise is an undesirable but inevitable product of the electronic devices and components
http://en.wikipedia.org/wiki/Switching_amplifier - A Class D amplifier or switching amplifier is an electronic amplifier where all power devices (usually MOSFETs) are operated as binary switches. They are either fully on or fully off. Ideally, zero time is spent transitioning between those two states.
http://www.audiosonica.com/en/course/post/2/Index- cool. got it from wikiversity. study sound effects concepts from here.
http://en.wikiversity.org/wiki/Getting_started_with_sound_recording
http://en.wikiaudio.org/Main_Page - on it.
http://en.wikibooks.org/wiki/Reaktor/Links/DSP
http://www.musicdsp.org/showmany.php -source codes :))) couldn't be better
http://www.digitalfilter.com/enindex.html
search "digital audio processing" on wikibooks
http://www.halfbakery.com/idea/Noise_20Cancelling_20Voice_20Amplifier -One would not want these voice wavelengths amplified, for fear of deafening the user by amplifiying noise components (eg: cymbals) which happened to be in that wavelength as well. The NCVA improves the signal of voice sounds by adding a low background of white noise at these same voice frequencies. This will not make voices louder, but will make them sharper. That's stochastic resonance.
http://www.freepatentsonline.com/4506379.html
http://www.freepatentsonline.com/4506379.pdf
http://members.misty.com/don/hivoice.html -interesting.How to Get More Apparent Voice Audio Power with Less Amplifier Power! Some about some "formants"
http://www.cs.cmu.edu/~music/icm/slides/week_10.pdf -Introduction to Computer Music. Week 10 - The Human Voice. More "formants"
http://users.otenet.gr/~athsam/speetch_filter.htm -for electronicians
The gain of an amplifier is the ratio of output to input power or amplitude, and is usually measured in decibels.
The bandwidth of an amplifier is the range of frequencies for which the amplifier gives "satisfactory performance". The definition of "satisfactory performance" may be different for different applications. However, a common and well-accepted metric is the half power points (i.e. frequency where the power goes down by half its peak value) on the output vs. frequency curve.
In ultra high fidelity amplifier design, the amp's frequency response should extend considerably beyond this (one or more octaves either side) and might have −3 dB points < 10 and > 65 kHz.
Professional touring amplifiers often have input and/or output filtering to sharply limit frequency response beyond 20 Hz-20 kHz; too much of the amplifier's potential output power would otherwise be wasted on infrasonic and ultrasonic frequencies, and the danger of AM radio interference would increase.
Modern switching amplifiers need steep low pass filtering at the output to get rid of high frequency switching noise and harmonics.
Efficiency is a measure of how much of the power source is usefully applied to the amplifier's output.
Commercially available Class D switching amplifiers have reported efficiencies as high as 90%.
An ideal amplifier would be a totally linear device, but real amplifiers are only linear within limits.
When the signal drive to the amplifier is increased, the output also increases until a point is reached where some part of the amplifier becomes saturated and cannot produce any more output; this is called clipping, and results in distortion.
Noise is an undesirable but inevitable product of the electronic devices and components
http://en.wikipedia.org/wiki/Switching_amplifier - A Class D amplifier or switching amplifier is an electronic amplifier where all power devices (usually MOSFETs) are operated as binary switches. They are either fully on or fully off. Ideally, zero time is spent transitioning between those two states.
http://www.audiosonica.com/en/course/post/2/Index- cool. got it from wikiversity. study sound effects concepts from here.
http://en.wikiversity.org/wiki/Getting_started_with_sound_recording
http://en.wikiaudio.org/Main_Page - on it.
http://en.wikibooks.org/wiki/Reaktor/Links/DSP
http://www.musicdsp.org/showmany.php -source codes :))) couldn't be better
http://www.digitalfilter.com/enindex.html
search "digital audio processing" on wikibooks
http://www.halfbakery.com/idea/Noise_20Cancelling_20Voice_20Amplifier -One would not want these voice wavelengths amplified, for fear of deafening the user by amplifiying noise components (eg: cymbals) which happened to be in that wavelength as well. The NCVA improves the signal of voice sounds by adding a low background of white noise at these same voice frequencies. This will not make voices louder, but will make them sharper. That's stochastic resonance.
http://www.freepatentsonline.com/4506379.html
http://www.freepatentsonline.com/4506379.pdf
http://members.misty.com/don/hivoice.html -interesting.How to Get More Apparent Voice Audio Power with Less Amplifier Power! Some about some "formants"
http://www.cs.cmu.edu/~music/icm/slides/week_10.pdf -Introduction to Computer Music. Week 10 - The Human Voice. More "formants"
http://users.otenet.gr/~athsam/speetch_filter.htm -for electronicians
Monday, September 27, 2010
Tuesday, September 21, 2010
Monday, September 20, 2010
Audacity: setup source- visual studio
First things first- install wxWidgets
http://wiki.wxwidgets.org/Downloading_and_installing_wxWidgets- its just about the env var "WXWIN"
http://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide
http://wiki.wxwidgets.org/Downloading_and_installing_wxWidgets- its just about the env var "WXWIN"
http://wiki.wxwidgets.org/Microsoft_Visual_C%2B%2B_Guide
Audacity: Noise removal
http://wiki.audacityteam.org/wiki/HowAudacityWorks#Noise_Removal - check out the section on tinkling effects
Wednesday, September 8, 2010
JAVA performance measurement- An effective and the most complicated tool ever :P
ANSWER:- A Stopwatch that hardly ticks.
http://java.sun.com/docs/books/performance/1st_edition/html/JPMeasurement.fm.html
Works great though.
http://java.sun.com/docs/books/performance/1st_edition/html/JPMeasurement.fm.html
Works great though.
Friday, September 3, 2010
Thursday, September 2, 2010
Android Embedded activity
http://www.mail-archive.com/android-beginners@googlegroups.com/msg15982.html
http://markmail.org/message/b3zfvuw7klgnz7f2 - condition for permission to embed
http://code.google.com/p/android/issues/detail?id=8818 - mem leak in localactivity manager. Status to be verified.
http://markmail.org/message/b3zfvuw7klgnz7f2 - condition for permission to embed
http://code.google.com/p/android/issues/detail?id=8818 - mem leak in localactivity manager. Status to be verified.
Wednesday, September 1, 2010
Tuesday, August 31, 2010
Kill android app
http://stackoverflow.com/questions/2550099/how-to-kill-an-android-activity-when-leaving-it-so-that-it-cannot-be-accessed-fro
http://www.androidcompetencycenter.com/2009/01/android-basics-managing-activity-states-part-i/
http://androidforums.com/application-development/133372-onpause-onstop-problems.html
http://www.androidcompetencycenter.com/2009/01/android-basics-managing-activity-states-part-i/
http://androidforums.com/application-development/133372-onpause-onstop-problems.html
Garbage collection and performance
http://www.ibm.com/developerworks/java/library/j-jtp01274.html - Hints, tips, and myths about writing garbage collection-friendly classes
Sunday, August 29, 2010
API demos notes
1. SharedPreferences : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/PersistentState.html
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/RedirectEnter.html - follow the classes in the source for advanced SharedPreferences ops.
eg: preferences.edit().remove("text").commit();
2. TextView.BufferType.EDITABLE - This allows us to later extend the text buffer : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/ReceiveResult.html
3. Example of removing yourself from the history stack after forwarding to another activity(just call finish) : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/Forwarding.html
4. Translucent activity - android:theme="@style/Theme.Transparent" in the activity declaration in manifest : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/TranslucentActivity.html
5. Translucent+BLUR background -
// Have the system blur any windows behind this one.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
Also in manifest - android:theme="@style/Theme.Transparent"> : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/TranslucentBlurActivity.html
6. Services : later
7.
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/RedirectEnter.html - follow the classes in the source for advanced SharedPreferences ops.
eg: preferences.edit().remove("text").commit();
2. TextView.BufferType.EDITABLE - This allows us to later extend the text buffer : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/ReceiveResult.html
3. Example of removing yourself from the history stack after forwarding to another activity(just call finish) : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/Forwarding.html
4. Translucent activity - android:theme="@style/Theme.Transparent" in the activity declaration in manifest : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/TranslucentActivity.html
5. Translucent+BLUR background -
// Have the system blur any windows behind this one.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
Also in manifest - android:theme="@style/Theme.Transparent"> : http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/TranslucentBlurActivity.html
6. Services : later
7.
Friday, August 27, 2010
Layout inflation. Create view from XML
http://developerlife.com/tutorials/?p=303 - Just use LayoutInflator instead of ViewInflate. See http://osdir.com/ml/Android-Developers/2010-02/msg03977.html where it says VI was replaced with LI.
Wednesday, August 25, 2010
My Android links
http://developerlife.com/tutorials/?p=300 - Getting started
http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html - Using relativelayout to reduce embedding of linearlayouts.
http://mobiforge.com/designing/story/understanding-user-interface-android-part-3-more-views - viewswitcher
http://groups.google.com/group/android-developers/browse_thread/thread/9b7dfa2cd9abec6b - android audio discussions April2010
http://groups.google.com/group/android-developers/browse_thread/thread/dda83b16eda1f848/b5d3cc89efea6dbd?lnk=gst&q=audio+direct+buffer#b5d3cc89efea6dbd - why not use NDK private APIs.
http://www.androidcompetencycenter.com/2009/01/android-basics-managing-activity-states-part-i/
http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html
http://source.android.com/porting/dalvik.html - android dalvik official page
http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html - Using relativelayout to reduce embedding of linearlayouts.
http://mobiforge.com/designing/story/understanding-user-interface-android-part-3-more-views - viewswitcher
http://groups.google.com/group/android-developers/browse_thread/thread/9b7dfa2cd9abec6b - android audio discussions April2010
http://groups.google.com/group/android-developers/browse_thread/thread/dda83b16eda1f848/b5d3cc89efea6dbd?lnk=gst&q=audio+direct+buffer#b5d3cc89efea6dbd - why not use NDK private APIs.
http://www.androidcompetencycenter.com/2009/01/android-basics-managing-activity-states-part-i/
http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html
http://source.android.com/porting/dalvik.html - android dalvik official page
Monday, August 9, 2010
Android error: "audiorecord Could not get audio input for record source 1"
http://comments.gmane.org/gmane.comp.handhelds.android.devel/84064 - says: "I was trying to start recording
from 2 separate threads at the same time causing a conflict."
http://langtagsandroid.langtags.com/blog/?p=605 - says: Everytime you get an error instantiating AudioRecord it doesn´t release it´s resources the way it should so you won´t be able to request it again unless you restart your phone (or close and reopen
the emulator).
from 2 separate threads at the same time causing a conflict."
http://langtagsandroid.langtags.com/blog/?p=605 - says: Everytime you get an error instantiating AudioRecord it doesn´t release it´s resources the way it should so you won´t be able to request it again unless you restart your phone (or close and reopen
the emulator).
This solution (restarting emulator) worked for me
Sunday, August 8, 2010
Android: Horizontal Progress Bar
<ProgressBar
android:id="@+id/ProgressBar01"
android:layout_height="wrap_content"
android:layout_width="250px"
style="?android:attr/progressBarStyleHorizontal">
</ProgressBar>
android:id="@+id/ProgressBar01"
android:layout_height="wrap_content"
android:layout_width="250px"
style="?android:attr/progressBarStyleHorizontal">
</ProgressBar>
Tuesday, July 27, 2010
Monday, July 26, 2010
Android Layout tutorials
http://developer.android.com/resources/tutorials/views/index.html
Linear
Relative
Table
Grid
Tab
List
Linear
Relative
Table
Grid
Tab
List
Wednesday, July 21, 2010
Android viewflipper and animated menu
http://www.warriorpoint.com/blog/2009/05/26/android-switching-screens-in-an-activity-with-animations-using-viewflipper/
http://www.agilemedicine.com/medBlog/?p=32
http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/
http://whyandroid.com/android/174-flipping-your-views.html
http://android-journey.blogspot.com/2009/12/android-viewflipper-and-slidingdrawer.html
http://www.agilemedicine.com/medBlog/?p=32
http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/
http://whyandroid.com/android/174-flipping-your-views.html
http://android-journey.blogspot.com/2009/12/android-viewflipper-and-slidingdrawer.html
Thursday, July 15, 2010
Low Level Android app fundamentals: Rookie/Novice/fresher...
APPLICATION COMPONENTS:
1. Activity(ACT)
activity, window(W), view(V)
Activity.setContentView()
2. Service(SVC)-
3. Broadcast Receiver(BR)-
4. Content Provider(CP)-
ContentProvider(CP) and ContentResolver(CR)
ACTIVATING COMPONENTS USING INTENT
ACT:
SVC:
BR:
onReceive()
SHUTTING DOWN COMPONENTS
ACT:
finish()
finishActivity()
. (
startActivityForResult())
SVC:
stopSelf()
Context.stopService()
.
THE MANIFEST FILE
INTENT FILTERS
ACTIVITIES AND TASKS
The principal Intent flags are:
FLAG_ACTIVITY_NEW_TASK
FLAG_ACTIVITY_CLEAR_TOP
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
FLAG_ACTIVITY_SINGLE_TOP
The principal <activity>
attributes are:taskAffinity
launchMode
allowTaskReparenting
clearTaskOnLaunch
alwaysRetainTaskState
finishOnTaskLaunch
Wednesday, July 14, 2010
Clean URLs with Drupal-UrlRewriteFilter-Quercus-Jboss
http://www.brianshowalter.com/blog/running_drupal_on_quercus - There's a nice RewriteRule-RewriteMatch combo classes for UrlRewriteFilter posted at this blog.
But it's designed for tomcat and didn't work on following JBoss configuration right away.
The JBoss config:
1. JBoss-4.2.2
2. Deploying the Quercus web-app(with Drupal inside) as exploded war (Folder name= "myapp.war").
3. Quercus 403
4. Drupal-6.17.
5. UrlRewriteFilter-320
Steps that worked for me:
1. Follow the above blog at brianshowalter.com.
2. Download UrlRewriteFilter source code from http://code.google.com/p/urlrewritefilter/
(http://code.google.com/p/urlrewritefilter/downloads/detail?name=urlrewritefilter-3.2.0-src.zip&can=2&q=)
3. You must have already downloaded drupalrewrite_0.1 in step1.
4. Couldn't find a link for posting comments on above blog. Hence posting the modified source code here. Kindly setup UrlRewriteFilter and drupalrewrite_0.1 sources with all required libs in eclipse etc. and copy the compiled classes to your myapp.war/WEB-INF/classes.
5. Checkout updated sources for drupalrewrite from http://drupalrewritefilter.googlecode.com (http://code.google.com/p/drupalrewritefilter/source/checkout) and compile/jar and copy to WEB-INF/lib(jar) or WEB-INF/classes(class) as you wish.
6. Good to go.
Thank you.
But it's designed for tomcat and didn't work on following JBoss configuration right away.
The JBoss config:
1. JBoss-4.2.2
2. Deploying the Quercus web-app(with Drupal inside) as exploded war (Folder name= "myapp.war").
3. Quercus 403
4. Drupal-6.17.
5. UrlRewriteFilter-320
Steps that worked for me:
1. Follow the above blog at brianshowalter.com.
2. Download UrlRewriteFilter source code from http://code.google.com/p/urlrewritefilter/
(http://code.google.com/p/urlrewritefilter/downloads/detail?name=urlrewritefilter-3.2.0-src.zip&can=2&q=)
3. You must have already downloaded drupalrewrite_0.1 in step1.
4. Couldn't find a link for posting comments on above blog. Hence posting the modified source code here. Kindly setup UrlRewriteFilter and drupalrewrite_0.1 sources with all required libs in eclipse etc. and copy the compiled classes to your myapp.war/WEB-INF/classes.
5. Checkout updated sources for drupalrewrite from http://drupalrewritefilter.googlecode.com (http://code.google.com/p/drupalrewritefilter/source/checkout) and compile/jar and copy to WEB-INF/lib(jar) or WEB-INF/classes(class) as you wish.
6. Good to go.
Thank you.
Monday, June 21, 2010
Removing HTML tags from a String using Regex
result = data.replaceAll("\\\\n","<br/>"). //replace \n with <br/>,
replaceAll("\\\\", ""). //remove stray "\"s
replaceAll("\\\"", "\\\\\""). // and escape double quotes
replaceAll("<[\\p{Alnum}\\p{Space}\\.\\-=/:\\\"\\\\;]*>"," "). //remove all opening html tags
replaceAll("</[\\p{Alnum}]*>"," "); //remove all closing html tags
Tuesday, June 15, 2010
High Level Hadoop MapReduce: Rookie/Novice/fresher...
MapReduce borrows a lot from functional programming(Lisp/ML/Scheme). Func. prog. expects to process lists of data frequently, hence they have a lot of inbuilt iterator-mechanisms and higher-level functions called list-comprehensions that are operators over lists. Two of these operators are map and reduce. Like map operator, Mapper takes a record (assumed to be a key-value pair) but can emit multiple key-value pairs(map operator does only one). A characteristic of MapRed paradigm is that mapper should be processing individual records in isolation of one-another.(One Record = up to you- depends on the class that loads the data from the block into mapper as k-v pair records).
Reducer takes a key and list of values and can emit none, one or multiple key-value pairs.
People also skip mapper or more often reducer, if it suffices for the app.
Reducers don't start until all mappers complete. They run on the same nodes as mappers(after mappers complete).
All values with same keys are collected from all mappers(that emitted that key) and sent to same reducer. This involves network communication. If multiples keys are processed by one reducer, they are presented to it in sorted order(No assumptions about the values of those keys). This is called "sort and shuffle" phase handled by the underlying framework. A single reduce task processes single key(it takes one key and list of values as input).
Within sort and shuffle, there can be a user-defined combine task that's run on the mapper's intermediate results. If app-logic allows it could be same as reducer code(eg: if reducer is commutative and associative). Combining phase is disabled by default. It runs on the mapper machine. It's solely for reducing network data-load and load on reducer. Don't perform any data-specific operation in combine phase. It may run zero, one or more times.(depends on size of data). Example is the word-count map reduce jobs. Mapper emits [, 1] . Combiner aggragates that mapper's results to [, n](no. of times the word occurred in the input blocks local to that machine). Then comes the reducers(mappers die).
Thank You.
Reducer takes a key and list of values and can emit none, one or multiple key-value pairs.
It's a general notion to ignore the key that's input to a map task. They could be byte offset to a chunk of data.
People also skip mapper or more often reducer, if it suffices for the app.
Reducers don't start until all mappers complete. They run on the same nodes as mappers(after mappers complete).
All values with same keys are collected from all mappers(that emitted that key) and sent to same reducer. This involves network communication. If multiples keys are processed by one reducer, they are presented to it in sorted order(No assumptions about the values of those keys). This is called "sort and shuffle" phase handled by the underlying framework. A single reduce task processes single key(it takes one key and list of values as input).
Within sort and shuffle, there can be a user-defined combine task that's run on the mapper's intermediate results. If app-logic allows it could be same as reducer code(eg: if reducer is commutative and associative). Combining phase is disabled by default. It runs on the mapper machine. It's solely for reducing network data-load and load on reducer. Don't perform any data-specific operation in combine phase. It may run zero, one or more times.(depends on size of data). Example is the word-count map reduce jobs. Mapper emits [
Thank You.
Friday, June 11, 2010
Hibernate JDBCConnectionException: could not execute query- Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
"org.quartz.JobExecutionException: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query [See nested exception: org.springframework.dao.DataAccessResourceFailureException: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query]
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 13,768,115 milliseconds ago. The last packet sent successfully to the server was 13,768,115 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem."
This problem occurred in a Grails application having a cron job that requests some data from an external server, processes it and persists some results. However the data is very large and the app requires 2+ Hrs. to process all of it before persisting a small result. The jdbc connection remains idle during this time.
Setting 'autoReconnect=true' or max_idle_time is certainly not a reliable solution for this.
What worked for me:
http://sacharya.com/grails-dbcp-stale-connections/: This was my exact problem. It says "By default, DBCP holds the pooled connections open for infinite time. But a database connection is essentially a socket connection, and it doesn’t come for free. The host OS, database host, and firewall have to allocate a certain amount of memory and other resources for each socket connection. It makes sense to those devices not to hold onto idle connections for ever. So the idea is to make sure that you don’t have stale connections in your pool that would otherwise be silently dropped by OS or firewall."
Modified my Datasource.groovy for working out this solution.
Had to use the following syntax from: http://stackoverflow.com/questions/376544/grails-mysql-maxpoolsize
Modified my Datasource.groovy:
Other relevant links:
http://drglennn.blogspot.com/2009/05/javasqlsqlexception-communication-link.html
http://commons.apache.org/dbcp/configuration.html
http://www.grails.org/DataSources+New
http://www.grails.org/1.2+Release+Notes
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 13,768,115 milliseconds ago. The last packet sent successfully to the server was 13,768,115 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem."
This problem occurred in a Grails application having a cron job that requests some data from an external server, processes it and persists some results. However the data is very large and the app requires 2+ Hrs. to process all of it before persisting a small result. The jdbc connection remains idle during this time.
Setting 'autoReconnect=true' or max_idle_time is certainly not a reliable solution for this.
What worked for me:
http://sacharya.com/grails-dbcp-stale-connections/: This was my exact problem. It says "By default, DBCP holds the pooled connections open for infinite time. But a database connection is essentially a socket connection, and it doesn’t come for free. The host OS, database host, and firewall have to allocate a certain amount of memory and other resources for each socket connection. It makes sense to those devices not to hold onto idle connections for ever. So the idea is to make sure that you don’t have stale connections in your pool that would otherwise be silently dropped by OS or firewall."
Modified my Datasource.groovy for working out this solution.
Had to use the following syntax from: http://stackoverflow.com/questions/376544/grails-mysql-maxpoolsize
Modified my Datasource.groovy:
dataSource {
pooled = true
dbCreate = "update"
url = "jdbc:mysql://localhost/yourDB"
driverClassName = "com.mysql.jdbc.Driver"
username = "yourUser"
password = "yourPassword"
properties {
maxActive = 50
maxIdle = 25
minIdle = 5
initialSize = 5
minEvictableIdleTimeMillis = 60000
timeBetweenEvictionRunsMillis = 60000
maxWait = 10000
} }
Other relevant links:
http://drglennn.blogspot.com/2009/05/javasqlsqlexception-communication-link.html
http://commons.apache.org/dbcp/configuration.html
http://www.grails.org/DataSources+New
http://www.grails.org/1.2+Release+Notes
Subscribe to:
Posts (Atom)