I created a swift file using a class called Course . Everything works in my code except when I try to input the URL. I get an error Message.
Here's is my sample code
URL(String:"https://www.youtube.com/watch?v=QBULK-w-i90")!
I keep getting error
Argument labels '(String)' do not match any available overloads
I'm not sure what that means and how can I fix this problem .
here is the code written out I follow video but keep getting errors.
import UIKit
class CourseStore
{
class func downloadNewCourses()-> [Course]
{
var courses = [Course]()
let chefCourse = Course(buttonImage: #imageLiteral(resourceName: "cover_chef"),
title: "Become a Pro Chef",
instructor: "Gordon Ramsay",
featuredImage: #imageLiteral(resourceName: "chef"),
introductionVideoUrl: URL(String:"https://www.youtube.com/watch?v=QBULK-w-i90")!,
introductionVideoUrl: ,
description: "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda."
)
return courses
}
}
Argument labels '(String)' do not match any available overloads
Means that URL doesn't have constructor which has those parameters. In your case you named parameter String but it should be lowercased string.
Instead use
URL(string: "https://www.youtube.com/watch?v=QBULK-w-i90")!
Related
In laravel 9 with spatie/laravel-tags 4.3
I add some initial data in seeder tagged with code like :
$this->votes_tag_type= 'votesTagType';
$lNewVote= Vote::create([
'id' => 1,
'name' => 'To be or not to be ?',
'slug' => 'to-be-or-not-to-be',
'description' => 'Still trying to find an answer. is the opening phrase of a soliloquy spoken by <i><i>Prince <i>Hamlet</i></i></i> in the so-called "nunnery scene" of <i><i>William Shakespeare</i>\'s</i> play <i>Hamlet</i>. Act III, Scene I.Though it is called a soliloquy <i>Hamlet</i> is not alone when he makes this speech because Ophelia is on stage pretending to read while waiting for <i>Hamlet</i> to notice her, and Claudius and Polonius, who have placed Ophelia in <i><i>Hamlet</i>\'s</i> way in order to overhear their conversation and find out if <i>Hamlet</i> is really mad or only pretending, have concealed themselves. Even so, <i>Hamlet</i> seems to consider himself alone and there is no indication that the others on stage hear him before he addresses Ophelia. In the speech, <i>Hamlet</i> contemplates death and suicide, bemoaning the pain and unfairness of life but acknowledging that the alternative might be worse. The meaning of the speech is heavily debated but seems clearly concerned with <i><i>Hamlet</i>\'s</i> hesitation to avenge his father\'s murder (discovered in Act I) by his uncle Claudius.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt...',
'creator_id' => 3,
'vote_category_id' => 1, // Classic literature
'is_quiz' => false,
'is_homepage' => true,
'ordering' => 1,
'status' => 'A',
'meta_description' => 'William Shakespeare with eternal question',
'meta_keywords' => ['Hamlet', 'William Shakespeare', 'Theater'],
'image' => 'tobe.png',
]);
$newTag= SpatieTag::findOrCreate('Hamlet', $this->votes_tag_type);
$lNewVote->attachTag('Hamlet', $this->votes_tag_type);
But with attachTag method used above I see 2 rows in tags table : https://prnt.sc/HzSVdpf0zDlf
also in taggables table I see rows with tag_id = 2. Assigned to 2nd row in tags table.
I think that is not valid, but what is wrong ?
Thanks!
Valid code is:
$lNewVote->syncTagsWithType(['Hamlet', 'William Shakespeare', 'Drama', 'Theater'], $this->votes_tag_type);
My problem is, that coreui in laravel does render the components, but none of them are interactive. For example when I use Tabs (CTabs), then it gets displayed correctly, but I cannot switch the tabs.
This is how I load coreui and the components:
import CoreuiVue from '#coreui/vue';
Vue.use(CoreuiVue);
// Registering a single component
import { CSwitch, CButton, CTabs, CTab, CCarousel, CCarouselItem } from '#coreui/vue';
Vue.component('CTabs', CTabs)
Vue.component('CTab', CTab)
Vue.component('CCarousel', CCarousel)
Vue.component('CCarouselItem', CCarouselItem)
// globally
Vue.directive('c-emit-root-event', CEmitRootEvent)
export default {
components: {
CTabs, CTab, CCarousel, CCarouselItem
},
directives: {
'c-tooltip': CTooltip
},
}
Vue.component(
'example-component',
require('./components/ExampleComponent.vue').default
);
const app = new Vue({
el: '#my-app',
data(){
}
});
Then the ExampleComponent.vue
<template>
<div>
<CTabs variant="pills" :active-tab="0">
<CTab title="Home">
1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
</CTab>
<CTab title="Profile">
2. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
</CTab>
<CTab title="Disabled" >
Text will not be shown.
</CTab>
</CTabs>
<CCarousel
arrows
indicators
animate
height="450px"
>
<CCarouselItem
captionHeader="First Slide"
image="https://picsum.photos/1024/480/?image=52"
captionText="Nulla vitae elit libero, a pharetra augue mollis interdum."
/>
<CCarouselItem
captionHeader="Blank page"
:image="{ placeholderColor: 'grey' }"
captionText="Nulla vitae elit libero, a pharetra augue mollis interdum."
/>
<CCarouselItem
image="https://picsum.photos/1024/480/?image=54"
/>
</CCarousel>
</div>
</template>
<script>
module.exports = {
data: function () {
return {
message : 'Hello Vue!!'
}
},
name: 'example-component'
}
</script>
and the view file
<div id="my-app">
<example-component></example-component>
</div>
Any ideas?
I simply had to wrap the Vue Object into DOMContentLoaded to make sure that the DOM is ready before attaching vue.js.
document.addEventListener("DOMContentLoaded", function(event) {
const app = new Vue({
el: '#my-app',
data(){
}
});
})
I have the following file format:
Text1
+ continuation of Text1
+ more continuation of Text1
Text2
+ continuation of Text2
+ more continuation of Text2
+ even more continuation of Text2
Continuations are marked by \n+. (Newline, plus character, space as a three character string.) Continuations can be any number of lines, including 0.
I want the following output (each is a line printed with .forEach):
Text1 continuation of Text1 more continuation of Text1
Text2 continuation of Text2 more continuation of Text2 even more continuation of Text2
I would like to use only Java streams to do the conversion, preferably with Collect. Is there a way to do this elegantly?
EDIT:
Another, more realistic example:
Lorem ipsum dolor sit amet, consectetur
+ adipiscing elit, sed do eiusmod tempor incididunt
+ ut labore et dolore magna aliqua. Ut enim ad minim veniam,
+ quis nostrud exercitation ullamco laboris nisi ut aliquip ex
+ ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit
+ esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
+ occaecat cupidatat non proident, sunt in culpa qui officia
+ deserunt mollit anim id est laborum.
Expected result is two lines:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
In Java 9, you could use
static final Pattern LINE_WITH_CONTINUATION = Pattern.compile("(\\V|\\R\\+)+");
…
try(Scanner s = new Scanner(file)) {
s.findAll(LINE_WITH_CONTINUATION)
.map(m -> m.group().replaceAll("\\R\\+", ""))
.forEach(System.out::println);
}
Since Java 8 lacks the Scanner.findAll(Pattern) method, you may add a custom implementation of the operation as a work-around
public static Stream<MatchResult> findAll(Scanner s, Pattern pattern) {
return StreamSupport.stream(new Spliterators.AbstractSpliterator<MatchResult>(
1000, Spliterator.ORDERED|Spliterator.NONNULL) {
public boolean tryAdvance(Consumer<? super MatchResult> action) {
if(s.findWithinHorizon(pattern, 0)!=null) {
action.accept(s.match());
return true;
}
else return false;
}
}, false);
}
which can be used like
try(Scanner s = new Scanner(file)) {
findAll(s, LINE_WITH_CONTINUATION)
.map(m -> m.group().replaceAll("\\R\\+", ""))
.forEach(System.out::println);
}
which will make the future migration easy.
Assuming that you run this sequentially only and really want to use streams:
List<String> result = Files.lines(Paths.get("YourPath"))
.collect(() -> new ArrayList<>(), (list, line) -> {
int listSize = list.size();
if (line.startsWith("+ ")) {
list.set(listSize - 1, list.get(listSize - 1) + line.substring(2));
} else {
list.add(line);
}
}, (left, right) -> {
throw new RuntimeException("Not for parallel processing");
});
I'm trying to implement text search with linq. I have a Messages table which is populated with emails data. I want to be able to search in Messages body. However emails bodies are very long and I will like to display only small part of the searched text for example if I search for:
aute
in the following text:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
the result should be:
...aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur....
Thanks
Something like this should do the job:
var query = from str in messages
let index = str.IndexOf(search)
where index > -1
select str.Substring(Math.Max(0, index - radius), radius + Math.Min(radius, str.Length - index));
Where messages is your email string list, and radius is an int describing how many characters you want to take before and after the string you are looking for. Note that this code will only return the first match in every email, ignoring the other ones.
Everything would be easier if you could use an helper function to calculate the proper substring tho.
Here you can find an extension method that implements a safe version of string.substring, making hte above linq code look something like:
var query = from str in lst
let index = str.IndexOf(search)
where index > -1
select str.SafeSubstring(index - radius, 2*radius);
that in my opinion is much simnpler to read
EDIT
Extending string with the two following methods :
public static List<int> IndexOfAll(this String str, string search)
{
List<int> lst = new List<int>();
foreach (Match match in Regex.Matches(str,search))
{
lst.Add(match.Index);
}
return lst;
}
public static string SafeSubstring(this String str, int start, int n)
{
return str.Substring(Math.Max(start, 0), Math.Min(n, str.Length - start));
}
you can get all the results in a nice form, using
var query = from str in lst
let index = str.IndexOfAll(search)
where index.Count>0
select index.Select(x => str.SafeSubstring(x-radius, 2*radius));
with query as an IEnumerable
I am trying to update the text inside a div. But when I use the below types of selections I get null.
my.class = Class.create(
{
initialize:function(container){
this._popup = new Element("div",{"id":"tm-popup"});
var innerEl = "<div class='content'><div></div></div>";
this._popup.insert(innerEl);
container.insert({bottom:this._popup});
},
show:function(){
var tempText = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.";
console.log("div = ", this._popup.select('content') );
console.log("div = ", $('#tm-popup').select('.content') );
$('#tm-popup').select('.content').update( tempText );
}
});
I have tried 3 ways to try and get the div to update its text but all 3 fail.
I want to stay away from $$ as a selector as I have a huge DOM tree and don't want to run through everything with the $$
If I do a log on this._popup in the show method it does trace out the object so I know its there.
For anyone who might run into this issue here is an answer.
$(this._popup).down('.content').update(tempText);