Thursday, 12 September 2013

Permalink Redirection and Regular Expressions

Permalink Redirection and Regular Expressions

I've got a pretty basic RegEx question but it's pressing enough that I
don't have time to run down a tutorial on RegEx in order to answer it
myself.
In short, I need: /2009/01/28/post-name/
redirected to /post-name/
As well as /post-name/author-name/
redirected to /post-name/
I promise to go take a class in RegEx before the month is out. Deal?
PS. Yes, I know that the Wordpress Redirection plugin will automate
.htaccess but it won't write RegEx for me.



Solved using the Redirection plugin.
Source URL: /(\d*)/(\d*)/(\d*)/([A-Za-z0-9-]*) Target URL: /$4

Why would one put `#! /usr/bin/false` in a Perl Module?

Why would one put `#! /usr/bin/false` in a Perl Module?

I was looking at the source code for the CPAN Perl module
Digest::MD5::Perl and noticed that it has the she bang #! /usr/bin/false.
Here's the first few lines of Digest/Perl/MD5.pm ...
#! /usr/bin/false
#
# $Id: MD5.pm,v 1.19 2004/02/14 02:25:32 lackas Exp $
#
package Digest::Perl::MD5;
use strict;
use integer;
use Exporter;
use vars qw($VERSION @ISA @EXPORTER @EXPORT_OK);
... why would the author of Digest::Perl::MD5 use #! /usr/bin/false? And
what if my system does not have /usr/bin/false but has /bin/false instead?

NSDateFormatter: Date according to currentLocale, without Year

NSDateFormatter: Date according to currentLocale, without Year

This can't be too difficult..
I want to display a date without the year. For example: "Aug, 2nd" (USA)
or "02.08." (GERMANY) It must work for a bunch of other locales as well.
My only idea so far is to do a normal format with year, and then remove
the year-portion from the generated string.

Behaviour of @Post callback methods i.e. @PostUpdate, @PostCreate etc. in JPA 2.0

Behaviour of @Post callback methods i.e. @PostUpdate, @PostCreate etc. in
JPA 2.0

Hi All,
I am not able to understand the exact behavior of @Post callback methods.
As mention in ProJPA book "When the SQL for deletion of an entity finally
does get sent to the database, the PostRemove event will get fired. As
with the PostPersist lifecycle event, the PostRemove event does not
guarantee success. The enclosing transaction may still be rolled back".
My concern here is, if SQL DELETE statement is already fire then how
transaction will be rolled back? If SQL DELETE statement is not able to
delete the object then exception will be thrown and @PostDelete will not
be executed. So, under what scenario transaction can be rolled back??
Thanks all for your time!!

Wednesday, 11 September 2013

Easier way to create a DataContext than implementing INotifyPropertyChanged?

Easier way to create a DataContext than implementing INotifyPropertyChanged?

As far as I know, there are 2 common ways to create a DataContect class,
one is to implement INotifyPropertyChanged and the other one is to derive
from DependencyObject.
Lots of people say the first way of implementing INotifyPropertyChanged is
simpler and I agree.
But I don't agree totally because I think even implementing
INotifyPropertyChanged is not simple enough but very tedious, because I
must rewrite every setter function for the properties and fire the event,
it's mostly copy & paste & modify things, which I dislike a lot. It's not
elegent.
So I'm curious, are there any other ways to create a DataContext, for
example, just derive from some class and all is done?
I know if the datacontext is a collection, there is a very easy way to do
it, just inherit from ObservableCollection<>, which I think is a very good
solution. But how about other classes?
Some 3rd party framework?

Uninitialized constant in view

Uninitialized constant in view

I have two models:
Post:
class Post < ActiveRecord::Base
has_many :exes
end
Exe:
class Exe < ActiveRecord::Base
belongs_to :post
end
What I am getting in my view on http://localhost:3000/posts/index is:
NameError in Posts#index
uninitialized constant Post::Ex
It says just Ex for some reason.
The code of line ruby is complaining on is <% post.exes.each do |exe| %>
which looks right to me.
So I don't really know why this is happening. If have also checked the
following as i thought this might be the reason but no:
2.0.0-p247 :004 > ActiveSupport::Inflector.pluralize('Exe')
=> "Exes"
2.0.0-p247 :005 > ActiveSupport::Inflector.singularize('Exe')
=> "Exe"
Thanks in advance!

using jquery UI how to add an image to the dialog

using jquery UI how to add an image to the dialog

i am using Jquery UI and i want to add an icon within the dialog box can
anyone help me ??? the dialog work fine but what i need to add a picture
to be more attractive i will appreciate any help
code
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Modal message</title>
<link rel="stylesheet"
href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!--<link rel="stylesheet" href="/resources/demos/style.css" />!-->
<script>
$(function() {
$( "#dialog-message" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>
</head>
<body>
<div id="dialog-message" title="Download complete">
<p>
<!--<span class="ui-icon ui-icon-circle-check" style="float: left; margin:
0 7px 50px 0;"></span>!-->
<span img src = "img1.jpg" style ="float: left; margin:0 7px 50px 0;
width:50px; height:50px;"></span>
Your files have downloaded successfully into the My Downloads folder.
</p>
<p>
Currently using <b>36% of your storage space</b>.
</p>
</div>
<p>Sed vel diam id libero <a href="http://example.com">rutrum
convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus
ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies
neque, sit amet auctor elit eros a lectus.</p>
</body>
</html>