Saturday, July 31, 2010

How do I fix JavaHL (JNI) Not available after I have changed the logon password on my Mac?

Programmer Question

I have installed Eclipse 3.5.2 and the plugin Subversion JavaHL Native Library Adapter 1.6.9.2 and this worked without any problems. However, this morning I was forced to change the password to logon to my Mac and since then I get the message that "Subversion native library not available" when I try to save any changes. Can anyone help? I have tried to add this line (-Djava.library.path=/usr/lib/jni) to the eclipse.ini file but this didn´t seem to make any difference.



Can anyone help?



Find the answer here

Is stdlib's qsort recursive?

Programmer Question

I've read that qsort is just a generic sort, with no promises about implementation. I don't know about how libraries vary from platform to plaform, but assuming the Mac OS X and Linux implementations are broadly similar, are the qsort implementations recursive and/or require a lot of stack?



I have a large array (hundreds of thousands of elements) and I want to sort it without blowing my stack to oblivion. Alternatively, any suggestions for an equivalent for large arrays?



Find the answer here

Saturday, July 24, 2010

How to make a Tag cloud app that post on a website?

Programmer Question

I want to make an app where the users can post messages that will be displayed on a website. The users would need to create a username and password to be able to post.



The app would be like a twitter, but only be able to post through the app and read the last few posts and not be able to write private messages.



The website would function like a huge cloud of thoughts where everyone could go and read what others have written. Once the post hit the cloud, they can't be deleted. Only me could delete posts.



All posts would have different color and font size, it would look like a huge tag cloud on the website.



How do I make an app and a website like this?



David H



Find the answer here

How does it hurt to use Linux (Ubuntu) as a guest OS for all my tasks?

Programmer Question

I have a machine running Windows, where the disk has two partitions C (50 GB) and D (250GB).
I do research in Information Retrieval and need to work with a large corpus (more than 50 GB) and in Linux.



So if I want to install Linux on the existing system, keeping the Windows installation intact, will it be fine to run it in a virtual box? (say, QEMU, VMWare, etc.)



An alternative is using Wubi. In that case the Linux installation has to be on drive C. Then, if I keep a small Linux installation (say 5GB) on C, and my corpus on D (mounted in Linux), how will it affect the performance of my programs which would be accessing the mounted Windows drive D.



Is it feasible to use Linux this way? Which of the above is better if at all they are a way out?



Find the answer here

Archive manipulating using qt framework

Programmer Question

Is it possible to handle different type of archive (zip,rar,7z,tar,) using qt framework ?



Find the answer here

Any benefits of learning 3d software rasterization & theory before jumping into OpenGL/Direct3D?

Programmer Question

I came across a very interesting book. I have done some 2d games but 3D is a whole new ballpark for me. I just need to know if there any benefits of learning 3d software rasterization & theory before jumping into OpenGL/Direct3D? Any reason why to either approach? Thanks in advanced!



Find the answer here

Ruby on Rails 3 Release date

Programmer Question

Hi,



Is there a release date for Ruby on Rails 3? I've been searching but nothing yet.



Find the answer here

Wednesday, July 21, 2010

Autonomy | IDOL search API

Programmer Question

Can someone point me to a tutorial or API resource for Autonomy IDOL search?
Thanks.



Find the answer here

did any of the more experienced and skilled programmers really struggle with the very basics of programming?

Programmer Question

I ask on behalf of those that have a very hard time grasping the basics, and I mean the very basics. From simple loops to basic arrays and what have you. Is there really a light at the end of the tunnel. Language independent.



Yes, practice and experience pays off without a doubt but from my experience those that blossom in something usually found the given field comfortable to begin with.



I attempt exercises and if I cannot do it I then take a peek at the solution only to get angry that I couldn't think of that. Sure it's part of the learning progress but I feel it's the sort of thing I should find easy.



So, is there anyone out there who really couldn't do the extremely simple tasks for a good while but ventured on and with time became very proficient and good?



Or, are those that are good and experienced at what they do found the starting steps simple then started slowing down when it came to the more complex tasks? Is there a point where someone should say - "right perhaps this as a working field is not for me?". As can certainly be the case for some even if you do enjoy the work.



is it as simple as this?



Find the answer here

Thursday, July 15, 2010

NSDate / NSDateComponent problem

Programmer Question

Hello,



Let's say we are the 15/07/2010, I would like to get the first day of the previous week, which is the 5 of July. I have the following method but it does not work. Seems that I have a problem with the weekday attribute...



+ (NSDate *)getFirstDayOfPreviousWeek
{
// Get current date
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *now = [NSDate date];

// Get today date at midnight
NSDateComponents *components = [cal components:( NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit | NSTimeZoneCalendarUnit) fromDate:now];
[components setHour:0];
[components setMinute:0];
[components setSecond:0];
NSInteger *dayNbr = [components weekday];
NSLog(@"week day:%@",dayNbr); // CRASH
NSDate *todayMidnight = [cal dateFromComponents:components];

// Get first day of previous week midnight
components = [[[NSDateComponents alloc] init] autorelease];
NSInteger *wd = [dayNbr intValue] * -1 + 1;
[components setWeekDay:wd];
[components setWeek:-1];
NSDate *newDate = [cal dateByAddingComponents:components toDate:todayMidnight options:0];
[cal release];

NSLog(@"new date:%@", newDate);

return newDate;
}


Could you please help ?



Thanks a lot,



Luc



Find the answer here

Why isn't regular expressions part of ISO C99

Programmer Question

Everyone knows how awesome C language is and how much it sucks in text processing tasks. Given that. Regex definitely must be part of ISO C. But it isn't. I don't understand why? Are there people who think its not essential?



Find the answer here

Numpy interconversion between multidimensional and linear indexing

Programmer Question

I'm looking for a fast way to interconvert between linear and multidimensional indexing in Numpy.



To make my usage concrete, I have a large collection of N particles, each assigned 5 float values (dimensions) giving an Nx5 array. I then bin each dimension using numpy.digitize with an appropriate choice of bin boundaries to assign each particle a bin in the 5 dimensional space.



N = 10
ndims = 5
p = numpy.random.normal(size=(N,ndims))
for idim in xrange(ndims):
bbnds[idim] = numpy.array([-float('inf')]+[-2.,-1.,0.,1.,2.]+[float('inf')])

binassign = ndims*[None]
for idim in xrange(ndims):
binassign[idim] = numpy.digitize(p[:,idim],bbnds[idim]) - 1


binassign then contains rows that correspond to the multidimensional index. If I then want to convert the multidimensional index to a linear index, I think I would want to do something like:



linind = numpy.arange(6**5).reshape(6,6,6,6,6)


This would give a look-up for each multidimensional index to map it to a linear index. You could then go back using:



mindx = numpy.unravel_index(x,linind.shape)


Where I'm having difficulties is figuring out how to take binassign (the Nx5 array) containing the multidimensional index in each row, and coverting that to an 1d linear index, by using it to slice the linear indexing array linind.



If anyone has a one (or several) line indexing trick to go back and forth between the multidimensional index and the linear index in a way that vectorizes the operation for all N particles, I would appreciate your insight.



Find the answer here

Create SSL certificate for use in my application.

Programmer Question

Hi,



Made a simple server using TcpListen and would like to add SSL to the applicayion for security.



I need help in the actual steps needed to create a self signed certificate, and what problems if any would there be if I shared the application.



Would the user have to make their own certificate or if using the same one would cause a security issue im guessing, as the certificate would readable if I shared the application or can you hide it in the application itself.



Any question answered is a step closer :)



Thanks



UPDATED



Im having a little trouble with makecert. Which type do i want ...



makecert -r -pe -n "CN=Your Name" -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.3 -ss My
or
makecert -r -n "CN=Your Name" -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.3 -sv selfcert.pvk selfcert.cer
cert2spc selfcert.cer selfcert.spc
pvkimprt -pfx selfcert.spc selfcert.pvk



And what values need to be edited??



Thanks



Find the answer here

System.Net.Mail send message without recipient

Programmer Question

I am using System.Net.Mail.MailMessage to create and send an email message. For various reasons I do not want to use the .To.Add() or the .CC.Add() or the .Bcc.Add() methods to add recipients to the email. I want to add them via the .Headers.Add() method. (This gives greater control over the recipients).



However, when I come to send the message I get an exception stating "A recipient must be specified". It obviously does not realise that I have added recipients via the Headers.



Can anyone think of a workaround for this? Could I somehow override the method that is validating the message and throwing the exception?



Thanks very much.



Find the answer here

Wednesday, July 14, 2010

Render Radio Button Django

Programmer Question

I Have this Form



class MyModelForm(forms.ModelForm):
boolfield = forms.TypedChoiceField(coerce=bool,
choices=((False, 'No'), (True, 'Yes')),
widget=forms.RadioSelect
)

class Meta:
model = MyModel


How can I show the buttons without LI an UL tags ? (I want to show them together horizontally), and how to set False selected by default? ()



Find the answer here

Monday, July 12, 2010

Targeting every object in an array syntax

Programmer Question

Newb question of the day:



I'm trying to select all the users with this condition, and then perform an action with each one :



User.find(:all).select { |u| u.organizations.count > 0} do |user|


Except, this isn't the right way to do this. Not entirely sure what the proper syntax is.



Any fellow rubyist offer a newb a hand?



Find the answer here

I am trying to figure out a way to streamline importing data from an access database into a .Net application

Programmer Question

I'm writing a fairly light-weight .Net application that queries an Access database and generates a Crystal Report based on the result-set.



The Dataset fill method is a little slow, but manageable.



The issue is when I load the crystal report. If the dataset being passed to Crystal is sizeable, at all, it takes forever to load, and the user gives up.



This is the code that sets the report dataset:



report.SetDataSource(largeDataSet);


largeDataSet has two tables. I have paired them down to the absolutely essential columns.



What ends up happening is the



reportViewer.Show();


command fires, but the ReportViewer takes minutes to actually display the report.



I am at a loss.



I appreciate your help and feedback.



Find the answer here

Wednesday, July 7, 2010

MySql - Aggregate function for choosing first choice, second choice, third choice, etc?

Programmer Question

Imagine I have the following data in a table called "messages":



message_id | language_id | message
------------------------------------
1 en Hello
1 de Hallo
1 es Hola
2 en Goodbye
2 es Adios


(Note that I don't have a German translation for "Goodbye.")



I want to select the messages for a user who speaks English and German, but prefers German.



Meaning, I want a result set that looks like:



message_id | language_id | message
------------------------------------
1 de Hallo
2 en Goodbye


But, um, it's proving tricky. Any ideas?



Find the answer here

C threading in linux?

Programmer Question

Does someone have a simple example of threading in c?



I want to build a small console app that will read a txt file file line by line and then use threads to process the entire txt. How should I do this? splitting the txt into X where X=N of threads, is the first thing that comes to my mind, is there a better way?



Find the answer here

Confirming action before processing!

Programmer Question

Am doing a contact management site in codeigniter, i have a function which delete the contact based on id.



For example the page will have all contacts listed. And each contact will have a link saying delete near it. The link will be to the function passing the id, like:



www.site.com/index.php/action/delete/23


So i want a confirmation box to ask user, yes or no for each link. So if user press yes it will be deleted and otherwise nothing happens. Hope I'm clear.



Find the answer here

DRY programming with jquery

Programmer Question

Posting as a jquery newbie. I am sure there must be a way to condense the code below in a DRY fashion. Essentially this is just a show/hide that is applied to multiple elements on a page, all using the same template and naming conventions:



$("#homelink1").hover(
function() { $("#poptext1").show(); },
function() { $("#poptext1").hide(); }
);

$("#homelink2").hover(
function() { $("#poptext2").show(); },
function() { $("#poptext2").hide(); }
);
...


I'm stuck on how to convert this to a function with passed parameters, so that I could just pass the integer (1 or 2) and have the function evaluate the rest, e.g.



$("#homelink" + param).hover



Find the answer here

Tuesday, July 6, 2010

jQuery Getting Element Class as Specified in CSS

Programmer Question

I know that Attr gets the exact class of an element. Is there a way to get the element exact class as defined in CSS?
For example an element may have class "title" but be defined in CSS as a descendant selector, something like: .other-list .title {}
I need something to get that exact class value. You can see here the full example:
http://jsfiddle.net/2TMgQ/2/



On click both elements have class "title" but are defined in CSS as 2 different elements.
Thank you



Find the answer here

C++ constant temporary lifetime

Programmer Question

hello.



Can you please tell me if such code is correct (according to standard):



struct array {
int data[4];
operator const int*() const { return data; }
};

void function(const int*) { ... }

function(array()); // is array data valid inside function?


Thank you



Find the answer here

How do I get a list of items in the Wordpress media library on a plugin options page?

Programmer Question

Hi!
I'm writing a Wordpress plugin which injects a grid of images just above the footer on all frontend pages. The application is to display sponsor's logos. I'd like to harness the WP Media Library since the logos are already uploaded for use on the 'sponsorship' page and in posts.



Essentially I'm stuck at accessing the media library interface on the plugin's options page. All of the legwork is done in terms of creating the options page, using the action hook to place content on frontend pages from the plugin, etc. What I need now is to be able to display all the files in the media library in a list on the options page, and provide a checkbox or something to allow the user to select certain files for insertion above the footer.



The Media Library API seems to be aimed at people writing themes or media plugins. Help understanding what to make use of would be great!



Find the answer here

Monday, July 5, 2010

remove Stopwords in java

Programmer Question

Hi



I have a list of stop words which contain around 30 words and a set of articles .



I want to parse each article and remove those stop words from it .



I am not sure what is the most effecient way to do it.



for instance I can loop through stop list and replace the word in article if exist with whitespace but it does not seem good .



Thanks



Find the answer here

How to remove hex characters from DB?

Programmer Question

Hi, i have a MySQL DB where the rows have characters like %20, %2C, etc...
how can i remove them from the DB without editing the file on notepad?
The .sql file is about 300mb in size...
thanks



Find the answer here

JDOM, XPath and Namespace Interactions

Programmer Question

Hi all,



I'm having a very frustrating time extracting some elements from a JDOM document using an XPath expression. Here's a sample XML document - I'd like to remove the ItemCost elements from the document altogether, but I'm having trouble getting an XPath expression to evaluate to anything at the moment.



  

Demo Operator Pricebook


Demo Wifi
DemoWifi
15
10


1Mb DIA
Demo1MbDIA
20
15






I would normally just use an expression such as //srv:ItemCost to identify these elements, which works fine on other documents, however here it continually returns 0 nodes in the List. Here's the code I've been using:



Namespace ns = Namespace.getNamespace("srv","http://ess.com/ws/srv");   
XPath filterXpression = XPath.newInstance("//ItemCost");
filterXpression.addNamespace(ns);
List nodes = filterXpression.selectNodes(response);


Where response is a JDOM element containing the above XML snippet (verified with an XMLOutputter). nodes continually has size()==0 whenever parsing this document. Using the XPath parser in Eclipse on the same document, this expression does not work either. After some digging, I got the Eclipse evaluator to work with the following expression: //*[local-name() = 'ItemCost'], however replacing the //srv:ItemCost in the Java code with this still produced no results. Another thing I noticed is if I remove the namespace declaration from the XML, //srv:ItemCost will resolve correctly in the Eclipse parser, but I can't remove it from the XML. I've been scratching my head for ours hours on this one now, and would really appreciate some nudging in the right direction.



Many thanks



Edit : Fixed code -



Document build = new Document(response);
XPath filterXpression = XPath.newInstance("//srv:ItemCost");
List nodes = filterXpression.selectNodes(build);


Find the answer here

Is rtmp the only way to protect images

Programmer Question

I have images that I need to manage access to. I've come across osmf and rtmp streaming which are flash/adobe technologies and would require me to install a special server. Anyone knows of other ways to get the same effect with php.



Find the answer here

How to use 2 different item renderers in mx:Tree

Programmer Question

Question for Flex guys.
How can I use multiple item renderers in mx:Tree depending on item's depth/level in tree?
For example. For the first level items I want to use label with button and for second level items combobox.



Is this somehow possible?



Find the answer here

Thursday, July 1, 2010

Ruby on Rails - access user defined lib functions in /lib/login_system.rb from app/views/layouts/_menu.rhtml

Programmer Question

I have defined a function called "is_logged_in?" in a user defined library stored in the /lib directory, however when I try to use it in one of my views (in this case a _menu.html.erb view) I get a "undefined method `is_logged_in?' for #" error. I had assumed that if the method was available within the /lib directory then it would be accessible through the application?



my login_system.rb file is as follows: -
module LoginSystem
protected



def is_logged_in?
@logged_in_user = User.find(session[:user]) if session[:user]
end



def logged_in_user
return @logged_in_user if is_logged_in?
end



def logged_in_user=(user)
if !user.nil?
session[:user] = user.id
@logged_in_user = user
end
end



def self.included(base)
base.send :helper_method, :is_logged_in, :logged_in_user
end
end



and my _menu.html.erb file is as follows: -










  • Logged in as:

  • 'account', :action => 'logout'}, :method => :post%>


  • 'users', :action => 'new' %>

  • 'account', :action => 'login' %>




Can anyone point where I've gone wrong?



Bernard



Find the answer here

how to move to location in graphics mode

Programmer Question

What code do we use to move at a point on the screen in graphics mode?As in normal we use goto(x,y).



Find the answer here

How do I prevent site scraping?

Programmer Question

I have a fairly large music website with a large artist database. I've been noticing other music sites scraping our site's data (I enter dummy Artist names here and there and then do google searches for them).



How can I prevent screen scraping? Is it even possible?



Find the answer here

LinkWithin

Related Posts with Thumbnails