Hi, I am a C++ / Java programmer and the main paradigm I happen to use in everyday programming is OOP. In some thread I read a comment that Type classes are more intuitive in nature than OOP. Can someone explain the concept of type classes in simple words so that an OOP guy like me can understand it?
What will be proper regular expression for git repositories?
example link:
[email protected]:someone/someproject.git
so it will be like
server can be url or ip
Project can contain some other characters than alphanumeric like '-'
I'm not sure what is the role of '/'
any suggestions?
Reading some answers with code samples I notice that those where this method mentioned are subjected to criticism. I'm using this method in my code. So I'd like to know if someone give me detailed response whuy this method is not recomemnded and what alternative approaches are?
I have some code that sets the lang var to the site default language.
$lg = &JFactory::getLanguage();
$lg = explode('-',$lg->_default);
$dlg = $lg[0];
if(!JRequest::getWord('lang', false ))
JRequest::setVar('lang', $dlg );
however before setting it to $dlg I would like to find out if the language is stored in the user information or session.
Can someone tell me how to check the session for language information?
For example, if I'm doing some form input validation and I'm using the following code for the name field.
preg_match("/^[a-zA-Z .-]$/", $firstname);
If someone types in Mr. (Awkward) Double-Barrelled I want to be able to display a message saying Invalid character(s): (, )
I have grown tired of all the little issues with paste template, it's horrible to maintain the templates, it has no way of updating an old project and it's very hard to test.
I'm wondering if someone knows of an alternative for quickstart generators as they have proven to be useful.
Hi, I own a avermedia volar HX usb stick, I want to capture fromthe composite input , but I can't because I'm unable to select the input. I'm using gstreamer with + python, I think I need to use gsttuner select input but I have no experience using gstreamer's interfaces. Could someone post a simple example?
Thanks!
Hi,
can someone tell me how to decrypt the messages I get at the socket from org.apache.log4j.net.SocketAppender?
I tried the Chainsaw-sources but I didn't find anything there :/
Or where does the message in log4j get encrypted?
Thanks
Hello,
I have a JSON variable defined as:
var myCollection = {
"data": [
{ "name":"Joe", "id":"1" },
{ "name":"Bill", "id":"2" },
{ "name":"Dave", "id":"3" }
]
};
I have a JavaScript function that is responsible for adding items to the data element in myCollection. However, I'm not sure how to add a name/id pair to the collection via JavaScript. Can someone show me how to add to a JSON collection via JavaScript?
Thank you!
Hi I was wondering if someone could help me with this problem.
Thanks!!
Show how to use a stack S and a queue Q to generate all possible subsets of a set nonrecursively.
I posted a question awhile ago asking how I could limit the rate at which a form could be submitted from a rails application. I was helped by a very patient user and their solution works great. The code was for my comments controller, and now I find myself wanting to add this functionality to another controller, my Messages controller. I immediately tried reusing the working code from the comments controller but I couldn't get it to work. Instead of asking for the working code, could someone please help me understand my working comment controller code?
class CommentsController < ApplicationController
#...
before_filter :post_check
def record_post_time
cookies[:last_post_at] = Time.now.to_i
end
def last_post_time
Time.at((cookies[:last_post_at].to_i rescue 0))
end
MIN_POST_TIME = 2.minutes
def post_check
return true if (Time.now - last_post_time) > MIN_POST_TIME
flash[:warning] = "You are trying to reply too fast."
@message = Message.find(params[:message_id])
redirect_to(@message)
return false
end
#...
def create
@message = Message.find(params[:message_id])
@comment = @message.comments.build(params[:comment])
if @comment.save
record_post_time
flash[:notice] = "Replied to \"#{@message.title}\""
redirect_to(@message)
else
render :action => "new"
end
end
def update
@message = Message.find(params[:message_id])
@comment = Comment.find(params[:id])
if @comment.update_attributes(params[:comment])
record_post_time
redirect_to post_comment_url(@message, @comment)
else
render :action => "edit"
end
end
#...
end
My Messages controller is pretty much a standard rails generated controller with a few before filters and associated private methods for DRYing up the code and a redirect for non existent pages.
I'll explain how much of the code I understand. When a comment is created, a cookie is created with a last_post_time value. If they try to post another comment, the cookie is checked if the last one was made in the last two minutes. If it was a flash warning is displayed and no comment is recorded. What I don't really understand is how the post_check method works and how I can adapt it for my simpler posts controller. I thought I could reuse all the code in the message controller with the exception of the line:
@message = Message.find(params[:message_id])
# (don't need the redirect code)
in the post_check method. But it trips up on the "record_post_time" in the create action/method. I really want to understand this. Can someone explain why this doesn't work? I greatly appreciate you reading my lengthy question.
I need to implement a priority queue where the priority of an item in the queue can change and the queue adjusts itself so that items are always removed in the correct order. I have some ideas of how I could implement this but I'm sure this is quite a common data structure so I'm hoping I can use an implementation by someone smarter than me as a base.
Can anyone tell me the name of this type of priority queue so I know what to search for or, even better, point me to an implementation?
Hi,
Can someone explain to me the usage of Integer, Boolean etc in place of their primitive types in JAVA?
I can't seem to grasp the advantages their are providing. They seem to create unnecessary problems of handling null values.
Thanks!
Does going to a less famous University that might not be terribly selective necessarily preclude someone from being considered from the elite software companies, i.e. Google or Microsoft regardless of my actual abilities? Furthermore how often do you find your alumni places a factor when looking for a job?
Thanks again for the responses.
I'm wondering if the following method will completely prevent CSRF, and be compatible with all users.
Here it is:
In the form just include an extra parameter that is: encrypted(user's userID + request time). Server-side just decrypt and make sure it's the right userID and the request time was reasonably recent.
Aside from someone sniffing the user's traffic, is this completely secure? Are there any downsides?
The question is pretty straight forward, I have tried using a span with rules set to clear:both; and display:block;, at the bottom of each list entry where the text is being inserted in with no luck. I am not really sure what to do on this. I don't expect to many entries with long consecutive letter strings but for example if someone does lolololololol or ahaahahahhhhhhhhhhhhaaaaaaaa for like 100 letters, it will overflow. If anyone can give me a pointer I would really appreciate it.
SO i think its plausible to send and receive an Instant Message via sever codes.
Just clearly wondering if there is an API or anything to function the possibility to send an IM to someone using MSN Live and others.
Can someone direct me to an example or explanation that will help me either:
Extend the SilverLight AutoComplete Box to allow watermarks.
Extend the Watermark TextBox to allow AutoComplete functionality.
It strikes me that option 1 would be easiest, but I'm open.
Thanks in advance.
The benefits of version control are obvious to someone who's producing text. How can I convince other disciplines, such as graphics or documentation writers? Or do i just version my stuff?
We are using Crystal Report 12 in one of our projects. Currently I need to create report template which should show different icons based on the some field value.
That field contains a number, storing some kind of status and I have several icons corresponding some statuses.
At the moment I can't figure out how to implement such a thing in Crystal Reports designer.
Could someone please help me?
I did a git on the com.android.music app and then created a project in eclipse from existing code. I chose 2.1 as the sdk target but I am getting errors trying to compile.
Is the music app referencing code that is not part of the 2.1 sdk? Can someone list the steps for how to compile in eclipse?
Description Resource Path Location Type
ArrayListCursor cannot be resolved to a type PlaylistBrowserActivity.java Music/src/com/android/music line 529 Java Problem
MediaFile cannot be resolved AlbumBrowserActivity.java
I am working on an App that intends to give an accurate measure of any object (building, desk, chair, people, etc.) Using the camera (either phone's or laptop) but I'm unsure as to how to do this without using a lot of resources, would someone mind giving me some options? I'm looking for a lightweight one that can be quickly processed by the computer/phone to give back the measures.