Get different content from same URI - laravel-5

I am developing a blog system using Laravel and showing content based on URI segment. My segment is 3 and this segment is, post TITLE.
Problem is once a post title is "test" and another post has same title, "test" then system is showing only 1 post where there are 2 post actually.
How could I show the both post with same URI.
Example:
URI : example.com/article/test
Expected Content :
Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1 Test1
Example:
URI : example.com/article/test
Expected Content :
Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2 Test2

Related

Undefined dynamic step - Table inside a step reference for cucumber

I have the following situation here. A hypothetical .feature file has this:
Scenario Outline: Test
Given bla bla bla
When I input the <data>
Then I should see a message
Examples:
| data |
| test1 |
| test2 |
And I need to execute the "I input the " on a step reference.
So I have this:
Given('I already have data') do
step %{input the <data>
| data |
| test1 |
| test2 |
}
end
And its giving me the "Undefined dynamic step" error. What should I do in this case, to get it working?
Thanks a lot!

I can't display results line by line with "diff" on unix shell

SUMMARY
I'm using "diff" on my linux shell to compare two txt files.
My files are like this:
file1.txt
test1
test2
test3
test4
test5
file2.txt
test6
test7
test8
test9
test10
ISSUE
I use this command diff test1.txt test2.txt
And it displays
1,5c1,5
< test1
< test2
< test3
< test4
< test5
---
> test6
> test7
> test8
> test9
> test10
WHAT I WOULD LIKE
1,5c1,5
< test1
> test6
---
< test2
> test7
---
< test3
> test8
---
< test4
> test9
---
< test5
> test10
I tried my best to test with all parameters of 'diff' but I not be able to get what I want.

How to convert target values with pig?

I have some data with a target of 4 values ​​and I want three of these to become part of one single using latin pig.
Input: Output:
ID | Target ID | Target
----------------- -----------------
test1 1 test1 1
test2 1 test2 1
test3 2 test3 2
test4 2 test4 2
test5 3 test5 2
test6 4 test6 2
test7 2 test7 2
Someone knows the best way to do it
Use Bincond to check for target value greater than 1 and if true replace it with the value you want,in this case 2.
A = LOAD 'data.txt' USING PigStorage('\t') AS (Id:chararray,target:int);
B = FOREACH A GENERATE Id,(target > 1 ? 2 : target);
DUMP B;

Merging two files with columns in bash [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a file1.txt and the output is:
test4 30
test6 29
test3 17
test2 12
test5 5
This is file is ordered by second column. I sorted it with sort -nr -k 2 .
I have also file2.txt with the content of:
test2 A
test3 B
test4 C
test5 D
test6 E
What I want as result(result.txt) is:
test4 C 30
test6 E 29
test3 B 17
test2 A 12
test5 D 5
Using awk:
awk 'FNR == NR { a[$1] = $2; next } { print $1, a[$1], $2 }' file2 file1
Output:
test4 C 30
test6 E 29
test3 B 17
test2 A 12
test5 D 5
If file1 is not yet sorted, you can do:
sort -nr -k 2 file1 | awk 'FNR == NR { a[$1] = $2; next } { print $1, a[$1], $2 }' file2 -
Or
awk 'FNR == NR { a[$1] = $2; next } { print $1, a[$1], $2 }' file2 <(sort -nr -k 2 file1)
There are many ways to format the output. You can use column -t:
... | column -t
Output:
test4 C 30
test6 E 29
test3 B 17
test2 A 12
test5 D 5
Or you can use printf. Although I'd prefer using column -t since table would be broken if one column grows larger than the actual size that printf has provided.
... { printf "%s%3s%4.2s\n", $1, a[$1], $2 }' ...
Output:
test4 C 30
test6 E 29
test3 B 17
test2 A 12
test5 D 5
Don't sort the file before processing it, keep the sorting by 1st column.
Assuming you have :
file1 file 2
________________________
test2 12 test2 A
test3 17 test3 B
test4 30 test4 C
test5 5 test5 D
test6 29 test6 E
Using join file2 file1 | sort -nr -k 3 will yield :
test4 C 30
test6 E 29
test3 B 17
test2 A 12
test5 D 5
use -t' ' if you want your spacing unmodified by join

LINQ retrieve values from a table that of which fields(of a certain column) are not equal of another table

I have two tables which have a column in common, how can I retrieve the first table where the values of it's column are not equal to the values of the column of the other table?
Here is an example:
table1ID | foo | fooBool table2ID | foo | fooin
---------------------------- -----------------------------
1 | test1 | true 1 | test2 | 5
2 | test2 | true 2 | test3 | 7
3 | test3 | true
4 | test4 | false
Therefore the result of the LINQ query for the first table that has values of foo not equal that of table2 are:
table1ID | foo | fooBool
---------------------------
1 | test1 | true
4 | test4 | false
var results = from t1 in db.table1
from t2 in db.table2
where t1.foo != t2.foo
select t1
You could also use the Intersect() IEnumerable Extension
var results = db.table1.Intersect(db.table2);
Or in LINQ
var codes = from intersected in db.table1.Intersect(db.table2)
select intersected.foo;
This would produce
results
----------
test2
test3
Update
Thanks to Joe for pointing out that Intersect would produce the common items (added sample above). What you would want is the Except extension method.
var results = db.table1.Except(db.table2);
Or in LINQ
var codes = from diff in db.table1.Except(db.table2)
select diff.foo;
This would produce
results
----------
test1
test4

Resources