fjord | Fjord , F # programming language for the JVM | Runtime Evironment library
kandi X-RAY | fjord Summary
Support
Quality
Security
License
Reuse
- Main entry point
- Evaluate a string
- Display help
- Analyze an identifier
- Visits an application expression
- Gets the operator
- Define class
- Defines the class that loads the value
- Gets the operator
- Define class
- Visits a constant value
- Parses the value
- Gets the constraints
- Normalizes the given operator
- Returns the string representation of a symbolic operator
- Returns the string representation of a non - symbolic operator
- Generate code block
- Gets the type class
- Visits this node then visits each module elements
- Traverses the left and right operand
- Bootstrap a static call site
- Visits this node then calls the given visitor
- Returns the string representation of the open button
- Gets the expression
- Returns the expression string
- Add an expression to the tree
- Returns a string representation of this constraint
- Sets the type - constraint list
fjord Key Features
fjord Examples and Code Snippets
Trending Discussions on fjord
Trending Discussions on fjord
QUESTION
I am trying to find difference in time between sailing and arrival for each IMO number.
IMO Name State Datetime
8300327 SILVER FJORD Arrival 13/08/2021 04:51
8300327 SILVER FJORD Sailing 13/08/2021 22:59
8300327 SILVER FJORD Arrival 20/08/2021 10:52
8300327 SILVER FJORD Sailing 20/08/2021 20:24
9340738 FRAMFJORD Arrival 19/08/2021 11:05
9340738 FRAMFJORD Sailing 20/08/2021 17:32
for above dataframe the output should be
IMO Name State Datetime Time_int
8300327 SILVER FJORD Arrival 13/08/2021 04:51
8300327 SILVER FJORD Sailing 13/08/2021 22:59 18:08:00
8300327 SILVER FJORD Arrival 20/08/2021 10:52
8300327 SILVER FJORD Sailing 20/08/2021 20:24 09:32:00
9340738 FRAMFJORD Arrival 19/08/2021 11:05
9340738 FRAMFJORD Sailing 20/08/2021 17:32 06:27:00
I have written below code for the calculation
def dwell_calc(df):
if (df['State'] == "Sailing"):
val = df['Datetime'].diff().dt.seconds.div(3600).fillna(0).reset_index()
return val
# data.sort_values(['IMO', 'Datetime'], inplace=True)
cond2=(data['State']=='Sailing')
data.loc[cond2, 'time_int'] = dwell_calc(data)
print(data['time_int'])
I am getting error:
if (df['State'] == "Sailing"):
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Please help with solution to find time interval using python
ANSWER
Answered 2021-Aug-31 at 19:55Try diff
after sort_values()
:
df.sort_values(["IMO", "Datetime"])
df.loc[df["State"]=="Sailing", "Time_int"] = df["Datetime"].diff()
>>> df
IMO Name State Datetime Time_int
0 8300327 SILVER FJORD Arrival 2021-08-13 04:51:00 NaT
1 8300327 SILVER FJORD Sailing 2021-08-13 22:59:00 0 days 18:08:00
2 8300327 SILVER FJORD Arrival 2021-08-20 10:52:00 NaT
3 8300327 SILVER FJORD Sailing 2021-08-20 20:24:00 0 days 09:32:00
4 9340738 FRAMFJORD Arrival 2021-08-19 11:05:00 NaT
5 9340738 FRAMFJORD Sailing 2021-08-20 17:32:00 1 days 06:27:00
QUESTION
I am using the Modal box to display some images, with a caption and a thumbnail section below.
The problem I am facing is that the thumbnail section works just fine for 6 or less than 6 images, I have to decrease the size of thumbnails if there are more images. Right now I have 10.
What I want to do is to have a horizontally scrollable thumbnail section. It can solve all my problems. I tried online, but I couldn't seem to make it.
Part of My Code :
The solution I found online was to add this to my CSS:
.row1 {
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
}
.column {
display: inline-block;
width: 16.66%;
}
This is not working, but it is surely doing something. When I use inspect elements, it shows me that the column is there, but I just can't see it. I have attached the screenshot below.
Just in case, I am attaching my entire Modal Code:
Entire Modal CSS:
/* The Modal (background) */
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 50px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
/* Enable scroll if needed */
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.8);
}
/* Modal Content */
.modal-content {
margin: auto;
display: block;
background-color: #f2f2f2;
border: none;
width: 100%;
height: 100%;
max-width: 1000px;
max-height: 70px;
}
/* The Close Button */
.close {
color: white !important;
position: absolute;
top: 10px;
right: 25px;
font-size: 30px !important;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #999 !important;
text-decoration: none;
cursor: pointer;
}
mySlides {
display: none;
}
.cursor {
cursor: pointer;
}
.prev,
.next {
cursor: pointer;
position: absolute;
top: 40%;
width: auto;
padding: 16px;
/* padding-right: 25px;*/
margin-top: -30px;
color: white;
font-weight: bold;
font-size: 20px;
border-radius: 0 10px 10px 0;
user-select: none;
-webkit-user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 10px 0 0 10px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover,
.next:hover {
color: #f2f2f2;
background-color: rgba(0, 0, 0, 0.4);
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* Container for image text */
.caption-container {
text-align: center;
background-color: #f2f2f2;
padding: 2px 16px;
color: #333;
}
.row1 {
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
}
.column {
display: inline-block;
width: 16.66%;
}
Thanks for your help!
ANSWER
Answered 2021-Jul-20 at 07:38I got it. The problem was with the container element. The "max-height" attribute was creating the problem. I just changed this :
.modal-content {
margin: auto;
display: block;
background-color: #f2f2f2;
border: none;
width: 100%;
height: 100%;
max-width: 1000px;
max-height: max-content; //THIS
}
QUESTION
I am trying to get multiple binding statements onto one combobox, but it is not working.
I have a tkinter window to enter data into a sql database with several dependent comboboxes to make the data entry easier in places that will cause fatal errors if the wrong thing is entered. The state name combobox will queue the state abbreviation in one combobox and another for national park names available in that state. The park chosen then triggers another combobox where the only option should be the park abbreviation. The problem I am having is with the binding of the state abbreviation and the park name comboboxes to the state combobox. They are in two separate statements, and I can only get one at a time to work. I have to comment out the state abbr bind in order to use the park name and park abbreviation comboboxes, or visa versa. Any ideas?
from tkinter import *
from tkinter import ttk
# list of states
states = ['Alaska', 'Arizona', 'Arkansas']
# dictionaries
STATE_DICT = {
'state_name': {
'AK': 'Alaska',
'AR': 'Arkansas',
'AZ': 'Arizona'}
}
PARKS_DICT = {
'state_name': {
'DENA': 'Alaska',
'GLBA': 'Alaska',
'KATM': 'Alaska',
'KEFJ': 'Alaska',
'HOSP': 'Arkansas',
'GRCA': 'Arizona',
'PEFO': 'Arizona',
'SAGU': 'Arizona'
},
'park_name': {
'DENA': 'Denali National Park',
'GLBA': 'Glacier Bay National Park',
'KATM': 'Katmai National Park',
'KEFJ': 'Kenai Fjords National Park',
'HOSP': 'Hot Springs National Park',
'GRCA': 'Grand Canyon National Park',
'PEFO': 'Petrified Forest National Park',
'SAGU': 'Saguaro National Park'}
}
root2 = Tk()
root2.title("data_entry_form")
root2.geometry("800x500")
state_name_label = Label(root2, text="State Name", width=20, font=("bold", 12),bd=1, relief="raised")
state_abbr_label = Label(root2, text="State Abbr", width=20, font=("bold", 12),bd=1, relief="raised")
park_name_label = Label(root2, text="Park Name", width=20, font=("bold", 12),bd=1, relief="raised")
park_abbr_label = Label(root2, text="Park Abbr", width=20, font=("bold", 12),bd=1, relief="raised")
nearest_city_label = Label(root2, text="Nearest City", width=20, font=("bold", 12),bd=1, relief="raised")
geo_location_label = Label(root2, text="Geo Location", width=20, font=("bold", 12),bd=1, relief="raised")
hike_name_label = Label(root2, text="Hike Name", width=20, font=("bold", 12),bd=1, relief="raised")
length_miles_label = Label(root2, text="Length in Miles", width=20, font=("bold", 12),bd=1, relief="raised")
elevation_gain_feet_label = Label(root2, text="Elevation in Feet", width=20, font=("bold", 12),bd=1, relief="raised")
nps_difficulty_rating_label = Label(root2, text="NPS Difficulty Rating", width=20, font=("bold", 12),bd=1, relief="raised")
route_type_label = Label(root2, text="Route Type", width=20, font=("bold", 12),bd=1, relief="raised")
# Data entry fields
hike_name_entry = Entry(root2,width=100)
nearest_city_entry = Entry(root2,width=50)
geo_location_entry = Entry(root2,width=50)
length_miles_entry = Entry(root2,width=50)
elevation_gain_feet_entry = Entry(root2,width=50)
# submit button
submitbutton = Button(root2, text='Submit New Hike!', width=20, bg="black", fg='white')
# comboboxes
def parks_list(e):
p=list()
x=list()
for key,value in PARKS_DICT['state_name'].items():
if value==state_combo.get():
p.append(key)
for k,v in PARKS_DICT['park_name'].items():
if k in p:
x.append(v)
park_combo.config(value=x)
def park_abb(e):
p=list()
for key,value in PARKS_DICT['park_name'].items():
if value==park_combo.get():
p.append(key)
park_abbr_combo.config(value=p)
def state_abb(e):
p=list()
for key,value in STATE_DICT['state_name'].items():
if value==state_combo.get():
p.append(key)
state_abbr_combo.config(value=p)
state_combo = ttk.Combobox(root2, value=states)
state_combo.current(0)
#state_combo.bind("<>", state_abb) #-have to # this out to get the other statement to work.
state_combo.bind("<>", parks_list)
state_abbr_combo = ttk.Combobox(root2, value=[" "])
state_abbr_combo.current(0)
park_combo = ttk.Combobox(root2, value=[" "])
park_combo.current(0)
park_combo.bind("<>", park_abb)
park_abbr_combo = ttk.Combobox(root2, value=[" "])
park_abbr_combo.current(0)
nps_difficulty_rating= ttk.Combobox(root2, value =range(1,6))
route_type_combo=ttk.Combobox(root2, value=['loop','out and back','point to point'])
# Grid placement
state_name_label.grid(row=1, column=0, padx=10, pady=10)
state_combo.grid(row=1, column=1, padx=10, pady=10)
state_abbr_label.grid(row=2, column=0, padx=10, pady=10)
state_abbr_combo.grid(row=2, column=1, padx=10, pady=10)
park_name_label.grid(row=3, column=0, padx=10, pady=10)
park_combo.grid(row=3, column=1, padx=10, pady=10)
park_abbr_label.grid(row=4, column=0, padx=10, pady=10)
park_abbr_combo.grid(row=4, column=1, padx=10, pady=10)
nearest_city_label.grid(row=5, column=0, padx=10, pady=10)
nearest_city_entry.grid(row=5, column=1, padx=10, pady=10)
geo_location_label.grid(row=6, column=0, padx=10, pady=10)
geo_location_entry.grid(row=6, column=1, padx=10, pady=10)
hike_name_label.grid(row=7, column=0, padx=10, pady=10)
hike_name_entry.grid(row=7, column=1, padx=10, pady=10)
length_miles_label.grid(row=8, column=0, padx=10, pady=10)
length_miles_entry.grid(row=8, column=1, padx=10, pady=10)
elevation_gain_feet_label.grid(row=9, column=0, padx=10, pady=10)
elevation_gain_feet_entry.grid(row=9, column=1, padx=10, pady=10)
nps_difficulty_rating_label.grid(row=10, column=0, padx=10, pady=10)
nps_difficulty_rating.grid(row=10, column=1, padx=10, pady=10)
route_type_label.grid(row=11, column=0, padx=10, pady=10)
route_type_combo.grid(row=11, column=1, padx=10, pady=10)
submitbutton.grid(row=12, column=1, padx=10, pady=10)
root2.mainloop()
ANSWER
Answered 2021-Apr-20 at 02:37While it's possible to do more than one binding, I see no advantage to doing so. Instead, create a function that calls the other functions.
def state_combo_changed(event):
state_abb(event)
parks_list(abb)
state_combo.bind("<>", state_combo_changed)
If you insist on doing two separate bindings you can set the add
attribute to True
:
state_combo.bind("<>", state_abb)
state_combo.bind("<>", parks_list, add=True)
QUESTION
const parks = [
{
id: 1,
name: "Acadia",
areaInSquareKm: 198.6,
location: { state: "Maine" },
},
{
id: 2,
name: "Canyonlands",
areaInSquareKm: 1366.2,
location: { state: "Utah" },
},
{
id: 3,
name: "Crater Lake",
areaInSquareKm: 741.5,
location: { state: "Oregon" },
},
{
id: 4,
name: "Lake Clark",
areaInSquareKm: 10602,
location: { state: "Alaska" },
},
{
id: 5,
name: "Kenai Fjords",
areaInSquareKm: 2710,
location: { state: "Alaska" },
},
{
id: 6,
name: "Zion",
areaInSquareKm: 595.9,
location: { state: "Utah" },
},
];
const users = {
"karah.branch3": {
visited: [1],
wishlist: [4, 6],
},
"dwayne.m55": {
visited: [2, 5, 1],
wishlist: [],
},
thiagostrong1: {
visited: [5],
wishlist: [6, 3, 2],
},
"don.kim1990": {
visited: [2, 6],
wishlist: [1],
},
};
I need to create a function that does this: This function returns all the usernames who have visited any park on the given user's wishlist.
getUsersForUserWishlist(users, "karah.branch3"); //> ["dwayne.m55"]
getUsersForUserWishlist(users, "dwayne.m55"); //> []
This is what I have so far but it doesn't work:
function getUsersForUserWishlist(users, userId) {
let wish = userId.wishlist;
return users[userId].visited.map((visited) => wish.includes(visited));
}
Please keep in mind: I just finished a section of my course that covers advanced functions (find, filter, map, some, every, forEach) and I'm supposed to use them to solve the problem.
ANSWER
Answered 2021-Apr-01 at 23:28Let's go over what you tried:
let wish = userId.wishlist;
Here, userId
is a string. A string has no property wishlist
. You need to get the user Object corresponding to that ID: users[userId].wishlist
. Just like you did on the second line:
users[userId].visited.map((visited) => wish.includes(visited));
However, map
is not the best method for what you want to achieve. You want to filter
the user names to keep only the ones that pass a condition. Which is that some
parks in the wishlist are included
in that user's list of visited parks:
const users= {
"karah.branch3": { visited: [1], wishlist: [4,6] },
"dwayne.m55": { visited: [2,5,1], wishlist: [] },
"thiagostrong1": { visited: [5], wishlist: [6,3,2] },
"don.kim1990": { visited: [2,6], wishlist: [1] }
};
function getUsersForUserWishlist(users, userId) {
const wishlist = users[userId].wishlist;
// Get all user names
return Object.keys(users)
// Filter them
.filter(
// If the wishlist has some elements which that user has visited
name => wishlist.some(park => users[name].visited.includes(park))
);
}
console.log(getUsersForUserWishlist(users, "karah.branch3")); //> ["don.kim1990"]
console.log(getUsersForUserWishlist(users, "dwayne.m55")); //> []
QUESTION
const parks = [
{
id: 1,
name: "Acadia",
areaInSquareKm: 198.6,
location: { state: "Maine" },
},
{
id: 2,
name: "Canyonlands",
areaInSquareKm: 1366.2,
location: { state: "Utah" },
},
{
id: 3,
name: "Crater Lake",
areaInSquareKm: 741.5,
location: { state: "Oregon" },
},
{
id: 4,
name: "Lake Clark",
areaInSquareKm: 10602,
location: { state: "Alaska" },
},
{
id: 5,
name: "Kenai Fjords",
areaInSquareKm: 2710,
location: { state: "Alaska" },
},
{
id: 6,
name: "Zion",
areaInSquareKm: 595.9,
location: { state: "Utah" },
},
];
const users = {
"karah.branch3": {
visited: [1],
wishlist: [4, 6],
},
"dwayne.m55": {
visited: [2, 5, 1],
wishlist: [],
},
thiagostrong1: {
visited: [5],
wishlist: [6, 3, 2],
},
"don.kim1990": {
visited: [2, 6],
wishlist: [1],
},
};
I need to write a function userHasVisitedAllParksInState
that does: This function returns a boolean that represents whether or not a user has visited all parks in the parks array from a given state.
I don't have any code for this because I don't even know where to start. Every time I think I have an idea it falls apart. Any help is appreciated.
function userHasVisitedAllParksInState(parks, users, state, userId) {}
ANSWER
Answered 2021-Apr-01 at 22:25You have a lot of ways you can solve this, but here are two ideas that you can continue developing:
One solution is very simple that works if you can't have visited the same park more than once. Create a list of the parks that match the requested state and check if the length of that is the same as the number of parks the person visited.
function userHasVisitedAllParksInState(parks, users, state, userId) {
var parksForState = parks.filter((park) => park.location.state === state);
return users[userId].visited.length === parksForState.length;
}
Another solution that might be easier to understand and works even if you have duplicate entries in the visited arrays:
function userHasVisitedAllParksInState1(parks, users, state, userId) {
var user = users[userId];
var parksForState = parks.filter((park) => park.location.state === state);
// Assume the person did visit all to start
var visitedAll = true;
for (var i = 0; i < parksForState.length; i++) {
// If the park we're checking atm is in the visited array, we've still visited all parks. If parksForState[i].id is not in user.visited
visitedAll = visitedAll && user.visited.indexOf(parksForState[i].id) > -1;
}
return visitedAll;
}
QUESTION
Ok, so I'm making a project gallery with the template of an Image Gallery from W3Schools. I am making this from mobile-first, so sizes are best-matched for iPhone 5-ish.
So I have made it, but the thumbnail container has the overflow expanding in the y-direction but I would like this container to expand into the x-direction and have it scrollable.
Here is a jsfiddle: https://jsfiddle.net/6chv3kry/2/. Note this is quite incomplete, but the thumbnail should be visible with alt
tags at the bottom of the page.
I have tried changing to a flex
display for the section-projects-thumbnail-row
, but this does not work. Is it maybe due to the sizing, if so how can I change it so that it works...thank you!
Here is the relevant code:
.html
Project Title 1
21/69/4200
Project Title 2
21/69/4200
Project Title 3
21/69/4200
Project Title 4
21/69/4200
Project Title 5
21/69/4200
Project Title 6
21/69/4200
.css
:
body, html {
max-width: 100%;
height: 100%;
margin: 0;
padding: 0;
border: 0;
overflow-x: hidden;
}
.section-projects-thumbnail-row{
position: absolute;
top: 70%;
height: 20%;
width: 100%;
overflow-x: scroll;
}
/* Six columns side by side */
.section-projects-thumbnail-col {
float: left;
width: 40%;
height: 100%;
margin: 2%;
}
/* Add a transparency effect for thumnbail images */
.section-projects-thumbnail-img {
display: block;
width: 100%;
height: 78%;
opacity: 0.6;
}
ANSWER
Answered 2021-Feb-26 at 21:27You have 2 options.
You have your 5 section-projects-thumbnail-col
floating left with a width of 40% and the container with a width of 100% of the window. There's obviously no room enough.
If you want to make it work that way you have to set your container: section-projects-thumbnail-row
200% width (40% * 5) and all your col
will behave a you want asuming you use box-sizing: border-box;
so paddings and margins do not take more room than 40%.
Second option could be not using float
, set your col
to display:inline-block
and add to the container white-space: nowrap;
. This would be a better option if the content is going to be dinamic so it will work with 5, 6 or as many elements you want.
Good luck with your project.
QUESTION
I'm trying to add a favicon to the following hugo theme: https://github.com/stackbithq/stackbit-theme-fjord The problem is that the documentation points me to a Gatsby.js example.
I've generated the favicon assets and placed them within /static, where does the following markup need to be placed within the theme?
For reference, I tried creating a head section within header.html but this wasn't generating the favicon while testing locally.
ANSWER
Answered 2021-Jan-26 at 12:21Append the lines to the file components/html_head.html
...
{% if site.params.favicon %}
{% endif %}
QUESTION
I have 2 pandas dataframes:
- state abbreviations and states.
- state names and all the national parks in each state. This is not the whole dataframe.
I need to search for a user input in the state dataframe, in this case the state abbreviation, then take the adjacent value, the full name and use that to display the correct column from the parks dataframe. I am sure this could be easier if they were one dataframe, but I could not figure a way to do that and keep all of the functionality; I want to be able to display the state dataframe for the user. Any suggestions would be really appreciated. here is my code. Around line 72 I could use help. I kept as much out as i could while keeping this functional, it is a large program, but this is my biggest problem so far. thank you
def main():
if __name__ == "__main__":
import pandas as pd
import numpy as np
from tabulate import tabulate
def parks():
park_dict = {'Alaska': ['DENA', 'Denali National Park and Preserve', 'GAAR', 'Gates of the Arctic National Park', 'GLBA',
'Glacier Bay National Park', 'KATM', 'Katmai National Park and Preserve', 'KEFJ',
'Kenai Fjords National Park', 'KOVA', 'Kobuk Valley National Park', 'LACLk', 'Lake Clark National Park',
'WRST', 'Wrangell – St Elias National Park and Preserve'],
'American_Samoa': ['NSPA', 'National Park of American Samoa','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Arizona': ['GRCA', 'Grand Canyon National Park', 'PEFO', 'Petrified Forest National Park', 'SAGU',
'Saguaro National Park','.','.','.','.','.','.','.','.','.','.'],
'Arkansas': ['HOSP', 'Hot Springs National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'California': ['CHIS', 'Channel Islands National Park', 'DVNP', 'Death Valley National Park', 'JOTR',
'Joshua Tree National Park', 'KICA', 'Kings Canyon National Park', 'LAVO',
'Lassen Volcanic National Park', 'REDW', 'Redwood National Park', 'SEKI',
'Sequoia National Park', 'YOSE','Yosemite National Park'],
'Caolorado': ['BLCA', 'Black Canyon of the Gunnison National Park', 'GRSA',
'Great Sand Dunes National Park and Preserve', 'MEVE', 'Mesa Verde National Park',
'ROMO','Rocky Mountain National Park','.','.','.','.','.','.','.','.'],
'Florida': ['BISC', 'Biscayne National Park', 'DRTO', 'Dry Tortugas National Park', 'EVER',
'Everglades National Park','.','.','.','.','.','.','.','.','.','.'],
'Hawaii': ['HALE', 'Haleakala National Park', 'HAVO', 'Hawaii Volcanoes National Park','.','.','.','.','.','.','.','.','.','.','.','.'],
'Kentucky': ['MACA', 'Mammoth Cave National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Maine': ['ACAD', 'Acadia National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Michigan': ['ISRO', 'Isle Royale National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Minnesota': ['VOYA', 'Voyageurs National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Montana': ['GLAC', 'Glacier National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Nevada': ['GRBA', 'Great Basin National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'New_Mexico': ['CAVE', 'Carlsbad Caverns National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'North_Carolina': ['GRSM', 'Great Smoky Mountains National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'North_Dakota': ['THRO', 'Theodore Roosevelt National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Ohio': ['CUVA', 'Cuyahoga Valley National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Oregon': ['CRLA', 'Crater Lake National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'South_Carolina': ['COSW', 'Congaree National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'South_Dakota': ['BADL', 'Badlands National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Tennessee': ['GRSM', 'Great Smoky Mountains National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Texas': ['BIBE', 'Big Bend National Park', 'GUMO', 'Guadalupe Mountains National Park','','','','','','','','','','','',''],
'US_Virgin_Islands': ['VIIS', 'Virgin Islands National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Utah': ['ARCH', 'Arches National Park', 'BRCA', 'Bryce Canyon National Park', 'CANY',
'Canyonlands National Park', 'CARE', 'Capitol Reef National Park', 'ZION', 'Zion National Park','.','.','.','.','.','.'],
'Virginia': ['SHEN', 'Shenandoah National Park','.','.','.','.','.','.','.','.','.','.','.','.','.','.'],
'Washington': ['MORA ', 'Mount Rainier National Park ', 'NOCA', 'North Cascades National Park', 'OLYM',
'Olympic National Park','.','.','.','.','.','.','.','.','.','.'],
'Wyoming': ['GRTE', 'Grand Teton National Park', 'YELL', 'Yellowstone National Park','.','.','.','.','.','.','.','.','.','.','.','.']}
df = pd.DataFrame(park_dict)
df.index = np.arange(1, len(df) + 1)
#print(tabulate(df, headers='keys', tablefmt='simple'))
return''
def choose_state():
state_list = [['AK', 'Alaska', 'AS', 'American Samoa', 'AZ', 'Arizona', 'AR', 'Arkansas'],
['CA', 'California', 'CO', 'Colorado', 'FL', 'Florida', 'HI', 'Hawaii'],
['KY', 'Kentucky', 'ME', 'Maine', 'MI', 'Michigan', 'MN', 'Minnesota'],
['MT', 'Montana', 'NV', 'Nevada', 'NM', 'New Mexico', 'NC', 'North Carolina'],
['ND', 'North Dakota', 'OH', 'Ohio', 'OR', 'Oregon', 'SC', 'South Carolina'],
['SD', 'South Dakota', 'TN', 'Tennessee', 'TX', 'Texas', 'USVI', 'US Vergin Islands'],
['UT', 'Utah', 'VA', 'Virginia', 'WA', 'Washington', 'WY', 'Wyoming']]
statedf = pd.DataFrame(state_list, columns=['Abbr', 'State', 'Abbr', 'State', 'Abbr', 'State', 'Abbr', 'State'])
print(tabulate(statedf, headers='keys', tablefmt='simple', showindex=False))
while True:
print('\nEnter the abreviation for the state you will visit\nR - Return tp previous menu\nQ - Quit')
try:
entry = str(input('\n').upper())
if not entry.isalpha():
print('please enter letters only.')
choose_state()
'''
# if entry == (state abbr) in state_list, then take the full name of the state and look in (park_dict) and display the correct column)
'''
print(tabulate(park_dict, headers='keys', tablefmt='simple')) # print correct column from park_dict
elif entry == str('R'):
choose_state()
elif entry == str('Q'):
print('Have a nice day.')
exit()
else:
print('please enter 2 letter state abreviation.')
except ValueError:
print('Invalid entry')
choose_state()
break
return ''
def main_menu():
print('Select choice from menu:\n\n'
'1 - not ready\n'
'2 - Select state and National Park you are visiting\n'
'3 - Quit')
while True:
try:
menu_choice = int(input('\n'))
if menu_choice == int(1):
print('ok')
exit()
elif menu_choice == int(2):
choose_state()
break
elif menu_choice == int(3):
print('Exiting program')
exit()
else:
print('Value not recognized.')
exit()
except ValueError:
print('Invalid entry, please enter 1,2, or 3.')
main_menu()
return ''
print(main_menu())
main()
update: I changed my code as MashodRana suggested below,and it definitely helped clean it up, but it is not working quite right.I keep getting attribute errors. I plan to take the dictionaries and have them just as csv files to help clean it up, but I think it should work.
these are the errors: raise AttributeError(f"module 'pandas' has no attribute '{name}'") AttributeError: module 'pandas' has no attribute 'tabulate'
import pandas as pd
import numpy as np
from tabulate import tabulate
import csv
park_dict = {
'Alaska': ['DENA', 'Denali National Park and Preserve', 'GAAR', 'Gates of the Arctic National Park', 'GLBA',
'Glacier Bay National Park', 'KATM', 'Katmai National Park and Preserve', 'KEFJ',
'Kenai Fjords National Park', 'KOVA', 'Kobuk Valley National Park', 'LACLk',
'Lake Clark National Park',
'WRST', 'Wrangell – St Elias National Park and Preserve'],
'American_Samoa': ['NSPA', 'National Park of American Samoa', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.', '.', '.'],
'Arizona': ['GRCA', 'Grand Canyon National Park', 'PEFO', 'Petrified Forest National Park', 'SAGU',
'Saguaro National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
'Arkansas': ['HOSP', 'Hot Springs National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.'],
'California': ['CHIS', 'Channel Islands National Park', 'DVNP', 'Death Valley National Park', 'JOTR',
'Joshua Tree National Park', 'KICA', 'Kings Canyon National Park', 'LAVO',
'Lassen Volcanic National Park', 'REDW', 'Redwood National Park', 'SEKI',
'Sequoia National Park', 'YOSE', 'Yosemite National Park'],
'Colorado': ['BLCA', 'Black Canyon of the Gunnison National Park', 'GRSA',
'Great Sand Dunes National Park and Preserve', 'MEVE', 'Mesa Verde National Park',
'ROMO', 'Rocky Mountain National Park', '.', '.', '.', '.', '.', '.', '.', '.'],
'Florida': ['BISC', 'Biscayne National Park', 'DRTO', 'Dry Tortugas National Park', 'EVER',
'Everglades National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
'Hawaii': ['HALE', 'Haleakala National Park', 'HAVO', 'Hawaii Volcanoes National Park', '.', '.', '.', '.', '.',
'.', '.', '.', '.', '.', '.', '.'],
'Kentucky': ['MACA', 'Mammoth Cave National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.'],
'Maine': ['ACAD', 'Acadia National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
'Michigan': ['ISRO', 'Isle Royale National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.'],
'Minnesota': ['VOYA', 'Voyageurs National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.'],
'Montana': ['GLAC', 'Glacier National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.'],
'Nevada': ['GRBA', 'Great Basin National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.'],
'New_Mexico': ['CAVE', 'Carlsbad Caverns National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.', '.'],
'North_Carolina': ['GRSM', 'Great Smoky Mountains National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.', '.', '.', '.'],
'North_Dakota': ['THRO', 'Theodore Roosevelt National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.', '.', '.'],
'Ohio': ['CUVA', 'Cuyahoga Valley National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.'],
'Oregon': ['CRLA', 'Crater Lake National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.'],
'South_Carolina': ['COSW', 'Congaree National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.'],
'South_Dakota': ['BADL', 'Badlands National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.'],
'Tennessee': ['GRSM', 'Great Smoky Mountains National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.', '.', '.'],
'Texas': ['BIBE', 'Big Bend National Park', 'GUMO', 'Guadalupe Mountains National Park', '', '', '', '', '', '',
'', '', '', '', '', ''],
'US_Virgin_Islands': ['VIIS', 'Virgin Islands National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.', '.', '.'],
'Utah': ['ARCH', 'Arches National Park', 'BRCA', 'Bryce Canyon National Park', 'CANY',
'Canyonlands National Park', 'CARE', 'Capitol Reef National Park', 'ZION', 'Zion National Park', '.',
'.', '.', '.', '.', '.'],
'Virginia': ['SHEN', 'Shenandoah National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
'.', '.'],
'Washington': ['MORA ', 'Mount Rainier National Park ', 'NOCA', 'North Cascades National Park', 'OLYM',
'Olympic National Park', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
'Wyoming': ['GRTE', 'Grand Teton National Park', 'YELL', 'Yellowstone National Park', '.', '.', '.', '.', '.',
'.', '.', '.', '.', '.', '.', '.']}
pdf = pd.DataFrame(park_dict)
pdf.index = np.arange(1, len(pdf) + 1)
#print(tabulate(pdf, headers='keys', tablefmt='simple'))
pdf.to_csv(r'park_dict.csv')
state_list = [['AK', 'Alaska', 'AS', 'American Samoa', 'AZ', 'Arizona', 'AR', 'Arkansas'],
['CA', 'California', 'CO', 'Colorado', 'FL', 'Florida', 'HI', 'Hawaii'],
['KY', 'Kentucky', 'ME', 'Maine', 'MI', 'Michigan', 'MN', 'Minnesota'],
['MT', 'Montana', 'NV', 'Nevada', 'NM', 'New Mexico', 'NC', 'North Carolina'],
['ND', 'North Dakota', 'OH', 'Ohio', 'OR', 'Oregon', 'SC', 'South Carolina'],
['SD', 'South Dakota', 'TN', 'Tennessee', 'TX', 'Texas', 'USVI', 'US Virgin Islands'],
['UT', 'Utah', 'VA', 'Virginia', 'WA', 'Washington', 'WY', 'Wyoming']]
sdf = pd.DataFrame(state_list, columns=['Abbr', 'State', 'Abbr', 'State', 'Abbr', 'State', 'Abbr', 'State'])
sdf = pd.DataFrame({'abbr': sdf['Abbr'].values.flatten(), 'state': sdf['State'].values.flatten()})
#sdf.to_csv(r'state_dict.csv')
#print(tabulate(sdf, headers='keys', tablefmt='simple', showindex=False))
def trail_finder():
with open('AllTrails data.csv', 'r') as f:
all_park_data = csv.reader(f)
all_park_info = list(all_park_data)
# print('\n'.join(' '.join(elems) for elems in all_park_info)) #just to verify data
f.close()
def main():
def choose_destination():
print(tabulate(sdf, headers='keys', tablefmt='simple', showindex=False))
# user input
entry = str(input('Enter the abreviation for the state you will visit:\n').upper())
while True:
try:
val = sdf[sdf['abbr'] == entry]
state_name = val.values.flatten()[1]
print(pd.tabulate(pdf))
ndf = {state_name: pdf[state_name].values}
print(tabulate(ndf, headers='keys', tablefmt='simple'))
# error checking
if not entry.isalpha():
print('please enter letters only.')
else:
print('please enter 2 letter state abreviation.')
except ValueError:
print('Invalid entry')
break
return ''
def fitness_menu():
print('1 - Determine fitness level\n2 - proceed to Trail Finder\n3 - Quit')
while True:
try:
menu_choice = int(input('\n'))
if menu_choice == int(1):
print('FIXME- build fitness level code')
break
elif menu_choice == int(2):
choose_destination()
break
elif menu_choice == int(3):
print('Exiting program')
exit()
else:
print('Invalid entry, please enter 1, 2, or 3.')
exit()
except ValueError:
print(ValueError)
exit()
return ''
def entrance_menu():
print('Select choice from menu:\n\n'
'1 - To use fitness calculator to determine fitness level(optional) \n'
'2 - To choose destination\n'
'3 - To Quit')
while True:
try:
menu_choice = int(input('\n'))
if menu_choice == int(1):
fitness_menu()
break
elif menu_choice == int(2):
choose_destination()
break
elif menu_choice == int(3):
print('Exiting program')
exit()
else:
print('Invalid entry, please enter 1, 2, or 3.')
entrance_menu()
except ValueError:
print(ValueError)
exit()
return ''
entrance_menu()
main()
ANSWER
Answered 2020-Nov-19 at 05:41You can do your task in this way:
Combine the all-states and abbreviations into a single column
sdf = pd.DataFrame({'abbr':statedf['Abbr'].values.flatten(),'state':statedf['State'].values.flatten()})
Search the abbreviations into the sdf (state data frame) and extract the corresponding full form
val = sdf[sdf['abbr']==entry]
state_name = val.values.flatten()[1]
Finally display the parks corresponding to state name from the pdf(park data frame)
ndf = {state_name:pdf[state_name].values}
print(tabulate(ndf, headers='keys', tablefmt='simple', showindex=False))
Note: Please save your parks and state as CSV file. Then load them on your program. Don't use different columns for the same type of value like 'state' and 'abbreviation' And if you want you can improve your code in many ways.
QUESTION
i have added %
and %.eu-west-1.compute.amazonaws.com
on my Manage Access Hosts on Mysql server like that :
and directly after running this cmd :
git push heroku master
the cmd end with an error like that:
remote: ----------------------------
remote: [INFO] driver: com.mysql.jdbc.Driver
remote: [INFO] url: jdbc:mysql://red.obambu.com:3306/dbName?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC
remote: [INFO] username: username
remote: [INFO] password: *****
remote: [INFO] use empty password: false
remote: [INFO] properties file: null
remote: [INFO] properties file will override? false
remote: [INFO] prompt on non-local database? false
remote: [INFO] clear checksums? false
remote: [INFO] changeLogDirectory: null
remote: [INFO] changeLogFile: src/main/resources/config/liquibase/master.xml
remote: [INFO] context(s): null
remote: [INFO] label(s): null
remote: [INFO] number of changes to apply: 0
remote: [INFO] drop first? false
remote: [INFO] ------------------------------------------------------------------------
remote: Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] BUILD FAILURE
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 14.608 s
remote: [INFO] Finished at: 2020-08-21T14:36:52Z
remote: [INFO] ------------------------------------------------------------------------
remote: [ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.9.0:update (default-cli) on project test-aoo:
remote: [ERROR] Error setting up or running Liquibase:
remote: [ERROR] liquibase.exception.DatabaseException: java.sql.SQLException: Access denied for user 'username'@'ec2-11-111-111-11.eu-west-1.compute.amazonaws.com' (using password: YES)
remote: [ERROR] -> [Help 1]
remote: [ERROR]
remote: [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
remote: [ERROR] Re-run Maven using the -X switch to enable full debug logging.
remote: [ERROR]
remote: [ERROR] For more information about the errors and possible solutions, please read the following articles:
remote: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
remote: Waiting for release... failed.
To https://git.heroku.com/quiet-fjord-74508.git
34d00e5..3ad885c master -> master
N.B : my db password is something like that : test@@123$$*
any help guys ?
ANSWER
Answered 2020-Aug-21 at 20:24You should remove @ from password or replace it with %40 in your URL to not confuse with the '@' in your database URL. example :
before :
jdbc:mysql://username:pass@word@localhost:3306/dbname
after :
jdbc:mysql://username:pass%40word@localhost:3306/dbname
QUESTION
I'm trying to create a gallery when an image is clicked on it brings up a carousel.
I'm almost there, but the image is huge when full size so I need it to be smaller however it leaves a background on the carousel.
function openModal() {
document.getElementById("myModal").style.display = "block";
}
function closeModal() {
document.getElementById("myModal").style.display = "none";
}
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
var captionText = document.getElementById("caption");
if (n > slides.length) {
slideIndex = 1
}
if (n < 1) {
slideIndex = slides.length
}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex - 1].style.display = "inline";
dots[slideIndex - 1].className += " active";
captionText.innerHTML = dots[slideIndex - 1].alt;
}
body {
font-family: Verdana, sans-serif;
margin: 0;
}
* {
box-sizing: border-box;
}
.row>.column {
padding: 0 8px;
}
.row:after {
content: "";
display: table;
clear: both;
}
.column {
float: left;
width: 25%;
background-color: black;
}
/* The Modal (background) */
.modal {
display: none;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: auto;
height: 100%;
overflow: auto;
background-color: black;
}
/* Modal Content */
.modal-content {
position: relative;
background-color: red;
margin: auto;
padding: 0;
width: auto;
}
/* The Close Button */
.close {
color: white;
position: absolute;
top: 10px;
right: 25px;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #999;
text-decoration: none;
cursor: pointer;
}
.mySlides {
display: none;
}
.cursor {
cursor: pointer;
}
/* Next & previous buttons */
.prev,
.next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -50px;
color: white;
font-weight: bold;
font-size: 20px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
-webkit-user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover,
.next:hover {
background-color: rgba(0, 0, 0, 0.8);
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
img {
margin-bottom: -4px;
}
.caption-container {
text-align: center;
background-color: black;
padding: 2px 16px;
color: white;
}
.demo {
opacity: 0.6;
}
.active,
.demo:hover {
opacity: 1;
}
img.hover-shadow {
transition: 0.3s;
}
.hover-shadow:hover {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
Image of what happens: https://imgur.com/lipg9nD
As you can see in the image, the photo isn't within the next/previous arrows and there's a lot of empty space (red) when it should just shrink/grow to the size of the image.
Thanks in advance for any help.
ANSWER
Answered 2020-Aug-12 at 14:54Add this to your CSS style:
.modal-content .mySlides img{
display:block;
margin:auto;
}
It will center the image. Further move before
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fjord
You can use fjord like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the fjord component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page