Wednesday, May 16, 2012

Leave object in cache unchanged

this code works "perfectly". Creates an XDocument, puts it in cache, and retrieves it the next time round.



BUT i'd like the object in cache NOT to be affected by the changes made after the marked place, where I add some elements only valid in this session.



The object in cache is relevant for all users on the page, so should only be genereted/altered once in cache lifetime.



I COULD clone it from the cache or store it as a string I guess (not a reference type) and losd into new XDocument, but what would be the most gentle way? Seems overkill, when I can cache the XDocument as it is...



Thanks in advance,



Steen



{
string cachekey = "categories";
var cateGoryDoc = HttpRuntime.Cache.Get(cachekey) as XDocument;

if (cateGoryDoc == null)
{
XDocument doc = XDocument.Parse(this.ProductList1.getXML());
IEnumerable<XElement> mainCats =
from Category1 in doc.Descendants("product").Descendants("category") select Category1;
var cDoc = new XDocument(new XDeclaration("1.0", "utf-8", null), new XElement("root"));
cDoc.Root.Add(mainCats);
cateGoryDoc = cDoc;
HttpRuntime.Cache.Insert(cachekey, cDoc, null,
DateTime.Now.AddMinutes(10),
TimeSpan.Zero);
}


// I DO NOT WANT TO CHANGE THE DOC IN CACHE!!
if (HttpContext.Current.Request["tCats"] != null)
{
string[] tCats = HttpContext.Current.Request["tCats"].Split(Convert.ToChar(","));

foreach (string tCat in tCats)
{
cateGoryDoc.Root.Add(new XElement("selectedCategory", tCat));
}
}

this.catecoryXML.DocumentContent = cateGoryDoc.ToString();
this.catecoryXML.TransformSource = "/XSLTFile1.xslt";
}




Train voice recognition

I have built a voice recognition system in C# and I'm using the Microsoft Speech Platform 11.0 (Swedish language packs). I use a wav file as an input for the SpeechRecognitionEngine.



The problem is that some of the words (40%) are not recognized at all.



I would like to record some commands (a limited number of Swedish words and/or numbers) to a sound file and import them so that the SpeechRecognitionEngine could be able to understand them.



For example:



Record when an user says the word: "Katt" (Swedish word for cat) and then be able to tell the RecognitionEngine that this means "Katt".



Is this possible or are there better solutions?





Is Online Gambling getting more popular and is there a website where one could gamble?

Is Online Gambling getting more popular and is there a website where one could gamble?





Why does SQL display an & as &amp;?

I need some assistance, my query is below:



STUFF(
(
SELECT ',' + CountDesc
FROM Count INNER JOIN ProjectCount ON Count.Id = ProjectCount.CountId
WHERE ProjectCount.ProjectId = Project.Id ORDER BY Count.CountDesc
FOR XML PATH('')
), 1, 1, '') as [Country]


What happens is when i run this query and the Count table has an & in one of its fields, it displays the & &



Is there anyway to not let this happen?



Thanks in advance.





Accidentally merged other branches when using `git pull` with no arguments

Not knowing any better, I'd always used blissfully git pull (without arguments) to get remote updates.



Now that we're using branches, this has come back to haunt me.



After doing a git pull, I noticed that my local master had been merged with the other branches as well.



I'm trying to figure out how this happened so that I can avoid doing it again in the future, but no luck so far.



I didn't put anything strange in my .git/config file.





findAndResignFirstResponder not dismissing keyboard

I have 6 UITextFields created in Interface Builder. After entering the values, and clicking the search button, I need to dismiss the keyboard from the view.
Currently I'm using 'findAndResignFirstResponder' and have delegates set for all text fields however the keyboard is not dismissing.



Any idea why this isn't working? Is there a better way to dismiss the keyboard?





How to let user change iphone app theme?

I have Article and Category entities that have a many to many relationship. Category has a name and a imagePath (which keep its name and path to image of an icon for that category).
If I want to let user change icons (for example change theme with a new pack of icon) what should I do?



What I'm thinking now is create separate entity, called Theme, which keep categoryId (need to add that to category) and move imagePath from Category to this Theme entity, so it would become



Article <<->> Category  
..... - categoryId
..... - name


and



Theme
-categoryId
-imagePath


with this approach I have to keep the selected Theme in NSUserDefault and lookup with categoryId every time I need an image.



Any thing I should concern with this or there is a better way of doing this kind of thing?



Edited



I will let user choose theme and save it in NSUserDefaults (just like normal setting preference), then when I want to show it for Article I get categoryId from Category and use that categoryId to search in Theme entity, get the imagePath and load image from that path. Here is some NSPredicate I think of



NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Theme" inManagedObjectContext:moc];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDescription];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"categoryId == %@ AND themeId = %@", category_id_for_article, theme_id_from_user_defaults];
[request setPredicate:predicate];




Is it possible to force row level locking in SQL Server?

I can see how to turn off row level and page level locking in SQL Server, but I cannot find a way to force SQL Server to use row level locking. Is there a way to force SQL Server to use row level locking and NOT use page level locking?





How would you calculate the age in C# using date of birth (considering leap years)

Here is a problem. I have seen many solutions, but no one seems to be fulfilling the criteria I want...



I want to display the age in this format



20 y(s) 2 m(s) 20 d(s)
20 y(s) 2 m(s)
2 m(s) 20 d(s)
20 d(s)


etc...



I have tried several solutions, but the leap year is causing the problem with me. My unit tests are always being failed because of leap years and no matter how many days come in between, the leap yeas count for extra number of days.



Here is my code....



public static string AgeDiscription(DateTime dateOfBirth)
{
var today = DateTime.Now;
var days = GetNumberofDaysUptoNow(dateOfBirth);
var months = 0;
var years = 0;
if (days > 365)
{
years = today.Year - dateOfBirth.Year;
days = days % 365;
}
if (days > DateTime.DaysInMonth(today.Year, today.Month))
{
months = Math.Abs(today.Month - dateOfBirth.Month);
for (int i = 0; i < months; i++)
{
days -= DateTime.DaysInMonth(today.Year, today.AddMonths(0 - i).Month);
}
}

var ageDescription = new StringBuilder("");

if (years.ToString() != "0")
ageDescription = ageDescription.Append(years + " y(s) ");
if (months.ToString() != "0")
ageDescription = ageDescription.Append(months + " m(s) ");
if (days.ToString() != "0")
ageDescription = ageDescription.Append(days + " d(s) ");

return ageDescription.ToString();
}

public static int GetNumberofDaysUptoNow(DateTime dateOfBirth)
{
var today = DateTime.Now;
var timeSpan = today - dateOfBirth;
var nDays = timeSpan.Days;
return nDays;
}


Any ideas???





How to remove XML declation from the document while transforming the file

I am using DOM parser to parse my xml content.



After completing the parsing, I transformed the document to a new file. But it generates a new file that had added a new line for XML declaration.



<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<TFORMer major="1" minor="0">
<!-- (c) 1998-2008 TEC-IT Datenverarbeitung GmbH -->


In above line, the xml version declaration is automatically added by the transformer.



How do I configure the transformer to not to add that XML declaration line?





How to remove the systray icon of another application in VB.net

To restore an application from "minimize to system tray" mode to "Normal" mode (visible) from another application, I am using Showwindow method of "user32.dll". The API is working as expected i.e. displaying the application on Normal mode.
Moreover, I want to remove that application's System tray icon as soon as its mode changes from "minimize to system tray" to "Normal".



I had tried using Shell_NotifyIcon method of "shell32.dll" by passing NIM_DELETE & reference of NOTIFYICONDATA but no luck.
The API method declaration is as follows:



Shared Function Shell_NotifyIcon(ByVal dwMessage As UInteger, ByRef pnid As NOTIFYICONDATA) As Boolean


Can anyone suggest me a solution for solving this issue.





JAXB, annotations for setter/getter

        @XmlType  
@XmlAccessorType(XmlAccessType.FIELD) // here I need this access
public class User implements Serializable
{
//...
@XmlTransient
private Set<Values> values;

//..

@XmlElement
private Set<History> getXmlHistory()
{
return new CustomSet<Values, History>(Values);
}

private void setXmlHistory(final Set<History> aHistory)
{
this.values = new HashSet<Values>();
}
}


When I am create User object in Java code and after create XML, then all normally.

But when I try to get User-object from XML, then field values always null. So setter not working here. May be setter needs some annotation too?



XML looks like



<user>  
...
<xmlHistory>
// ... record 1
</xmlHistory>
<xmlHistory>
// ... record 2
</xmlHistory>
</user>




Cannot save tag_list when using multi-step forms

I have a belonging model that allows user to post objects to be sold or rented on my website. I recently changed the form, making it a multi-step form: a first form asks the name of the object and if the object is for sale or to rent, a second form ask for object's details, with the fields depending on the user's choice.



I am using is_taggable, with Rails 3.0.5, and my problem is that tag_list is never saved in the database since I switched to the multi-step form (all the other fields are saved correctly).



I followed Ryan Bates Rails cast #217.



Before, I was using: @belonging.tag_list = params[:belonging][:tag_list]



Since I went from multistep, I am using: @belonging.tag_list = session[:belonging_params][:tag_list]



I am a bit of a newbie in Rails, so there might be something obvious I am missing here. I spent the whole afternoon and evening trying to understand what is wrong, any help will therefore be appreciated!



Here are the 'new' and 'create' action of my controller:



class BelongingsController < ApplicationController
before_filter :authenticate_user!, :except => [:index, :with_tag, :remove_tag]
after_filter :update_tag_cloud, :only => [:create, :update]

def new
@title = "Insert a new product or service"
@user = current_user
session[:belonging_params] ||= {}
session[:belonging_step] = nil
@belonging = @user.belongings.new(session[:belonging_params])
session[:belonging_params][:tag_list] ||= []
@belonging.current_step = session[:belonging_step]
render 'new'
end

def create
session[:belonging_params].deep_merge!(params[:belonging]) if params[:belonging]
@belonging = current_user.belongings.build(session[:belonging_params])
@belonging.current_step = session[:belonging_step]
@belonging.tag_list=session[:belonging_params][:tag_list]
if params[:previous_button]
@belonging.previous_step
render 'new'
elsif params[:cancel_button]
session[:belonging_step] = session[:belonging_params] = nil
redirect_to user_path(current_user)
elsif params[:continue_button]
if @belonging.last_step?
if @belonging.save!
expire_fragment('category_list')
flash[:success] = "New product or service created!"
session[:belonging_step] = session[:belonging_params] = nil
redirect_to belonging_path(@belonging)
else
flash[:error] = "Object could not be saved"
render 'new'
end
else
@belonging.next_step
render 'new'
end
else
render 'new'
end
session[:belonging_step] = @belonging.current_step
end


Many many thanks for any clue !!





Nested document insert into MongoDB with C#

I am trying to insert nested documents in to a MongoDB using C#. I have a collection called categories. In that collection there must exist 2 array, one named categories and one named standards. Inside those arrays must exist new documents with their own ID's that also contain arrays of the same names listed above. Below is what I have so far but I am unsure how to proceed. If you look at the code what I want to do is add the "namingConventions" document nested under the categories array in the categories document however namingConventions must have a unique ID also.



At this point I am not sure I have done any of this the best way possible so I am open to any and all advice on this entire thing.



namespace ClassLibrary1
{
using MongoDB.Bson;
using MongoDB.Driver;
public class Class1
{
public void test()
{
string connectionString = "mongodb://localhost";
MongoServer server = MongoServer.Create(connectionString);
MongoDatabase standards = server.GetDatabase("Standards");
MongoCollection<BsonDocument> categories = standards.GetCollection<BsonDocument>("catagories");

BsonDocument[] batch = {
new BsonDocument { { "categories", new BsonArray {} },
{ "standards", new BsonArray { } } },
new BsonDocument { { "catagories", new BsonArray { } },
{ "standards", new BsonArray { } } },
};
categories.InsertBatch(batch);

((BsonArray)batch[0]["categories"]).Add(batch[1]);
categories.Save(batch[0]);
}
}
}


For clarity this is what I need:



What I am doing is building a coding standards site. The company wants all the standards stored in MongoDB in a tree. Everything must have a unique ID so that on top of being queried as a tree it can be queried by itself also. An example could be:



/* 0 */
{
"_id" : ObjectId("4fb39795b74861183c713807"),
"catagories" : [],
"standards" : []
}

/* 1 */
{
"_id" : ObjectId("4fb39795b74861183c713806"),
"categories" : [{
"_id" : ObjectId("4fb39795b74861183c713807"),
"catagories" : [],
"standards" : []
}],
"standards" : []
}


Now I have written code to make this happen but the issue seems to be that when I add object "0" to the categories array in object "1" it is not making a reference but instead copying it. This will not due because if changes are made they will be made to the original object "0" so they will not be pushed to the copy being made in the categories array, at least that is what is happening to me. I hope this clears up what I am looking for.





PHP: how to subtract e.g 9 days from filectime()

I want to delete all files older than 9 days. Since filectime returns the creation time of a



certain file, therefore, I just want to know how to subtract for an example: 9 days from the



filectime().





rails gem or plugins for reading and writing excel and csv files both

Hi i want to read and write data from CSV and excel file both.Can anyone please help me that



which gem or plugin is more suitable for this.





how to bottom align an image to a h1?

I am trying to bottom align an image to a h1 text, but I am not achieving the desired results.
I tried adding two divs and align them that did not work well, now I am trying to align a span but I am not getting the desired result as well.



<div id="formheader">
<div id="formlogo"> <img src="../../Pictures/EditIcon.gif" width="17" height="20" alt="login logo"> </div>
<div id="formtitle"> <span> <img src="../../Pictures/EditIcon.gif" width="17" height="20" alt="login logo">Editor</span> </div>
</div>


aligning issue



Any tips on how to align images with text? I had to change from h1 to span because it would not align as h1.





Autocomplete menu width goes out of screen when Jscrollpane is used

I'm trying to set the custom scrollbar to my jquery autocomplete and below is the HTML i'm using, When first time autocomplete menu opens the custom scroller is set and when i type some character in textbox the autocomplete menu width goes out of the screen, I'm unable to figure out the problem. Please suggest some possible solutions for this problem..



        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1; user-scalable=no">
<met

a http-equiv="Content-type" content="text/html; charset=utf-8">

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.css" />
<script type="text/javascript" src="scripts-css/jquery-1.7.2.js"></script>
<script type="text/javascript" src="scripts-css/jquery-ui.js"></script>
<script type="text/javascript" src="scripts-css/jquery.mobile.js"></script>


<link type="text/css" href="http://jscrollpane.kelvinluck.com/style/jquery.jscrollpane.css" rel="stylesheet" media="all" />
<script src="http://www.nathanbuskirk.com/jquery.jscrollpane.js" type="text/javascript"></script>
<script type="text/javascript" src="http://jscrollpane.kelvinluck.com/script/jquery.mousewheel.js"></script>
<script>

$(document).ready(function(){
var myArray = [ 'zero', 'one', 'two', 'three', 'four', 'five', 'one', 'two', 'three', 'four', 'five', 'one', 'two', 'three', 'four', 'five', 'one', 'two', 'three', 'four', 'five' ];
$('.scroll-pane').jScrollPane();

$('#prdiag').autocomplete({
source:myArray,
open:function(event, ui) {
$('.ui-autocomplete')
.addClass('scroll-pane')
.jScrollPane();
$('.jScrollPaneContainer').css({
'position': 'absolute',
'top': ($(this).offset().top + $(this).height() + 5) + 'px',
'left': $(this).offset().left + 'px'
});
},
focus: function (event, ui) {},
minLength:0
});

//$('.ui-autocomplete').jScrollPane();
});
</script>

<style type="text/css" id="page-css">
.scroll-pane
{
width: 102%;
height: 400px;
overflow: auto;

}
.horizontal-only
{
height: auto;
max-height: 200px;
}
.ui-autocomplete {
height: 200px;
overflow: auto;
-webkit-overflow-scrolling: touch;}
</style>
</head>
<body>

<div data-role="dialog" data-transition="pop" id="dialog-success" ><!-- dialog-->

<div data-role="header" data-theme="e" data-iconpos="right">
<h1>Help</h1>
</div><!-- /header -->

<div data-role="content" data-theme="e">
<input type="text" data-theme="d" id='prdiag' name="primaryDiagnosis" class='autoall' placeholder='Select Primary Diagnosis'/>
</div>
</div>

</body>
</html>


Thanks in advance...





Jpcap breaking the JVM

I have written the following program that is intended to dump all network device traffic to a file. I know the problem involves the use of JpcapWriter. Why am I getting the error message shown below?



import jpcap.*;
import jpcap.packet.*;

public class dumptraffic
{
private static final int maxPackets = 100;

public static void main(String args[])
{
try
{
NetworkInterface[] devices = JpcapCaptor.getDeviceList();

if (args.length != 1)
{
System.out.println("You must enter a device number.");

int i = 0;
for (NetworkInterface device : devices)
System.out.println((i++) + ": " + device.name);

return;
}

JpcapCaptor jpcap = JpcapCaptor.openDevice(devices[Integer.parseInt(args[0].trim())], 2000, false, 20);
JpcapWriter writer = JpcapWriter.openDumpFile(jpcap, "dump.pcap");

for (int i = 0; i < maxPackets; i++)
writer.writePacket(jpcap.getPacket());

writer.close();

System.out.println("Recorded packets to the file \"dump.pcap\"");
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}

}


Here is the log that Java dumps:



#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0234659d, pid=4900, tid=5808
#
# JRE version: 6.0_22-b04
# Java VM: Java HotSpot(TM) Client VM (17.1-b03 mixed mode, sharing windows-x86 )
# Problematic frame:
# v ~BufferBlob::jni_fast_GetLongField
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

--------------- T H R E A D ---------------

Current thread (0x02211c00): JavaThread "main" [_thread_in_native, id=5808, stack(0x002f0000,0x00340000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:
EAX=0x00000000, EBX=0x6da511e8, ECX=0x00000000, EDX=0x00000000
ESP=0x0033f578, EBP=0x0033f5b0, ESI=0x00000022, EDI=0x00000000
EIP=0x0234659d, EFLAGS=0x00010246

Top of Stack: (sp=0x0033f578)
0x0033f578: 02211d18 6d97567f 02211d18 00000000
0x0033f588: 00000022 00000000 02211d18 6da511e8
0x0033f598: 0033f58c 0033f19c 0033fd8c 6d9f4ed0
0x0033f5a8: 6da2a4b0 00000000 0033fc68 015d358c
0x0033f5b8: 02211d18 00000000 00000022 02211c00
0x0033f5c8: 380655e0 0033fc68 380655e0 0000005b
0x0033f5d8: 00000000 03000003 001521a8 77a94460
0x0033f5e8: 00000000 77a94460 00000000 001219b8

Instructions: (pc=0x0234659d)
0x0234658d: 00 00 00 8b c1 83 e0 01 8b 54 04 0c 8b 74 24 10
0x0234659d: 8b 12 c1 ee 02 8b 04 32 8b 54 32 04 be e0 16 a6


Stack: [0x002f0000,0x00340000], sp=0x0033f578, free space=13d0033f0ack
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
v ~BufferBlob::jni_fast_GetLongField
C [Jpcap.dll+0x358c]
j dumptraffic.main([Ljava/lang/String;)V+127
v ~StubRoutines::call_stub
V [jvm.dll+0xf3a9c]
V [jvm.dll+0x186591]
V [jvm.dll+0xf3b1d]
V [jvm.dll+0xfd365]
V [jvm.dll+0x104fbd]
C [java.exe+0x2155]
C [java.exe+0x85b4]
C [kernel32.dll+0x4d0e9]
C [ntdll.dll+0x419bb]
C [ntdll.dll+0x4198e]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j jpcap.JpcapWriter.writePacket(Ljpcap/packet/Packet;)V+0
j dumptraffic.main([Ljava/lang/String;)V+127
v ~StubRoutines::call_stub

--------------- P R O C E S S ---------------

Java Threads: ( => current thread )
0x02245800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=2888, stack(0x04550000,0x045a0000)]
0x0223e400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2620, stack(0x04500000,0x04550000)]
0x0223d400 JavaThread "Attach Listener" daemon [_thread_blocked, id=4060, stack(0x044b0000,0x04500000)]
0x0223a400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4280, stack(0x04460000,0x044b0000)]
0x02232000 JavaThread "Finalizer" daemon [_thread_blocked, id=5952, stack(0x04410000,0x04460000)]
0x02230c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=5860, stack(0x008c0000,0x00910000)]
=>0x02211c00 JavaThread "main" [_thread_in_native, id=5808, stack(0x002f0000,0x00340000)]

Other Threads:
0x0222f400 VMThread [stack: 0x003b0000,0x00400000] [id=4396]
0x0224f400 WatcherThread [stack: 0x045a0000,0x045f0000] [id=4156]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation total 4928K, used 371K [0x28050000, 0x285a0000, 0x2d5a0000)
eden space 4416K, 8% used [0x28050000, 0x280acf00, 0x284a0000)
from space 512K, 0% used [0x284a0000, 0x284a0000, 0x28520000)
to space 512K, 0% used [0x28520000, 0x28520000, 0x285a0000)
tenured generation total 10944K, used 0K [0x2d5a0000, 0x2e050000, 0x38050000)
the space 10944K, 0% used [0x2d5a0000, 0x2d5a0000, 0x2d5a0200, 0x2e050000)
compacting perm gen total 12288K, used 86K [0x38050000, 0x38c50000, 0x3c050000)
the space 12288K, 0% used [0x38050000, 0x38065868, 0x38065a00, 0x38c50000)
ro space 10240K, 51% used [0x3c050000, 0x3c57baf8, 0x3c57bc00, 0x3ca50000)
rw space 12288K, 54% used [0x3ca50000, 0x3d0e76d8, 0x3d0e7800, 0x3d650000)

Dynamic libraries:
0x00400000 - 0x00424000 C:\Windows\system32\java.exe
0x779d0000 - 0x77af7000 C:\Windows\system32\ntdll.dll
0x77700000 - 0x777dc000 C:\Windows\system32\kernel32.dll
0x761c0000 - 0x76286000 C:\Windows\system32\ADVAPI32.dll
0x76460000 - 0x76523000 C:\Windows\system32\RPCRT4.dll
0x10000000 - 0x10048000 C:\Windows\system32\guard32.dll
0x76950000 - 0x769ed000 C:\Windows\system32\USER32.dll
0x77be0000 - 0x77c2b000 C:\Windows\system32\GDI32.dll
0x75f00000 - 0x75f08000 C:\Windows\system32\VERSION.dll
0x77500000 - 0x775aa000 C:\Windows\system32\msvcrt.dll
0x77b60000 - 0x77b7e000 C:\Windows\system32\IMM32.DLL
0x76880000 - 0x76948000 C:\Windows\system32\MSCTF.dll
0x77b10000 - 0x77b19000 C:\Windows\system32\LPK.DLL
0x76290000 - 0x7630d000 C:\Windows\system32\USP10.dll
0x75ef0000 - 0x75ef7000 C:\Windows\system32\fltlib.dll
0x7c340000 - 0x7c396000 C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d7f0000 - 0x6da97000 C:\Program Files\Java\jre6\bin\client\jvm.dll
0x74900000 - 0x74932000 C:\Windows\system32\WINMM.dll
0x775b0000 - 0x776f5000 C:\Windows\system32\ole32.dll
0x763d0000 - 0x7645d000 C:\Windows\system32\OLEAUT32.dll
0x748c0000 - 0x748fd000 C:\Windows\system32\OLEACC.dll
0x75ec0000 - 0x75eec000 C:\Windows\system32\apphelp.dll
0x6d7a0000 - 0x6d7ac000 C:\Program Files\Java\jre6\bin\verify.dll
0x6d320000 - 0x6d33f000 C:\Program Files\Java\jre6\bin\java.dll
0x6d280000 - 0x6d288000 C:\Program Files\Java\jre6\bin\hpi.dll
0x76070000 - 0x76077000 C:\Windows\system32\PSAPI.DLL
0x6d7e0000 - 0x6d7ef000 C:\Program Files\Java\jre6\bin\zip.dll
0x015d0000 - 0x015f8000 C:\Windows\System32\Jpcap.dll
0x763a0000 - 0x763cd000 C:\Windows\system32\WS2_32.dll
0x77b20000 - 0x77b26000 C:\Windows\system32\NSI.dll
0x045f0000 - 0x0463c000 C:\Windows\system32\wpcap.dll
0x00920000 - 0x00938000 C:\Windows\system32\packet.dll
0x75980000 - 0x75999000 C:\Windows\system32\iphlpapi.dll
0x75940000 - 0x75975000 C:\Windows\system32\dhcpcsvc.DLL
0x75e70000 - 0x75e9c000 C:\Windows\system32\DNSAPI.dll
0x75f10000 - 0x75f24000 C:\Windows\system32\Secur32.dll
0x75930000 - 0x75937000 C:\Windows\system32\WINNSI.DLL
0x75900000 - 0x75922000 C:\Windows\system32\dhcpcsvc6.DLL
0x6d600000 - 0x6d613000 C:\Program Files\Java\jre6\bin\net.dll
0x756f0000 - 0x7572b000 C:\Windows\system32\mswsock.dll
0x756e0000 - 0x756e5000 C:\Windows\System32\wship6.dll

VM Arguments:
java_command: dumptraffic 1
Launcher Type: SUN_STANDARD

Environment Variables:
CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip
PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Ruby192\bin;C:\Program Files\Java\jdk1.6.0_20\bin
USERNAME=Donald Taylor
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 13, GenuineIntel



--------------- S Y S T E M ---------------

OS: Windows Vista Build 6002 Service Pack 2

CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 13, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3

Memory: 4k page, physical 2094396k(1168912k free), swap 4458364k(3080400k free)

vm_info: Java HotSpot(TM) Client VM (17.1-b03) for windows-x86 JRE (1.6.0_22-b04), built on Sep 15 2010 00:56:36 by "java_re" with MS VC++ 7.1 (VS2003)

time: Mon Nov 08 19:50:43 2010
elapsed time: 0 seconds




a color change in transparency

I have an image generated in the javascript HTML5 canvas.
I would now like to say that all the px of a certain color (red for example) have all become transparent





window.open is not working in IE8

I am using IE8, to open a window i am using this code,



window.open(url,"STO");


Its working in other browsers except IE8.



please tell me what is the problem with IE8? I tried turningoff popupblocker also.





Setting PDO/MySQL LIMIT with Named Placeholders

I'm having an issue binding the LIMIT part of an SQL query. This is because the query is being passed as a string. I've seen another Q here that deals with binding parameters, nothing that deals with Named Placeholders in an array.



Here's my code:



public function getLatestWork($numberOfSlides, $type = 0) {

$params = array();
$params["numberOfSlides"] = (int) trim($numberOfSlides);
$params["type"] = $type;

$STH = $this->_db->prepare("SELECT slideID
FROM slides
WHERE visible = 'true'
AND type = :type
ORDER BY order
LIMIT :numberOfSlides;");

$STH->execute($params);

$result = $STH->fetchAll(PDO::FETCH_COLUMN);

return $result;
}


The error I'm getting is: Syntax error or access violation near ''20'' (20 is the value of $numberOfSlides).



How can I fix this?





How to extract text from image using openCV or OCR tesseract?

i'm currently doing a project on text recognition based on a image capture in android phone. I want to ask how the text can be extracted from image?



Does have any openCV or OCR tesseract tutorial for extracting ?





How download an image from browser in a single click using JQuery?

I have a piece of code like below:



<div><a href="/images/test-201.gif" class="download">Download</a> </div>


I need to do is when I click on the Download. It should open a new window like save as for this image. I need to do this using htnl or javascript.





bash parse filename

Is there any way in bash to parse this filename :



$file = dos1-20120514104538.csv.3310686



into variables like $date = 2012-05-14 10:45:38 and $id = 3310686 ?



Thank you





SwiftMailer does not send mail, why?

SwiftMail does not send my email, while mail() does work. Same as here.



I added the EchoLogger but it does not print anything.



$message = Swift_Message::newInstance();
$message->setSubject('Test');
$message->setTo( $email );
$message->setFrom(ABSENDER);
$message->setBody($nl_text);

$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);

$logger = new Swift_Plugins_Loggers_EchoLogger();
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));

$result = $mailer->send($message, $failures);
var_dump($failures);


The email is returned in $failures but why?





How to export an mschart chart to excel?

I have created a chart with Mschart.I want to export the created chart to excel.
I'm using following code but when I open it in excel I just see some unknown code instead of chart.



using (var chartimage = new MemoryStream())
{
ChartAmalkerd.SaveImage(chartimage, ChartImageFormat.Png);
ExportToExcel(chartimage.GetBuffer());
}
private void ExportToExcel(byte[] input)
{
string attachment = "attachment; filename=Employee.xls";
Response.ClearContent();
Response.ContentEncoding = Encoding.GetEncoding(1256);
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
Response.Buffer = true;
this.EnableViewState = false;
Response.BinaryWrite(input);
Response.Flush();
Response.Close();
Response.End();

}




How to integrate Selenium 2.21.0(previously Selenium RC) libraries with Eclipse?

I want to add Selenum 2.21 libraries to Eclipse java project. I tried two methods.



One through Command line:



I have downloaded the Selenium 2.2(previously selenium RC) from their website for Java and unzipped them. When I write, java -jar (selenium-filename).jar, I am getting 'No main manifest attribute' error.



I know, the line mainclass has to be added in manifest file. There is no folder for the manifest in v2.21.



I also had Seleniumv1.03, which had the Manifest option. I added the line and a new line character, as mentioned in another post in someplace, but still I faced the issue.



two through copy/paste of jar files under JRE system library of the project:



This action is also not allowed. Cannot paste under JRE system library corresponding to the project.



Can you please tell a step by step procedure, other than refering somewhere in Sun tutorial, where they have given about java cfe (jar name) (class name) (class name.class), for defining the entry point... I had tried that too, at present...



For other reference, Java6 Update 32, I have downloaded for SDK and JRE. Firefox 12 and ie9, I am using. Eclipse Indigo IDE for Java Developers is been used.





sorting according to a custom comparator

I've got a map looking like this:



user> (frequencies "aaabccddddee")
{\a 3, \b 1, \c 2, \d 4, \e 2}


And I'd like to have a function that would sort the key/value pairs according to the order each character is appearing in a string I'd pass as an argument.



Something like this:



user> (somesort "defgcab" (frequencies "aaabccddddee"))
[[\d 4] [\e 2] [\c 2] [\a 3] [\b 1]]


(in the example above 'f' and 'g' do not appear in the map and they're hence ignored. It is guaranteed that the string -- "defgcab" in this example -- shall contain every character/key in the map)



The resulting collection doesn't matter much as long as it is sorted.



I've tried several things but cannot find a way to make this work.





update in mysql need good statement

I am new in sql. I am having writting query based on data



How can I write query to update row; I want to follow this format;



UPDATE `reports_attributes` 
(`ConID`,`CheckServices`,`Attribute1`,`Attribute2`,`Attribute3`,`Attribute4`,`Attribute5`,`Attribute6`,`Attribute7`,`Attribute8`)
VALUES ('78','Execute Summary','criminality','color1','education','color5','employment_check_2','color7','report_status','color9')
WHERE ConID=78 AND ReportType='interim_report'