By continuing you indicate that you have read and agree to our Terms of service and Privacy policy
by azkaban Java Version: 4.0.0 License: Apache-2.0
by azkaban Java Version: 4.0.0 License: Apache-2.0
Support
Quality
Security
License
Reuse
kandi has reviewed azkaban and discovered the below as its top functions. This is intended to give you an instant insight into azkaban implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
Azkaban workflow manager.
QUESTION
GraphQLObjectType is not a constructor
Asked 2021-May-22 at 08:03I'm trying to follow a graphql tutorial, even thoughg I followed it and double checked I keep getting the above error and I have no idea why
dont you really hate when the bot asks you to type more, its mostly code for a reason I dont have a clue and I posted all my code!!!
const express = require("express");
const expressGraphQL = require("express-graphql");
const graphql = require("graphql");
const {
GraphQlSchema,
GraphQlObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
GraphQLNonNull,
} = graphql;
const app = express();
const authors = [
{ id: 1, name: "J. K. Rowling" },
{ id: 2, name: "J. R. R. Tolkien" },
{ id: 3, name: "Brent Weeks" },
];
const books = [
{ id: 1, name: "Harry Potter and the Chamber of Secrets", authorId: 1 },
{ id: 2, name: "Harry Potter and the Prisoner of Azkaban", authorId: 1 },
{ id: 3, name: "Harry Potter and the Goblet of Fire", authorId: 1 },
{ id: 4, name: "The Fellowship of the Ring", authorId: 2 },
{ id: 5, name: "The Two Towers", authorId: 2 },
{ id: 6, name: "The Return of the King", authorId: 2 },
{ id: 7, name: "The Way of Shadows", authorId: 3 },
{ id: 8, name: "Beyond the Shadows", authorId: 3 },
];
const BookType = new GraphQlObjectType({
name: "Book",
description: "A Book written by an author",
fields: () => ({
id: { type: GraphQLNonNull(GraphQLInt) },
name: { type: GraphQLNonNull(GraphQLString) },
authorId: { type: GraphQLNonNull(GraphQLInt) },
}),
});
const RouteQueryType = new GraphQlObjectType({
name: "Query",
description: "Root Query",
fields: () => ({
books: new GraphQLList(BookType),
description: "List of Books",
resolve: () => books,
}),
});
const schema = new GraphQlSchema({
query: RouteQueryType,
});
app.use(
"/graphql",
expressGraphQL({
schema: schema,
graphiql: true,
})
);
app.listen(5000, () => console.log("server running"));
ANSWER
Answered 2021-May-22 at 08:03Wrong capitilisation GraphQlObjectType
should be GraphQLObjectType
QUESTION
KeyError on chained callback for dependent dropdowns in plotly-dash [Python]
Asked 2021-Apr-16 at 01:20I'm trying to create a dependent dropdown in dash/plotly, based on the unique values from the column depending on what is selected in the first dropdown. I created a chained callback and visually, the graph is updating correctly and the dropdowns are populating correctly. However, I receive an KeyError for one of my fields (Category
, which has nothing to do with the dropdowns, it simply colors the categories), after a fair amount of tinkering I still can't figure out what's causing it. Here's my layout, callbacks and the error I'm getting in the debug environment:
#Layout
app.layout = html.Div(children=[
dcc.Dropdown(id='select_game',
options=[
{"label": "Harry Potter and the Philosopher's Stone (HP1)", "value":"HP1"},
{"label": "Harry Potter and the Chamber of Secrets (HP2)", "value":"HP2"},
{"label": "Harry Potter and the Prisoner of Azkaban (HP3)", "value":"HP3"},
{"label": "Harry Potter and the Goblet of Fire (HP4)", "value":"HP4"}
],
multi=False,
value="HP1",
clearable=False, className = 'dcc-compon'
),
dcc.Dropdown(id='select_platform',
options=[],
multi=False,
clearable=False, className = 'dcc-compon'
),
html.Br(),
dcc.Graph(id="wrprogvis", figure={}),
], style={'font-family':'bahnschrift'})
#Chained callback
@app.callback(
Output('select_platform', 'options'),
Input('select_game', 'value')
)
def get_platforms(select_game):
wrcombo_plts = wrcombo[wrcombo['Game']==select_game]
return [{'label': i, 'value': i} for i in wrcombo_plts['Platform'].unique()]
print(wrcombo_plts['Platform'].unique())
@app.callback(
Output('select_platform', 'value'),
Input('select_platform', 'options')
)
def slct_platform(select_platform):
return[k['value'] for k in select_platform][0]
@app.callback(
Output(component_id='wrprogvis', component_property='figure'),
[Input(component_id='select_game', component_property='value'),
Input(component_id='select_platform', component_property='value')
]
)
#Graph build
def update_graph(game_slct, plat_slct):
wrcombo_ = wrcombo.copy()
wrcombo_ = wrcombo_[wrcombo_['Game']==game_slct]
wrcombo_ = wrcombo_[wrcombo_['Platform']==plat_slct]
wrfig = px.line(wrcombo_, x='Date', y='Time', color='Category', custom_data=['Runner', 'Game', 'Notes'], height=600)
wrfig.update_traces(
mode="markers+lines",
hovertemplate='<b>%{customdata[0]}</b><br>Time: %{y|%H:%M:%S} <br>Achieved on: %{x|%e %b %Y} <br>Notes: %{customdata[2]}'
)
wrfig.update_layout(yaxis_tickformat='%H:%M', title_font={"family": "Bahnschrift"}, legend_font_family="Bahnschrift", legend_title_font_family="Bahnschrift")
wrfig.update_xaxes(
title_font = {"family": "Bahnschrift"},
tickfont = {"family": "Bahnschrift"},
showspikes=True
)
wrfig.update_yaxes(
title_font = {"family": "Bahnschrift"},
tickfont = {"family": "Bahnschrift"},
showspikes=True,
)
return wrfig
Error:
KeyError: 'Category'
Traceback (most recent call last)
File "HPWRprog.py", line 194, in update_graph
wrfig = px.line(wrcombo_, x='Date', y='Time', color='Category', custom_data=['Runner', 'Game', 'Notes'], height=600)
File "_chart_types.py", line 252, in line
return make_figure(args=locals(), constructor=go.Scatter)
File "_core.py", line 1889, in make_figure
for val in sorted_group_values[m.grouper]:
KeyError: 'Category'
Traceback (most recent call last):
File "HPWRprog.py", line 194, in update_graph
wrfig = px.line(wrcombo_, x='Date', y='Time', color='Category', custom_data=['Runner', 'Game', 'Notes'], height=600)
File "_chart_types.py", line 252, in line
return make_figure(args=locals(), constructor=go.Scatter)
File "_core.py", line 1889, in make_figure
for val in sorted_group_values[m.grouper]:
KeyError: 'Category'
Appreciate any help in advance!
edit: callback graph is showing an unwanted callback, I don't want graph update to be triggered until the options are updated (i.e. the path on the right). is there any way I can prevent this? callback graph
ANSWER
Answered 2021-Apr-16 at 01:20So I have a workaround, I'm sure there is a better solution but this is working as expected. I believe the graph update_graph
function is being triggered after the game dropdown is updated, but before the options are updated, resulting in the filter on wrcombo_
producing a blank table. After the 2nd callback, the error was fixing itself as the platform is updated and the table can filter correctly. Introducing a check if the table is empty allows me to decide whether or not to refresh the graph, as below:
def update_graph(game_slct, plat_slct):
wrcombo_ = wrcombo.copy()
wrcombo_ = wrcombo_[wrcombo_['Game']==game_slct]
wrcombo_ = wrcombo_[wrcombo_['Platform']==plat_slct]
if len(wrcombo_) != 0:
print(wrcombo_)
wrfig = px.line(wrcombo_, x='Date', y='Time', color='Category', custom_data=['Runner', 'Game', 'Notes', 'Category'], height=600)
wrfig.update_traces(
mode="markers+lines",
hovertemplate='<b>%{customdata[0]}</b><br>Time: %{y|%H:%M:%S} <br>Achieved on: %{x|%e %b %Y} <br>Notes: %{customdata[2]}'
)
return wrfig
else:
return dash.no_update
As I mentioned, not sure this is optimal, as I am still having to filter the table first - so please let me know if there is a better way to do this. There is no need for the 3rd callback to trigger until the second one has, so disabling that is probably the missing piece of the puzzle.
QUESTION
Why does group by statement do not return correct rows?
Asked 2021-Mar-10 at 14:06I'm going through a tutorial and I can't understand why my query is not working.
I have 2 tables :
authors
id | name |
---|---|
1 | JK Rowling |
2 | Stephen King |
3 | Agatha Christie |
4 | Dr Seuss |
books
id | title | author_id |
---|---|---|
1 | Chamber of Secrets | 1 |
2 | Prizoner of Azkaban | 1 |
3 | The Dark Tower | 2 |
4 | Murder at the Links | 3 |
5 | Affait at Styles | 3 |
6 | Cat in the hat | 4 |
The task was to write a query that would print an author's name and the number of books they have authored.
My solution was this one:
SELECT name, COUNT(*)
FROM books
JOIN authors ON books.author_id = authors.id
GROUP BY author_id
However, in the result there is no name row. I know that the correct solution is to GROUP BY name
, however I can't understand why I can't group by author_id
? Thanks for your help.
ANSWER
Answered 2021-Feb-26 at 23:27First, you should write your query with qualified column references so it is easier to follow:
SELECT a.name, COUNT(*)
FROM books b JOIN
authors a
ON b.author_id = a.id
GROUP BY b.author_id;
Why doesn't this work? Clearly the SELECT
and GROUP BY
columns are different! They are not even from the same table.
The following might work:
SELECT a.name, COUNT(*)
FROM books b JOIN
authors a
ON b.author_id = a.id
GROUP BY a.id;
This would work if authors.id
is declared to be the primary key or unique
-- which is quite likely. This works because of a capability called functional dependence, which alls for any column to be referenced when a unique or primary key is in a GROUP BY
key.
However, if there is no such explicit declaration, then you need a.name
in the GROUP BY
clause.
QUESTION
Center element on window using transform
Asked 2021-Feb-23 at 09:26I'm trying to center a card element when it is clicked, to highlight it and separate if from the other cards, using CSS transforms. I know CSS transform is relative to the element's location, but I have to use transform and not top/left to avoid repositioning of the other cards. I've tried to calculate the correct offset using JavaScript, like so:
const cardRect = cardElement.getBoundingClientRect();
const offsetX = window.innerWidth / 2 - cardRect.x - cardRect.width / 2;
const offsetY = window.innerHeight / 2- cardRect.y - cardRect.height / 2;
However that did not work, because the bounding client rect changes all the time, as I have a scale(1.1) on card hover.
So how can I move the clicked card to the center, without offsetting all the other ones?
The cards are created like so in the HTML:
<div class='container'>
<div class='movie'>
<img :src='/images/1.png'>
<h3>Harry Potter and the Sorcerer's Stone</h3>
</div>
<div class='movie'>
<img :src='/images/2.png'>
<h3>Harry Potter and the Chamber of Secrets</h3>
</div>
<div class='movie'>
<img :src='/images/3.png'>
<h3>Harry Potter and the Prisoner of Azkaban</h3>
</div>
etc...
</div>
And everything is styled like so:
.container {
display: flex;
flex-flow: row wrap;
}
.movie {
width: min-content;
flex: 1;
}
.movie:not(.selected-movie):hover { /* .selected-movie is a class applied to the clicked card */
transform: scale(1.1);
box-shadow: 10px 10px 32px 0px rgba(0,0,0,0.4),
-10px -10px 32px 0px rgba(0,0,0,0.4);
}
.selected-movie {
transform: translate(offsetX, offsetY); /* Here are the offsets needed */
flex: 0;
display: grid;
grid-template-areas:
'poster title'
'poster description';
}
Here is a JSFiddle showing the problem: https://jsfiddle.net/u6tpbjna/5/
ANSWER
Answered 2021-Feb-22 at 23:15Some of your other CSS styles for .selected-movie
were throwing off the un-selected cards' styles when the clicked movie is selected, so I've temporarily commented out those styles. Regardless, I believe this should answer the question you're asking about the using those offsets in the CSS.
This is a great opportunity to use CSS variables, which you can set on pageload and window resize using JavaScript. From there, everything else can be done in CSS.
See below:
const cards = Array.from(document.querySelectorAll('.movie'));
const setCardOffsets = () => {
for (card of cards) {
const cardRect = card.getBoundingClientRect();
const cardOffsetX = window.innerWidth / 2 - cardRect.x - cardRect.width / 2;
const cardOffsetY = window.innerHeight / 2- cardRect.y - cardRect.height / 2;
card.style.setProperty('--offset-x', cardOffsetX + "px");
card.style.setProperty('--offset-y', cardOffsetY + "px");
}
}
setCardOffsets();
window.onresize = setCardOffsets;
document.addEventListener('click', e => {
if (e.target && e.target?.matches('.movie, .movie *')) {
const clickedCard = e.target.matches('.movie') ? e.target : e.target.closest('.movie');
if (clickedCard.classList.contains('selected-movie')) {
clickedCard.classList.remove('selected-movie');
return;
}
cards.forEach(card => card.classList.remove('selected-movie'));
clickedCard.classList.add('selected-movie');
}
});
.container {
display: flex;
flex-flow: row wrap;
}
.movie {
transform: scale(1) translate(0px, 0px);
width: min-content;
flex: 1;
position: relative;
transition: all 0.2s ease-out;
}
.movie:not(.selected-movie):hover {
transform: scale(1.1) translate(0px, 0px);
box-shadow: 10px 10px 32px 0px rgba(0,0,0,0.4),
-10px -10px 32px 0px rgba(0,0,0,0.4);
z-index: 2;
}
.selected-movie {
transform: scale(1.1) translate(var(--offset-x), var(--offset-y));
/*flex: 0;
display: grid;
grid-template-areas:
'poster title'
'poster description';*/
z-index: 1;
}
<div class='container'>
<div class='movie'>
<img src='/images/1.png'>
<h3>Harry Potter and the Sorcerer's Stone</h3>
</div>
<div class='movie'>
<img src='/images/2.png'>
<h3>Harry Potter and the Chamber of Secrets</h3>
</div>
<div class='movie'>
<img src='/images/3.png'>
<h3>Harry Potter and the Prisoner of Azkaban</h3>
</div>
</div>
I hope this helps! Let me know if you have any questions about my implementation of this.
QUESTION
How do I create a table that can be filled with data from a data set randomly?
Asked 2020-Dec-31 at 02:33I'm trying to create a random movie generator. I've already created a generator that displays a new movie after a button is clicked. But I want to create a table that will display more information about each movie that is generated, that is, the director, genre, year etc. I want this information to be generated into a table each time and the correct data to be under the correct heading in the table.
Example of how the data would look
HTML so far:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<link rel="stylesheet" href="movie.css">
<title>Movie Generator</title>
</head>
<body><div class="container">
<div class="row flex-top justify-content-center">
<header class="border shadow">
<h1>Movie Generator</h1>
</header>
</div>
<div class="row flex-top justify-content-center">
<button id="button" class="btn-large new-movie-button" onClick="getMovie()">New Movie</button>
</div>
<div class="row justify-content-center">
<main class="card">
<p class="movie card-body center" id="newMovieSection"></p>
</main>
</div>
</div>
<script src="movie.js"></script>
</body>
</html>
CSS so far:
header {
padding: 2em;
background-color: black;
margin-top: 2em;
text-align: center;
color: white;
}
.movie {
font-size: 2em;
}
.btn-large {
margin: 0.5em
}
.card {
text-align: center;
width: 45em;
}
.new-movie-button{
background-color: rgb(77, 87, 97);
border-color: black;
color: white;
}
button:hover {
background-color: rgb(142, 155, 168);
color: white;
}
JavaScript so far:
var movies = [
"Twilight",
"The Twilight Saga: New Moon",
"The Twilight Saga: Eclipse",
"The Twilight Saga: Breaking Dawn - Part 1",
"The Twilight Saga: Breaking Dawn - Part 2",
"Star Wars: Episode IV - A New Hope ",
"Star Wars: Episode V - The Empire Strikes Back",
"Star Wars: Episode VI - Return of the Jedi",
"Star Wars: Episode I - The Phantom Menace",
"Star Wars: Episode II - Attack of the Clones",
"Star Wars: Episode III - Revenge of the Sith",
"Star Wars: Episode VII - The Force Awakens ",
"Star Wars: Episode VIII - The Last Jedi ",
"Star Wars: The Rise of Skywalker",
"Rogue One: A Star Wars Story",
"Iron Man ",
"Iron Man 2",
"Iron Man 3",
"The Incredible Hulk",
"Thor",
"Thor: The Dark World",
"Thor: Ragnarok",
"Captian America: The First Avenger ",
"Captian America: The Winter Soldier",
"Captian America: Civil War",
"Avengers Assemble ",
"Avengers: Age of Ultron ",
"Avengers: Infinity War",
"Avengers: Endgame",
"Black Panther ",
"Doctor Strange ",
"Ant-Man",
"Ant-Man and the Wasp",
"Spider-Man: Homecoming ",
"Spider-Man: Far from Home",
"Guardians of the Galaxy ",
"Guardians of the Galaxy Vol.2",
"Harry Potter and the Philosopher's Stone ",
"Harry Potter and the Chamber of Secrets ",
"Harry Potter and the Prisoner of Azkaban ",
"Harry Potter and the Goblet of Fire ",
"Harry Potter and the Order of the Phoenix ",
"Harry Potter and the Half-Blood Prince ",
"Harry Potter and the Deathly Hallows: Part 1 ",
"Harry Potter and the Deathly Hallows: Part 2",
"The Lord of the Rings: The Fellowship of the Ring ",
"The Lord of the Rings: The Two Towers ",
"The Lord of the Rings: The Return of the King ",
"The Hobbit: An Unexpected Journey ",
"The Hobbit: The Desolation of Smaug ",
"The Hobbit: The Battle of Five Armies ",
"Spider-Man",
"Spider-Man 2",
"Spider-Man 3",
"Mission: Impossible ",
"Mission: Impossible II",
"Mission: Impossible III",
"Mission: Impossible - Ghost Protocol",
"Mission: Impossible - Rogue Nation ",
"Mission: Impossible - Fallout ",
"Rise of the Planet of the Apes",
"Dawn of the Planet of the Apes",
"War for the Planet of the Apes",
"The Bourne Identity ",
"The Bourne Supremacy",
"The Bourne Ultimatum ",
"The Bourne Legacy",
"Jason Bourne ",
"The Amazing Spider-Man ",
"The Amazing Spider-Man 2",
"Jurassic Park",
"The Lost World: Jurassic Park",
"Jurassic Park III",
"Jurassic World",
"Jurassic World: Fallen Kingdom",
"Jumanji",
"Jumanji: Welcome to the Jungle",
"Jumanji: The Next Level",
"The Fast and the Furious ",
"2 Fast 2 Furious",
"The Fast and the Furious: Tokyo Drift ",
"Fast & Furious",
"Fast & Furious 5",
"Fast & Furious 6",
"Fast & Furious 7",
"Fast & Furious 8",
"Fast & Furious: Hobbs & Shaw",
"Transformers",
"Transformers: Revenge of the Fallen",
"Transformers: Dark of the Moon",
"Transformers: Age of Extinction",
"Transformers: The Last Knight ",
"X-Men",
"X2",
"X-Men: The Last Stand",
"X-Men Origins: Wolverine ",
"X-Men: First Class",
"The Wolverine ",
"X-Men: Days of Future Past",
"Logan",
]
function getMovie() {
var randomNumber = Math.floor(Math.random() * movies.length);
document.getElementById("newMovieSection").innerHTML = movies[randomNumber];
}
ANSWER
Answered 2020-Dec-31 at 02:33It looks like you are 90% of the way there already.
All you need to do is replace your paragraph with a table that's organized how you want, then you need to update multiple table cells every time you click the button instead of just updating the one paragraph.
How you update the table cells depends on how the data is stored.
For example, if you had all the titles in one array and all the directors in another array and the years in a third array, you'd have to update one cell with titlesArray[randomNumber]
and another cell with directorsArray[randomNumber]
and another with yearsArray[randomNumber]
— and you'd have to make sure the movies were in order in each array and nothing was missing anywhere.
However, if at all possible, the easier solution is to store each movie's data as an object. This is a perfect use case.
Your array of strings would simply become an array of objects. You would get a new random number for the index of the array, then you'd reference the properties of the object at that index for the particulars of that movie.
Simple example here that you can build on:
const movies = [
{
title: 'Star Wars Episode IV: A New Hope',
director: 'George Lucas',
year: '1977',
},
{
title: 'Mission: Impossible III',
director: 'J. J. Abrams',
year: '2006',
},
{
title: 'Spider-Man 2',
director: 'Sam Raimi',
year: '2004',
}
];
const titleCell = document.getElementById('newMovieTitle');
const directorCell = document.getElementById('newMovieDirector');
const yearCell = document.getElementById('newMovieYear');
function getMovie() {
const randomNumber = Math.floor(Math.random() * movies.length);
const newMovie = movies[randomNumber];
titleCell.textContent = newMovie.title;
directorCell.textContent = newMovie.director;
yearCell.textContent = newMovie.year;
}
<table>
<thead>
<tr>
<th>Title</th>
<th>Director</th>
<th>Year</th>
</tr>
</thead>
<tbody>
<tr>
<td id="newMovieTitle"></td>
<td id="newMovieDirector"></td>
<td id="newMovieYear"></td>
</tr>
</tbody>
</table>
<button id="button" class="btn-large new-movie-button" onClick="getMovie()">New Movie</button>
QUESTION
JAVA - Difficulty scanning in a TXT file containign a mix of different information
Asked 2020-Dec-07 at 21:33I have a text file containing a list of names and a list of books in this form:
5
Prisoner Azkaban
J. k. Rowling
Eragon
Christopher Paolini
Ulysses
James Joyce
Of mice and men
John Steinbeck
War and peace
Leo Tolstoy
4
Craig David
Isabel Campbell
Lee Rinaldo
Bethany Waters
The numbers tell you how many"objects" come after the number, starting with a cycle of book name > author, then this pattern stops repeating for the users section where user names are listed.
Here is my attempt at the code:
Scanner inFile = new Scanner(new FileReader("C:\\Users\\finla\\IdeaProjects\\Untitled1\\src\\books2.txt"));
int numberOfBooks = inFile.nextInt();
for (int i= 0; i <= numberOfBooks; i++){
String bookName = inFile.nextLine();
System.out.println("Book name: " + bookName);
String bookAuthor = inFile.nextLine();
System.out.println("Book author: " + bookAuthor);
}
int numberOfUsers = inFile.nextInt();
for (int i= 0; i <= numberOfUsers; i++){
String userName = inFile.nextLine();
System.out.println("User name: " + userName);
}
Here is the output:
Book name:
Book author: Prisoner Azkaban
Book name: J. k. Rowling
Book author: Eragon
Book name: Christopher Paolini
Book author: Ulysses
Book name: James Joyce
Book author: Of mice and men
Book name: John Steinbeck
Book author: War and peace
Book name: Leo Tolstoy
Book author: 4
The book author label i in the wrong place. The loop shouldn't print out the 4 at the end. I would like to be able to read in the list of people at the end. Do you have any suggestions as to why my code won't work? I've tried using next() as opposed to nextline(), but this doesn't solve the problem and only takes the first string from each line.
ANSWER
Answered 2020-Dec-07 at 21:16You want your for loops to go from 0 to < the count or else from 1 to the count as in:
for (int i= 0; i < numberOfBooks; i++){
}
You had <=, which means you consumed 1 line too many.
QUESTION
Is it possible to remove cascading CTEs in this query when trying to add ROW_NUMBER
Asked 2020-Oct-22 at 17:01I have a reading list in a database. I use this as a base for personal training It has grown in functionality over time, so please forgive the odd structure.
I'm trying to add paging to this query but I'm having an issue trying to add the ROW_NUMBER method because of how I implemented "Ord" in my query.
I was able to get this working utilizing cascading Common Table Expressions but feel there must be a better way.
Here is what the output should do when displaying all books by an author:
Setup
CREATE TABLE #books(
ID int,
Author nvarchar(100),
Title nvarchar(100),
Series nvarchar(100),
BookNumber int,
DateCompleted smalldatetime,
[Status] int
)
INSERT INTO #books (ID, Author, Title, Series, BookNumber, DateCompleted, Status) VALUES
(1004,'J. K. Rowling','Harry Potter and the Chamber of Secrets','Harry Potter',2,'1-Mar-2020',1),
(1045,'J. K. Rowling','Harry Potter and the Prisoner of Azkaban','Harry Potter',3,NULL,2),
(1047,'J. K. Rowling','Harry Potter and the Goblet of Fire','Harry Potter',4,NULL,3),
(1048,'J. K. Rowling','Harry Potter and the Order of the Pheonix','Harry Potter',5,NULL,4),
(1049,'J. K. Rowling','Harry Potter and the Half Blood Prince','Harry Potter',6,NULL,NULL),
(1051,'J. K. Rowling','Harry Potter and the Deathly Hallows','Harry Potter',7,NULL,NULL),
(1185,'J. K. Rowling','Harry Potter and the Sorcerer''s Stone','Harry Potter',1,'1-Jan2020',NULL)
DECLARE @Author nVarChar(100) = 'J. K. Rowling'
DECLARE @Year nVarChar(5) = ''
DECLARE @PageNum INT = 1;
DECLARE @PageSize INT = 10;
Original Query
SELECT b.ID,
b.Title,
b.Series,
b.BookNumber,
ISNULL(b.Series, '') + ISNULL(' (book ' + LTRIM(STR(b.BookNumber)) + ')','') as SeriesDesc,
b.Author,
Case
When b.[Status] = 1 Then 'Completed'
When b.[Status] = 2 Then 'Reading'
When b.[Status] > 2 Then 'Next'
End as StatusDesc,
b.[Status],
b.DateCompleted,
CASE
WHEN b.DateCompleted is not NULL THEN 0
WHEN b.[Status] is not NULL THEN 5
WHEN b.[Status] is NULL THEN 9
END as Ord
FROM #books b
WHERE (((b.Author = @Author OR @Author = '') AND b.DateCompleted is not NULL) AND
(Year(b.DateCompleted) = @Year OR @Year = ''))
OR
(b.Author = @Author AND b.DateCompleted is NULL AND @Year = '')
ORDER BY Ord, [Status], DateCompleted, Series, BookNumber
This is the only way I've been able to get this to work as expected.
;WITH Step1 AS
(SELECT b.ID,
b.Title,
b.Series,
b.BookNumber,
ISNULL(b.Series, '') + ISNULL(' (book ' + LTRIM(STR(b.BookNumber)) + ')','') as SeriesDesc,
b.Author,
Case
When b.[Status] = 1 Then 'Completed'
When b.[Status] = 2 Then 'Reading'
When b.[Status] > 2 Then 'Next'
End as StatusDesc,
b.[Status],
b.DateCompleted,
CASE
WHEN b.DateCompleted is not NULL THEN 0
WHEN b.[Status] is not NULL THEN 5
WHEN b.[Status] is NULL THEN 9
END as Ord
FROM #books b
WHERE (((b.Author = @Author OR @Author = '') AND b.DateCompleted is not NULL) AND
(Year(b.DateCompleted) = @Year OR @Year = ''))
OR
(b.Author = @Author AND b.DateCompleted is NULL AND @Year = '')
),
Step2 AS
(SELECT ID, Title, Series, BookNumber, SeriesDesc, Author, StatusDesc, [Status], DateCompleted, Ord,
ROW_NUMBER() OVER (ORDER BY Ord, [Status], DateCompleted, Series, BookNumber) as RowNum
FROM Step1)
SELECT
ID, Title, Series, BookNumber, SeriesDesc, Author, StatusDesc, [Status], DateCompleted, Ord, RowNum
FROM Step2
WHERE @PageNum = 0 OR (RowNum BETWEEN (@PageNum - 1) * @PageSize + 1
AND @PageNum * @PageSize)
ORDER BY RowNum
Expected Output
|---------------------|-------------------------------------------|---------------------|------------------|-----------------------|------------------|---------------------|------------------|---------------------|------------------|
| ID | Title | Series | BookNumber | SeriesDesc | Author | StatusDesc | Status | DateCompleted | Ord |
|---------------------|-------------------------------------------|---------------------|------------------|-----------------------|------------------|---------------------|------------------|---------------------|------------------|
| 1185 | Harry Potter and the Sorcerer's Stone | Harry Potter | 1 | Harry Potter (book 1) | J. K. Rowling | NULL | NULL | 2020-01-01 00:00:00 | 0 |
| 1185 | Harry Potter and the Chamber of Secrets | Harry Potter | 2 | Harry Potter (book 2) | J. K. Rowling | Completed | 1 | 2020-03-01 00:00:00 | 0 |
| 1185 | Harry Potter and the Prisoner of Azkaban | Harry Potter | 3 | Harry Potter (book 3) | J. K. Rowling | Reading | 2 | NULL | 5 |
| 1185 | Harry Potter and the Goblet of Fire | Harry Potter | 4 | Harry Potter (book 4) | J. K. Rowling | Next | 3 | NULL | 5 |
| 1185 | Harry Potter and the Order of the Pheonix | Harry Potter | 5 | Harry Potter (book 5) | J. K. Rowling | Next | 4 | NULL | 5 |
| 1185 | Harry Potter and the Half Blood Prince | Harry Potter | 6 | Harry Potter (book 6) | J. K. Rowling | NULL | NULL | NULL | 9 |
| 1185 | Harry Potter and the Deathly Hallows | Harry Potter | 7 | Harry Potter (book 7) | J. K. Rowling | NULL | NULL | NULL | 9 |
|---------------------|-------------------------------------------|---------------------|------------------|-----------------------|------------------|---------------------|------------------|---------------------|------------------|
ANSWER
Answered 2020-Oct-22 at 17:01then how about offset fetch :
SELECT b.ID,
b.Title,
b.Series,
b.BookNumber,
ISNULL(b.Series, '') + ISNULL(' (book ' + LTRIM(STR(b.BookNumber)) + ')','') as SeriesDesc,
b.Author,
Case
When b.[Status] = 1 Then 'Completed'
When b.[Status] = 2 Then 'Reading'
When b.[Status] > 2 Then 'Next'
End as StatusDesc,
b.[Status],
b.DateCompleted,
CASE
WHEN b.DateCompleted is not NULL THEN 0
WHEN b.[Status] is not NULL THEN 5
WHEN b.[Status] is NULL THEN 9
END as Ord
FROM #books b
WHERE (((b.Author = @Author OR @Author = '') AND b.DateCompleted is not NULL) AND
(Year(b.DateCompleted) = @Year OR @Year = ''))
OR
(b.Author = @Author AND b.DateCompleted is NULL AND @Year = '')
ORDER BY Ord, [Status], DateCompleted, Series, BookNumber
OFFSET @PageSize*@PageNum ROWS
FETCH NEXT @PageSize ROWS ONLY
@PageNum should start from 0
QUESTION
Is there any way to use img alt as tooltip?
Asked 2020-Oct-20 at 03:21I have a page with many images, here is an example:
<section>
<div><img src="capas/livro1.jpg" alt="Harry Potter e a Pedra Filosofal"></div>
<div><img src="capas/livro2.jpg" alt="Harry Potter e a Câmara Secreta"></div>
<div><img src="capas/livro3.jpg" alt="Harry Potter e o Prisioneiro de Azkaban"></div>
<div><img src="capas/livro4.jpg" alt="Harry Potter e o Cálice de Fogo"></div>
<div><img src="capas/livro5.jpg" alt="Harry Potter e o Enigma do Príncipe"></div>
<div><img src="capas/livro6.jpg" alt="Harry Potter e a Ordem da Fênix"></div>
<div><img src="capas/livro7.jpg" alt="Harry Potter e as Relíquias da Morte"></div>
<div><img src="capas/livro8.jpg" alt="Pai Rico, Pai Pobre"></div>
<div><img src="capas/livro9.jpg" alt="Quem Mexeu no Meu Queijo?"></div>
<div><img src="capas/livro10.jpg" alt="O Guia do Pão Duro"></div>
.
.
.
</section>
I'd like to show tooltip without using title
. Is it possible using only HTML, CSS or JavaScript?
Something like this:
Thanks.
ANSWER
Answered 2020-Oct-20 at 01:11Check out this site on how to create tooltips using only HTML/CSS
Here's a snippet from the site:
<style>
/* Tooltip container */
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
}
/* Tooltip text */
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
/* Position the tooltip text - see examples below! */
position: absolute;
z-index: 1;
}
/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
visibility: visible;
}
</style>
<div class="tooltip">Hover over me
<span class="tooltiptext">Tooltip text</span>
</div>
QUESTION
How to perform HTTP PUT Request by reading values from CSV in JMeter?
Asked 2020-Aug-19 at 14:29how can I set up HTTP Request Sampler for HTTP PUT method in JMeter so it can read data from CSV file using CSV Data Set Config?
In my scenario I'm using Concurrency Thread Group with the following parameters:
This is my CSV Data Set Config setup:
(Java) Types of Variable Names are: bookId:Long, title:String, price:double, amount:int, authors: Set , categories: Set , isDeleted:boolean
This is my HTTP Request Sampler setup:
...and this is content of my bookCollection10Items.csv file where quoted values are Strings, and the ones in angle brackets [] are arrays
of values (as I'm updating Book that has Many-To-Many relationship with Categories/Authors):
1,"Harry Potter and Magic Stone",39.99,2500,[4],7,11,false
2,"Murder on the Orient Express",[19.98,500500],1,9,false
3,"The Murder of Roger Ackroyd",19.99,1500,1,[7,9],false
4,"Harry Potter and the Chamber of Secrets",24.99,0,4,[7,9],true
5,"Harry Potter and the Prisoner of Azkaban",17.99,1200,4,7,false
6,"The Da Vinci Code",29.99,700,8,10,false
7,"Inferno",22.50,950,8,10,false
11,"War and Peace",31.99,300,5,8,false
14,"The Trial",27.99,450,6,9,false
15,"IT",16.50,0,2,5,true
What I want to achieve is that each Thread(i.e. User) to select one item from "bookCollection10Items.csv" file in a round-robin fashion and update it for a given bookId using "All Threads" as Sharing Mode option.
Any advice/suggestion is greatly appreciated.
ANSWER
Answered 2020-Aug-18 at 15:53JMeter's built-in CSV Data Set Config is reading lines from the CSV file sequentially so each user will get the next line on each iteration.
If you need to read a random line (however I don't think it's a good idea as I believe tests need to be repeatable) you will need to go for some plugins like:
Both can be installed using JMeter Plugins Manager
QUESTION
Why is my code only showing one JK Rowling book? It should be working?
Asked 2020-Aug-13 at 22:42I want it to show all of the JK Rowling Harry Potter series books but for some reason it only show the first one. How do I fix this? It seems there is a bug in the select statement but i cant seem to find out what it is. Can some one help? I am just gonna type random words in quotations because stackoverflow says the my post is mostly code and i need to add more details.
create table authors (id integer primary key autoincrement, fullname TEXT, language TEXT, birthdate integer, deathdate integer, books integer, notes text);
insert into authors (fullname, language, birthdate, deathdate, books) values ("William Shakespeare", "English", 1564, 1616, 39);
insert into authors (fullname, language, birthdate, books) values ("J. K. Rowling", "English", 1965, 15);
insert into authors (fullname, language, birthdate, books, notes) values ("Gordon Korman", "English", 1963, 82, "Only favorite books");
create table books (author_id integer, name text, publish_year integer);
insert into books VALUES (1, "The Two Gentlemen of Verona", 1589);
insert into books VALUES (1, "The Comedy of Errors", 1589);
insert into books VALUES (1, "Titus Andronicus", 1591);
insert into books VALUES (1, "The Taming of The Shrew", 1593);
insert into books VALUES (1, "Love Labours Lost", 1589);
insert into books VALUES (1, "Romeo and Juliet", 1594);
insert into books VALUES (1, "A Midsummer's Night's Dream", 1595);
insert into books VALUES (1, "King John", 1595);
insert into books VALUES (1, "The Merchant of Venice", 1596);
insert into books VALUES (1, "The Merry Wives of Windsor", 1597);
insert into books VALUES (1, "Much Ado About Nothing", 1598);
insert into books VALUES (1, "As You Like It", 1599);
insert into books VALUES (1, "Julius Caesar", 1599);
insert into books VALUES (1, "Troilus and Cressida", 1600);
insert into books VALUES (1, "Hamlet", 1600);
insert into books VALUES (1, "Twelfth Night or What You Will", 1601);
insert into books VALUES (1, "All's Well That Ends Well", 1603);
insert into books VALUES (1, "Measure for Meausre", 1603);
insert into books VALUES (1, "Othello", 1603);
insert into books VALUES (1, "Timon of Athens", 1604);
insert into books VALUES (1, "King Lear", 1605);
insert into books VALUES (1, "Macbeth", 1606);
insert into books VALUES (1, "Pericles", 1607);
insert into books VALUES (1, "Antony and Cleopatra", 1608);
insert into books VALUES (1, "Coriolanus", 1608);
insert into books VALUES (1, "Cymbeline", 1609);
insert into books VALUES (1, "The Winter's Tale", 1609);
insert into books VALUES (1, "The Tempest", 1610);
insert into books VALUES (1, "The Two Noble Kinsmen", 1611);
insert into books VALUES (1, "Cardenio", 1612);
insert into books VALUES (1, "Henry VIII", 1613);
insert into books VALUES (1, "Henry V", 1599);
insert into books VALUES (1, "Richard III", 1593);
insert into books VALUES (1, "Richard II", 1595);
insert into books VALUES (2, "Fantastic Beasts and Where to Find Them", 2001);
insert into books VALUES (2, "Quidditch Through the Ages", 2001);
insert into books VALUES (2, "The Tales of Beedle the Bard", 2008);
insert into books VALUES (2, "Hogwarts: An Incomplete & Unreliable Guide", 2016);
insert into books VALUES (2, "Short Stories from Hogwarts of Heroism, Hardship and Dangerous Hobbies", 2016);
insert into books VALUES (2, "Short Stories from Hogwarts of Power, Politics and Pesky Poltergeists", 2016);
insert into books VALUES (3, "Losing Joe's Place", 1990);
insert into books VALUES (3, "The Sixth Grade Nickname Game", 1998);
insert into books VALUES (3, "Schooled", 2007);
insert into books VALUES (3, "The Juvie Three", 2008);
insert into books VALUES (3, "Ungifted", 2012);
insert into books VALUES (3, "Restart", 2018);
insert into books VALUES (3, "Whatshisface", 2018);
insert into books VALUES (3, "The Unteachbles", 2019);
insert into books VALUES (3, "Notorius", 2020);
select authors.fullname as Author, books.name as "Name", books.publish_year as "Year Published" from books left outer join authors on books.author_id = authors.id;
create table series (id integer primary key autoincrement, series_id text, name_book text);
insert into series (series_id, name_book) VALUES("1-1", "Henry VI, Part One");
insert into series (series_id, name_book) VALUES("1-1", "Henry VI, Part Two");
insert into series (series_id, name_book) VALUES("1-1", "Henry VI, Part Three");
insert into series (series_id, name_book) VALUES("1-2", "Henry IV, Part One");
insert into series (series_id, name_book) VALUES("1-2", "Henry IV, Part Two");
insert into series (series_id, name_book) VALUES("2-1", "Harry Potter and the Philosopher's Stone");
insert into series (series_id, name_book) VALUES("2-2", "Harry Potter and the Chamber of Secrets");
insert into series (series_id, name_book) VALUES("2-3", "Harry Potter and the Priosner of Azkaban");
insert into series (series_id, name_book) VALUES("2-4", "Harry Potter and the Goblet of Fire");
insert into series (series_id, name_book) VALUES("2-5", "Harry Potter and the Order of the Phoenix");
insert into series (series_id, name_book) VALUES("2-6", "Harry Potter and the Half-Blood Prince");
insert into series (series_id, name_book) VALUES("2-7", "Harry Potter and the Deathly Hallows");
insert into series (series_id, name_book) VALUES("2-8", "Harry Potter and the Cursed Child, Parts I & II");
insert into series (series_id, name_book) VALUES("3-1", "Slacker");
insert into series (series_id, name_book) VALUES("3-1", "Level 13");
insert into series (series_id, name_book) VALUES("3-2", "Masterminds");
insert into series (series_id, name_book) VALUES("3-2", "Criminal Destiny");
insert into series (series_id, name_book) VALUES("3-2", "Payback");
insert into series (series_id, name_book) VALUES("3-3", "The Hypnotists");
insert into series (series_id, name_book) VALUES("3-3", "Memory Maze");
insert into series (series_id, name_book) VALUES("3-3", "The Dragonfly Effect");
insert into series (series_id, name_book) VALUES("3-4", "Ungifted");
insert into series (series_id, name_book) VALUES("3-4", "Supergifted");
create table series_id (author_id integer, series_id text, series_name text, books_in_series integer, start_year integer);
insert into series_id VALUES (1, "1-1", "Henry VI", 3, 1590);
insert into series_id VALUES (1, "1-2", "Henry IV", 2, 1596);
insert into series_id VALUES (2, "2-1", "Harry Potter", 8, 1997);
insert into series_id VALUES (3, "3-1", "Slacker", 2, 2016);
insert into series_id VALUES (3, "3-2", "Masterminds", 3, 2015);
insert into series_id VALUES (3, "3-3", "The Hypnotists", 3, 2013);
insert into series_id VALUES (3, "3-4", "Ungifted", 2, 2012);
select authors.fullname, series_id.series_name, series_id.books_in_series, series_id.start_year, series.id, series.name_book from series_id join authors on series_id.author_id = authors.id join series on series_id.series_id = series.series_id order by series.id;
ANSWER
Answered 2020-Aug-13 at 22:41There is only 1 join for author_id = 2
, and it's on series_id = "2-1"
:
insert into series_id VALUES (2, "2-1", "Harry Potter", 8, 1997);
insert into series (series_id, name_book) VALUES("2-1", "Harry Potter and the Philosopher's Stone");
It looks like you are cramming multiple things into series_id
, namely an actual series_id and a sequence within the series. I suggest you create separate columns for each concept.
See First Normal Form - Columns should contain only 1 value.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
HTTPS
https://github.com/azkaban/azkaban.git
CLI
gh repo clone azkaban/azkaban
SSH
git@github.com:azkaban/azkaban.git
Share this Page
See Similar Libraries in
See all related Kits
by apache
by n8n-io
by eip-work
by argoproj
by aosp-mirror
See all BPM Libraries
by azkaban Java
by azkaban CSS
by azkaban Java
See all Libraries by this author
by camunda
by eternita
by yin-bp
by spring-guides
by camunda
See all BPM Libraries
by OpenSecurityResearch
by camunda
by eternita
by yin-bp
by spring-guides
See all BPM Libraries
by camunda
by camunda
by yin-bp
by spring-guides
by camunda
See all BPM Libraries
by ncbi
by camunda
by camunda
by aiidateam
by adrobisch
See all BPM Libraries
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source