Monday, April 16, 2012

Calculate value of symbolic equation in MATLAB

I have following MATLAB code:



>> syms x
>> z = 20.*exp(x)+cos(x)
>> derivative = diff(z)


How can I calculate value of derevative for any number, e.g. 6?



Following commands



>> clear all
>> x = 6
>> derevative = 20*exp(x)-sin(x)


works fine, but if x is symbolic I don't use x = 6 such as above example.





How to display a progress bar during loading another table view with a table view

I have a table view cell , during click it , another table view will open , you can select something as the value of the table view cell. The issue here is the data in the second table view is big and it will take long time to load. So after I click the cell , the screen will froze there which is not user friendly. I want to displaying a progress bar during load the second table view. But I can not find a good place to add that. I am wondering in which method should I add the code to display the progress bar.





Can I consolidate these two jQuery on() events with a toggle()?

There has got to be a way to do these in one toggleClass():



$('div').on("mouseenter", ".myButton", function(){
$(this).addClass('rollOver');
});
$('div').on("mouseleave", ".myButton", function(){
$(this).removeClass('rollOver');
});


...but it's within an on() because the myButton is created dynamically.





Webrick:: Access to public folders (css, js etc)

Webrick serves "/" path, but I want to have direct access to css, js and other public folders.



if I use DocumentRoot, will handle all public paths too (like css/style.css), because it hadles root path:



server = WEBrick::HTTPServer.new(
:DocumentRoot => Dir::pwd,
:Port=>8080
)


I need to mount_proc my root:



server.mount_proc('/') {|req,resp|  ...


How to give access to public folders?





Correctly send user to 404 if dynamic content is not found (ASP.NET MVC)

I have implemented 404 handling for the general case in ASP.NET MVC 3, for when a controller/view is not found. But how should it be handled inside the controller if the user is trying to access something that can't be found? For example www.foo.bar/Games/Details/randomjunk will call this inside GamesController:



public ActionResult Details(string id) // id is 'randomjunk'
{
if(DoesGameExist(id) == false)
// Now what?


I could just do a return Redirect('/Errors/Http404'); but that doesn't seem like the correct way to do it. Should you throw an exception, or something else?



We could have a special view in this case, but to start with we need a good way we can apply to several cases.



Edit: I want to show my friendly 404 page I already have for the general case.





Take picture with android camera (intent) out of memory error

I'm having two troubles with the below code. It just take picture "onclick" using intent of camera android and it display the image on the ImageView.



1) After two or three pictures without leaving the activity, it crash with an outOfMemory error often when i'm rotating the display.
2) When I take picture first time, it refresh the imageview but when i do second or third time...it doesn't refresh the picture until I rotate the screen
3) I would like to save picture on internal storage instead of external, but I don't understand how to do cause I tried several tutorial and it stucks the camera!



public class HandScryActivity extends Activity {

private static int TAKE_PICTURE = 1;
private MtgMatch myMatch;
private File handFile;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.handscry);
// Disable screen saver
getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
// Load match
myMatch = MtgMatch.getSingletonMtgMatch();
handFile = new File(Environment.getExternalStorageDirectory(), "test.jpg");
if (myMatch.getHandUri() != null) { loadPicture(); }
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
loadPicture();
}

// Handles onGame clicked buttons
public void btnHandClick(View v) {
Button clickedButton = (Button) v;
// according to clicked button
switch (clickedButton.getId()) {
case R.id.btnBackToGame:
this.finish();
break;
case R.id.btnTakePicture:
myMatch.setHandUri(Uri.fromFile(handFile));
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, myMatch.getHandUri());
startActivityForResult(intent, TAKE_PICTURE);
break;
default:
break;
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == TAKE_PICTURE) {
// Display image
if (resultCode == RESULT_OK) {
loadPicture();
} else if (resultCode == RESULT_CANCELED) {
// User cancelled the image capture
} else {
// Image capture failed, advise user
}
}
}

// Put the photo inside frame
private void loadPicture() {
ImageView img = (ImageView) findViewById(R.id.imgHand);
img.setImageURI(myMatch.getHandUri());
}

}




Symfony2 validator, NotBlank but allow null

I'm having trouble validating a value to allow NULL but not an empty string with the Symfony2 validator component.



I've integrated the component in a Silex application and used the Property Constraint target to validate some properties of my Application Entities (not a Doctrine Entity).



I've added this static method to my Entity class to validate name and service_id on my Entity, problem is that when service_id is NULL which should be valid the NotBlank constraint kicks in and reports a violation.



static public function loadValidatorMetadata(ClassMetadata $metadata)
{
// name should never be NULL or a blank string
$metadata->addPropertyConstraint('name', new Assert\NotNull());
$metadata->addPropertyConstraint('name', new Assert\NotBlank());

// service_id should either be a non-blank string or NULL
$metadata->addPropertyConstraint('service_id', new Assert\NotBlank());
}


Bottomline, I'm looking how to allow either a String or NULL as service_id but not allow an empty string.



PS: I've also tried the MinLength(1) constraint but that allows empty strings unfortunately.





Can I make money if I release my CMS as opensource

I have a CMS that I've written in ASP.NET. It still needs work and I'm thinking of releasing it as opensource. I'm just not sure how I want to handle this in the future. If I release it now as opensource, can I still release a commercial version? What other ways are there for me to make money on the CMS?





Can there collision if two threads writing on the same serial port?

I am coding in c#. Can there collision if two threads writing on the same serial port?
If yes, how can I handle this? Also I want to give priority to one of the thread.



For eg. If two threads are writing on the serial port, I want to halt the transmission of thread 1 when I write data from thread 2. i.e. thread 2 has priority of writing it to port than thread1.





Best way to wait async to complete on WP7

i having some hard time on this, i'm trying to get my first WP7 app out.
I have an method that download the html from a website and regex it, but the problem is, when i click the button for the first time, nothing happens, on the second try, it fills the grid perfectly, when i was debugging i saw the string with the HTML is already assigned correctly before the method even starts. So, the question is, what is the simplest way to wait for async method to finish?
I've searched about CTP async and some other ways, but i can't manage to make it work.
Here's is the code



   public static void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
doc = e.Result;
}

public static List<Row> Search(string number)
{
WebClient wClient = new WebClient();

sNumber = number;
int i = 0;
DateTime datetime;

wClient.DownloadStringAsync(new Uri(sURL + sNumber));
wClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
/*More code*/
}


The button calls the method Search() and uses the list returned to fill the grid.





Two expanders beside each other wont expand the latter

For some reason when I set two expanders beside one another, the first expander seems to be behind the second one and wont expand out the expander set beside it? Is there a way I can fix this in the code below?



<Grid>
<StackPanel Orientation="Horizontal" Margin="0,0,195,0">
<StackPanel.Triggers>
<EventTrigger RoutedEvent="Expander.Expanded" SourceName="expander">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="0" To="1.2" Duration="0:0:0.35" Storyboard.TargetName="listBox" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleX)"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</StackPanel.Triggers>
<Expander x:Name="expander" Expanded="expander_Expanded" ExpandDirection="Right" Width="29">
<ListBox x:Name="listBox">
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBox.LayoutTransform>
<ScaleTransform ScaleX="0" ScaleY="1"/>
</ListBox.LayoutTransform>
</ListBox>
</Expander>

<StackPanel Orientation="Horizontal" Margin="0,0,342,0" Width="318">
<StackPanel.Triggers>
<EventTrigger RoutedEvent="Expander.Expanded" SourceName="expander1">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="0" To="1.2" Duration="0:0:0.35" Storyboard.TargetName="listBox1" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleX)"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</StackPanel.Triggers>
<Expander ExpandDirection="Right" Name="expander1" Width="29">
<ListBox Name="listBox1">
<ListBox.LayoutTransform>
<ScaleTransform ScaleX="0" ScaleY="1" />
</ListBox.LayoutTransform>
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
<ListBoxItem Content="ListBoxItem" VerticalAlignment="Top" />
</ListBox>
</Expander>
</StackPanel>
</StackPanel>
</Grid>






How user can (safely) programme their own filter in Java

I want my users to be able to write there own filter when requesting a List in Java.



Option 1) I'm thinking about JavaScript with Rhino.

I get my user's filter as a javascript string. And then call isAccepted(myItem) in this script.

Depending on the reply I accept the element or not.



Option 2) I'm thinking about Groovy.

My user can write Groovy script in a textfield. When my user searches with this filter the Groovy script is compiled in Java (if first call) and call the Java methode isAccepted()
Depending on the reply I accept the element or not.



My application rely a lot on this fonctionallity and it will be called intensively on my server.

So I beleave speed is the key.



Option 1 thinking:
Correct me if I'm wrong, but I think in my case the main advantage of Groovy is the speed but my user can compile and run unwanted code on my server... (any workaround?)



Option 2 thinking:
I think in most people mind JavaScript is more like a toy. Even if it's not my idea at all it is probably for my customers who will not trust it that much. Do you think so?

An other bad point I expect is speed, from my reading on the web.

And again my user can access Java and run unwanted code on my server... (any workaround?)



More info:
I'm running my application on Google App Engine for the main web service of my app.

The filter will be apply 20 times by call.

The filter will be (most of the times) simple.




Any idea to make this filter safe for my server?

Any other approche to make it work?





Is there a difference between LDAP and CRL?

In context of Public Key Infrastructure ? By LDAP i mean publicly available public keys exposed by an LDAP server that you can query using the LDAP protocol ? CRL stands for certificate revocation list, in other words it contains certificates not to be trusted. Do these two protocols depend on the same database of public key certificates ? I have a CA here, that announced it would not continue updating the CRL, but their responses to LDAP queries seem up to date.





Is there a better way to run this mysql update?

I have the following code, which firstly retrieves each unique style from a database and then searches through the products table to find the terms associated with each style and updates the stylerefs table with the styleid and the productid:



$query = "Select id,style,terms from su_styles";

if ($results = $sudb->query($query)) {

while($result = $results->fetch_array(MYSQLI_ASSOC)) {

$id=$result['id'];
$style=$result['style'];
$terms=$result['terms'];

$query= "INSERT IGNORE INTO su_stylerefs (mykey,id)
SELECT mykey,$id FROM su_pref where (match(name) against ('$terms' in Boolean Mode))
ON DUPLICATE KEY UPDATE id=$id, mykey = su_pref.mykey";

$sudb->query($query);


Is there anyway I can rewrite this query into one, rather than looping through the results of the first query? I have 10 other similar queries that need to run every day and some of the tables in the first query could have 100s of records, which mean hundreds of connections to the database, which takes a while.



Thank you in advance





How to filter out a tagname in Eclipse LogCat viewer

I have an Android application that "spams" the LogCat and I would like to remove its logcat entries in order to have an output more readable.



Is it possible to have a filter that remove the LogCat entries for a specific tag name? Or a search pattern that does the trick?





can I delete stale entries from mysql.user table?

I did a bunch of GRANTS in trying to gain connectivity from a remote host. So I did :



GRANT ALL PRIVILEGES ON *.* TO 'prog'@'foobar-dev.foobar.com' WITH GRANT OPTION;


however, 'foobar-dev' no longer exists. and there are a bunch of other entries for other non existent hosts..



I did the following REVOKE, hoping the entry in mysql.user would go away :



REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'prog'@'foobar-dev.foobar.com'.


This sets all the the columns in mysql.user to "N" for 'prog'@'foobar-dev.foobar.com', but wouldn't it be better (and cleaner) to delete the row? I have not deleted the row, as this could 'break something' and violate referential integrity of system tables I am not that familiar with. But, it sort of is distracting to have bogus entries I have to see it every time I select on mysql.user to check privileges. I always thought system tables should reflect reality, not be a litany of the past.



So, does mysql.user "stand by itself" such that deleting rows in it has no side affects to other tables? what is the correct way to maintain this table?



Would this break anything?



delete from mysql.user where Host = 'foobar-dev.foobar.com' and User = 'prog';


TIA!





analyzing a txt file in python by jumping the n_th element of a list

I have trouble handling a txt file with lines like this:



50.0 0.1 [0.03, 0.05, 0.067, 1.003, ...]
50.0 0.134 [0.3465, 0.5476, 1.0, ....]
.
.
.


I don't need the beginning of each line, just the lists!The elements of a list are not evenly spaced and seperated by space characters and comma.
What i wanna do is ignore what ever is in front of the list, jump to (for example) the 9th element of the list, read and save it und then go to the next line and do the same.



my approach:



Find away way to handle the line oft the txt as a list and not as a string, so i can operate with the elements of the list..



or



manage to jump to the 9th space character and then read everythin till the next (10th in this case) space character



any ideas how to do this?



Every idea for a solution is appreciated! thx





Does FluentSecurity replaces Asp.Net membership provider or it's supposed to complement/work together with it?

I'm working on an Asp.Net MVC4 site and I wanted to create a membership provided backed by Redis. Since I need the user privileges to be dynamic - user can create new roles in the admin dashboard - I was considering on using FluentSecurity (fluentsecurity.net) in the way explained in this SO question ASP.NET MVC3 Role and Permission Management -> With Runtime Permission Assignment.



So, my question is: Does FluentSecurity replaces Asp.Net membership system (or custom ones based on the membership provider pattern) or is it meant to augment it?





Java multithreading and files

I'm working on project. One part of it is read given folders files.
Program travels into deep and collects filenames and other info which i wrap into my own DFile class, and puts it into collection for further work.
It worked when was singlethreaded (using recursive read), but I want to do that in multithreading perspective, ignoring the thing that disk IO and multithreading won't increase performance. I want it for learning purpose.



So far, I've been jumping from one decision to another, changing plans how it will be and can't get it good. Your help would be appreciated.



What I want, that I supply root folder name, and my program runs several minithreads (user defined number of threads for this purpose), each thread reads given folders content:
- When it finds file, wraps it into DFile and puts into shared between threads collection
- When it finds folder, puts folder (as File object) into jobQueue, for other available thread to take work on it.



I can't get this system correctly. I've been changing code, puting idea what classes should be from one class with static collections to many.
So far few classes I am listing here:



DirectoryCrawler http://pastebin.com/8tVGpGT9



Won't publish rest of my work (maybe in other topic, because purpose of the program absolutely not covered here). Program should read folder and make a list of files in it, then sort it (where I'll probably use multithreading too), then search for same hashed files and there's constantly working thread for writing those equal file groups into result file. I don't need to gain any performance, files gonna be small, as at first I was working on speed, I don't need it now.



Any help regarding design of reading would be appreciated



EDIT:



So much of headache :((. Doesn't work correctly :( Here so far:
crawler (like a minithread for reading one folder, found files goes to fileList which is in other class, and folders to queue) pastebin. com/AkJLAUhD



scanner class (Don't even know should it be runnable or no). DirectoryScanner (main, should control crawlers, hold main filelist) pastebin. com/2abGMgG9 .



DFile itself pastebin. com/8uqPWh6Z (something became wrong with hashing, now when sorting all get same hash.. worked .. (hashing is for other task unrelated)) .



Filelist http:// pastebin. com/Q2yM6ZwS



testcode:



DirectoryScanner reader = new DirectoryScanner(4);
for (int i = 0; i < 4; i ++) {
reader.runTask(new DirectoryCrawler("myroot", reader));
}
try {
reader.kill();
while (!reader.isDone()) {
System.out.println("notdone");
}
reader.getFileList().print();
}


myroot is a folder with some files for test



Anything, i can't even think of should scanner be itself runnable, or only crawlers. Because while scanning I actualy don't want to start doing other stuff like sorting (because nothing to sort while not gathered all files) ..





Accessing the contents of a selected subclasses UITableViewCell

If I've subclass UITableViewCell with say MySubclassedCell and it contains a few labels and an image, how would I go about accessing the contents of the subclassed cell in the didSelectRowAtIndexPath method?



Normally (without subclassing) I'd do this:



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
}


and then go from there. Replacing MySubclassedCell doesn't work, so what if I need to access the properties of a subclassed cell?





what does the arguments of startelement() method in SAX parser refer to

public void startElement(String uri, String localName, String qName,
Attributes attributes)


can anybody please give a simple example as to how localname is different from qName and what exactly is the uri string ? And yes before somebody asks I did check it on the net but no one cared to mention the difference as some examples used qName and others used localname which is really confusing for me.





Any tips to improve MySQL query?

I have a table with 500K rows that looks like this: http://d.pr/njFJ



enter image description here



A query like this sometimes often takes more than 2 seconds:



SELECT * 
FROM `alerts`
WHERE `a_timestamp` > '2012-04-15' AND `a_timestamp` <= '2012-04-16'
AND a_company_id IN(64,65,69,70,71,72,73,74,75,76,83,86,106,108,109,116,148) ORDER BY a_id DESC


Here's the explain query: http://d.pr/z20b



enter image description here



Can somebody point out what I'm doing wrong? Maybe I'm missing something. Should it take that much time on such a small table?





How to write a web crawler?

I have this code to extract news content from a given news web page (The code makes use of Boilerpipe to extract news from a web page).



package news_extraction;

import de.l3s.boilerpipe.document.TextDocument;
import de.l3s.boilerpipe.extractors.ArticleExtractor;
import de.l3s.boilerpipe.sax.BoilerpipeSAXInput;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
import org.xml.sax.InputSource;


public class Main {


public static void main(String[] args)throws Exception{
// TODO code application logic here
Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", "proxy_host");
systemSettings.put("http.proxyPort", "8080");
System.getProperties().put("http.proxyUser", "my_username");
System.getProperties().put("http.proxyPassword", "my_password");

System.setProperties(systemSettings);
URL url;
url = new URL("http://any_url");

final InputStream urlStream = url.openStream();
final InputSource is = new InputSource(urlStream);

final BoilerpipeSAXInput in = new BoilerpipeSAXInput(is);
final TextDocument doc = in.getTextDocument();
urlStream.close();

// You have the choice between different Extractors

// System.out.println(DefaultExtractor.INSTANCE.getText(doc));
System.out.println(ArticleExtractor.INSTANCE.getText(doc));

}

}


Now I want to integrate this code in a web crawler to extract news content from different news web sites automatically on receiving user's input and store it in a file.Can anyone give me some idea how to do it ?



Thanks.





Using characterAtindex with objective C NSPredicate class

I have a pList of strings which I'm bundling into an NSMutable Array. I want to compare each character in the strings to a specified character and use the results to create a new array.



I'm able to filter on the first and last characters using the below



NSPredicate *filter = [NSPredicate predicateWithFormat:@"SELF beginswith[cd] %@", @"B"];

NSPredicate *filter = [NSPredicate predicateWithFormat:@"SELF endswith[cd] %@", @"B"];


but when I try to check the characters in between using the characterAtIndex method I get an error.



NSPredicate *filter = [NSPredicate predicateWithFormat:@"SELF characterAtIndex:%i LIKE[cd] %@", 3, @"B"];


I know I could probably do a loop to loop through each word checking the characters but using NSPredicate is so much tidier and should be much better performance considering the list of strings can be quite large (over 100,000).



Can anyone show me the proper syntax for using characterAtIndex with NSPredicate or have any other solution ideas?



Thanks in advance for any help,
Derm





Merging two table in sqlplus

I have two tables with same structure:
masterTable (id, description, list_price)
and
changesTable (id, description, list_price)



I want to merge changes from changesTable into masterTable, but I don't want to update 'description' in masterTable when it is NULL in changesTable, I want to keep old value



I tried to do this



WHEN MATCHED THEN
UPDATE SET master.list_price=changes.list_price,
master.description=ch.description
WHERE length(changes.description)>0


but in this case the list_price doesn't get updated as well.



How can I merge them properly?
Thanks





Regarding hashcode() and Equals()

I have a POJO that contains hashcode() and equals() method that I have overridden , but my query is that what about If i make hashcode() method comment then in collection lets say in a hashmap when I am storing the user defined objects then what impact would it have...and another thing is that if I make equals method as a comment then what Impact would it have If I try to enter duplicate records will it store duplicate records twice!



public class Employee {

String name,job;
int salary;

public Employee(String n , String j, int t )
{
this.name= n;
this.job=j;
this.salary= t;
}

/* @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((job == null) ? 0 : job.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + salary;
return result;
}*/

/*@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employee other = (Employee) obj;
if (job == null) {
if (other.job != null)
return false;
} else if (!job.equals(other.job))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (salary != other.salary)
return false;
return true;
}
*/

@Override
public int hashCode()
{
return name.hashCode()+job.hashCode()+salary;

}

@Override
public boolean equals(Object obj) {
if (this == obj)
{
return true;
}
// make sure o can be cast to this class
if (obj == null || obj.getClass() != getClass())
{
// cannot cast
return false;
}

Employee e = (Employee) obj;
return this.name.equals(e.name)&&this.job.equals(e.job)&&this.salary==e.salary;
}

@Override
public String toString() {
return name+"\t" +"\t"+ job +"\t"+ salary;
}
}




Format SQL Output

I need to make my output readable. I have succeeded in doing so, for queries that I write directly.




  1. I need to do the same for queries that involve a cursor, i.e. to be specific, I need the records returned by a cursor to be formatted as well. But I am unable to do.


  2. I instead explicitly print the column names, and the print the records. Still, the same. Is there any way, I could retrieve the headers as well, and then based on their length, format the received records as well?






Have a list, need to see which number is the biggest

I have a text in python,and I need to check which letter is starting in the words the most,and how many times did it happen...
I know how to do it, and using the max function I can see which letter have been used the most(I'm having a counnter for the 26 letters in the A B C), though I cant know which letter is it...
is there a way to see the place of the max number in the list?
(using the max function, for ex. max(list))...
Thanks...





wordpress custom field output after the_content

What I want to do is output a custom field content (which is a button with a dynamic link that's being inserted in the value of the custom field of each posts) right after the_content and before the plugins.



This is the code for the custom field:



<div class="button">
<a href="<?php echo get_post_meta($post->ID, 'Button', true); ?>">
<img src="<?php echo get_template_directory_uri() . '/images/button.png'; ?>" alt="link" />
</a>
</div>


On wordpress codex I also found this example of how to apply a filter to the_content in order to obtain something similar to what I want. This is the code:



add_filter( 'the_content', 'my_the_content_filter', 20 );
function my_the_content_filter( $content ) {
if ( is_single() )
// Add image to the beginning of each page
$content = sprintf(
'<img class="post-icon" src="%s/images/post_icon.png" alt="Post icon" title=""/>%s',
get_bloginfo( 'stylesheet_directory' ),
$content
);
// Returns the content.
return $content;
}


The problem is I don't know PHP and I have no idea how am I supposed to edit the above code to apply on my specific case.



I modified it a bit and I manage to list the button, but only before the_content and without the PHP that enables the custom field.



add_filter( 'the_content', 'my_the_content_filter', 20 );
function my_the_content_filter( $content ) {

if ( is_single() )
// Add button to the end of each page
$content = sprintf(
'<img class="button-link" src="%s/images/button.png" alt="Link" title=""/>%s',
get_bloginfo( 'stylesheet_directory' ),
$content
);
// Returns the content.
return $content;
}


You can see the output here: http://digitalmediaboard.com/?p=6583 (it's the top-right 'show-me' button)





Java this.classProperty versus classProperty incase argument variable name clashes?

Can someone please explain output 0 in case of first constructor without this ?



If the argument variable name is same as class property name and i am using that property inside the method. What does java interpret that "class property" or "the argument variable" ?



Without this:



 public User(int userId){
userId = userId;

}


With this:



 public User(int userId){
this.userId = userId;

}


public void PrintUserId(){
System.out.println(this.userId);
}

User firstUser = new User(123);
firstUser.PrintUserId();


// 0 without this



//123 with this