kandi background
Explore Kits

Hadi | Hadi is an Android ORM Framework | Database library

 by   PepeuCps Java Version: 1.7 License: No License

 by   PepeuCps Java Version: 1.7 License: No License

Download this library from

kandi X-RAY | Hadi Summary

Hadi is a Java library typically used in Database, Framework applications. Hadi has no bugs, it has no vulnerabilities and it has low support. However Hadi build file is not available. You can download it from GitHub.
Hadi is an Android ORM Framework. It makes SQLite using in Android easy and simple. Hadi is and open source project. It was originally created by The9tCat http://sourceforge.net/users/the9tcat.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • Hadi has a low active ecosystem.
  • It has 23 star(s) with 6 fork(s). There are 15 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 2 open issues and 1 have been closed. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of Hadi is 1.7
Hadi Support
Best in #Database
Average in #Database
Hadi Support
Best in #Database
Average in #Database

quality kandi Quality

  • Hadi has 0 bugs and 0 code smells.
Hadi Quality
Best in #Database
Average in #Database
Hadi Quality
Best in #Database
Average in #Database

securitySecurity

  • Hadi has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • Hadi code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
Hadi Security
Best in #Database
Average in #Database
Hadi Security
Best in #Database
Average in #Database

license License

  • Hadi does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
Hadi License
Best in #Database
Average in #Database
Hadi License
Best in #Database
Average in #Database

buildReuse

  • Hadi releases are available to install and integrate.
  • Hadi has no build file. You will be need to create the build yourself to build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • Hadi saves you 338 person hours of effort in developing the same functionality from scratch.
  • It has 809 lines of code, 46 functions and 9 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
Hadi Reuse
Best in #Database
Average in #Database
Hadi Reuse
Best in #Database
Average in #Database
Top functions reviewed by kandi - BETA

kandi has reviewed Hadi and discovered the below as its top functions. This is intended to give you an instant insight into Hadi implemented functionality, and help decide if they suit your requirements.

  • Scan tables .
  • Loads all fields from the cursor into the model .
  • Creates tables .
  • Returns the column attribute of the specified object .
  • Update model .
  • Insert a model .
  • Closes the database manager .
  • Closes the database .
  • Open database .
  • Gets the database manager .

Hadi Key Features

Hadi is an Android ORM Framework.

How to use

copy iconCopydownload iconDownload
	<application android:name="com.the9tcat.hadi.HadiApplication" android:icon="@drawable/icon" android:label="@string/app_name">

Como Usar

copy iconCopydownload iconDownload
	<application android:name="com.the9tcat.hadi.HadiApplication" android:icon="@drawable/icon" android:label="@string/app_name">

Bash count occurences based on parameters

copy iconCopydownload iconDownload
#!/bin/bash

file=athletes.csv
nationality=$1
sport=$2

IFS=, read -a l < "$file"
declare -A h
for pos in "h${!l[@]}"
do
    h["${l[$pos]}"]=$pos
done

declare -i participants=0
declare -i medals=0
while IFS=, read -a l
do
    if [ "${l[${h["nationality"]}]}" = "$nationality" ] &&
        [ "${l[${h["sport"]}]}" = "$sport" ]
    then
    ((participants++))
        medals=$((
        $medals +
        "${l[${h["gold"]}]}" +
        "${l[${h["silver"]}]}" +
        "${l[${h["bronze"]}]}"
    ))
    fi
done < "$file"
echo "Participants, Medals"
echo "$participants, $medals"
$ ./script2_4.sh CAN athletics
Participants, Medals
1, 1
-----------------------
#!/bin/bash

file=athletes.csv
nationality=$1
sport=$2

IFS=, read -a l < "$file"
declare -A h
for pos in "h${!l[@]}"
do
    h["${l[$pos]}"]=$pos
done

declare -i participants=0
declare -i medals=0
while IFS=, read -a l
do
    if [ "${l[${h["nationality"]}]}" = "$nationality" ] &&
        [ "${l[${h["sport"]}]}" = "$sport" ]
    then
    ((participants++))
        medals=$((
        $medals +
        "${l[${h["gold"]}]}" +
        "${l[${h["silver"]}]}" +
        "${l[${h["bronze"]}]}"
    ))
    fi
done < "$file"
echo "Participants, Medals"
echo "$participants, $medals"
$ ./script2_4.sh CAN athletics
Participants, Medals
1, 1

R convert character string to a dataframe

copy iconCopydownload iconDownload
library(dplyr, warn.conflicts = FALSE) # for pipes

df <- 
  txt %>% 
  
  # Replace "." sep with newline
  stringr::str_replace_all(
    "\\.[A-Z]", 
    function(x) stringr::str_replace(x, "\\.", "\n")
  ) %>% 
  
  # Replace all commas in (First[,Middle1,Middle2,...]) with space
  stringr::str_replace_all(
    # Match anything inside brackets, but as few times as possible, so we don't
    # match multiple brackets
    "\\(.*?\\)", 
    # Inside the regex that was matched, replace comma with space
    function(x) stringr::str_replace_all(x, ",", " ")
  ) %>% 
  
  # Replace ( with ,
  stringr::str_replace_all("\\(", ",") %>%
  
  # Remove )
  stringr::str_remove_all("\\)") %>%
  
  # Replace @ with ,
  stringr::str_replace_all("@", ",") %>%
  
  # Remove the last "."
  stringr::str_replace_all("\\.$", "\n") %>% 
  
  # Add , after female/male
  stringr::str_replace_all("male", "male,") %>% 
  
  # Read as comma delimited file (works since string contains \n)
  readr::read_delim(
    file = .,
    delim = ",",
    col_names = FALSE,
    show_col_types = FALSE
  )

# Add names (could also be done directly in read_delim with col_names argument)
names(df) <- c(
  "family_name",
  "first_names",
  "gender",
  "birthday",
  "birth_city",
  "birth_country",
  "acc_type",
  "acc_num",
  "district",
  "code"
)

df
#> # A tibble: 4 × 10
#>   family_name first_names      gender birthday birth_city birth_country acc_type
#>   <chr>       <chr>            <chr>  <chr>    <chr>      <chr>         <chr>   
#> 1 EREKSON     Andrew Hélène    female 10/06/2… Geneva     Switzerland   PPF     
#> 2 BOUKAR      Mohamed El-Hadi  male   04/12/1… London     England       PPF     
#> 3 HARIMA      Olak N’nassik G… female 25/06/2… Paris      France        PPF     
#> 4 THOMAS      Hajil Pau Joëli  female 03/03/1… Berlin     Germany       VAT     
#> # … with 3 more variables: acc_num <chr>, district <chr>, code <chr>
-----------------------
library(tidyr)
data.frame(txt) %>%
  # separate `txt` into rows using the dot `.` *if* 
  # preceded by `Dt\\.\\d{3}/\\d{3}` as splitting pattern:
  separate_rows(txt, sep = "(?<=Dt\\.\\d{3}/\\d{3})\\.(?!$)") %>%
  extract(
          # select column from which to extract:
          txt,
          # define column names into which to extract:
          into = c("family_name","first_names","gender",
                   "birthday","birth_city","birth_country",
                   "acc_type","acc_num","district","code"),
          # describe the string exhaustively using capturing groups
          # `(...)` to delimit what's to be extracted:
          regex = "([A-Z]+)\\(([\\w,]+)\\),([a-z]+)([\\d/]+)@(\\w+)\\((\\w+)\\),([A-Z]+),(\\w+),dist.(\\d+),Dt\\.([\\d/]+)")
# A tibble: 4 × 10
  family_name first_names    gender birthday   birth_city birth_country acc_type acc_num  
  <chr>       <chr>          <chr>  <chr>      <chr>      <chr>         <chr>    <chr>    
1 EREKSON     Andrew,Peter   male   10/06/2011 Geneva     Switzerland   PPF      2000X007…
2 OBAMA       Barack,Hussian male   04/12/1956 London     England       PPF      2001X005…
3 CLINTON     Hillary        female 25/06/2013 Paris      France        PPF      2009X005…
4 GATES       Melinda        female 03/03/1980 Berlin     Germany       VAT      2010X006…
# … with 2 more variables: district <chr>, code <chr>

API Laravel - Call Store Procedure with IN and OUT parameter using OCI8 or PDO

copy iconCopydownload iconDownload
public function cekLogin(Request $request) {
    $pdo = DB::getPdo();

    $pIsSuccess = "";
    $pMsg = "";
    $pLastScope = "";
    $pParam = "";

    $procedureName = 'myschema.VERIFY_LOGIN';
    
    $userLogin = $request['userLogin'];
    $passLogin = $request['passLogin'];
    $userLogin = $request['userLogin'];
    
    $stmt = $pdo->prepare("begin " . $procedureName . " (:pUserLogin, :pUserPassword, :pIPLogin, :pIsSuccess, :pMsg, :pLastScope, :pParam); end;");
    $stmt->bindParam(':pUserLogin', $userLogin, PDO::PARAM_STR);
    $stmt->bindParam(':pUserPassword', $passLogin, PDO::PARAM_STR);
    $stmt->bindParam(':pIPLogin', $userLogin, PDO::PARAM_STR);
    $stmt->bindParam(':pIsSuccess', $pIsSuccess, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 4000);
    $stmt->bindParam(':pMsg', $pMsg, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 4000);
    $stmt->bindParam(':pLastScope', $pLastScope, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 4000);
    $stmt->bindParam(':pParam', $pParam, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 4000);
    
    $stmt->execute();

    return response()->json([
        'IsSuccess' => $pIsSuccess, 
        'Msg' => $pMsg, 
        'LastScope' => $pLastScope, 
        'Param' => $pParam, 
    ], 422);
}

fake_useragent module not connecting properly - IndexError: list index out of range

copy iconCopydownload iconDownload
    html = html.split('<table class="w3-table-all notranslate">')[1]
#                                    ^^ change this
    html = html.split('<table class="ws-table-all notranslate">')[1]
#                                    ^^ to this
import fake_useragent
print(fake_useragent.__file__)
'C:\\Users\\mattdmo\\AppData\\Roaming\\Python\\Python310\\site-packages\\fake_useragent\\__init__.py'
-----------------------
    html = html.split('<table class="w3-table-all notranslate">')[1]
#                                    ^^ change this
    html = html.split('<table class="ws-table-all notranslate">')[1]
#                                    ^^ to this
import fake_useragent
print(fake_useragent.__file__)
'C:\\Users\\mattdmo\\AppData\\Roaming\\Python\\Python310\\site-packages\\fake_useragent\\__init__.py'
-----------------------
    html = html.split('<table class="w3-table-all notranslate">')[1]
#                                    ^^ change this
    html = html.split('<table class="ws-table-all notranslate">')[1]
#                                    ^^ to this
import fake_useragent
print(fake_useragent.__file__)
'C:\\Users\\mattdmo\\AppData\\Roaming\\Python\\Python310\\site-packages\\fake_useragent\\__init__.py'
-----------------------
    html = html.split('<table class="w3-table-all notranslate">')[1]
#                                    ^^ change this
    html = html.split('<table class="ws-table-all notranslate">')[1]
#                                    ^^ to this
import fake_useragent
print(fake_useragent.__file__)
'C:\\Users\\mattdmo\\AppData\\Roaming\\Python\\Python310\\site-packages\\fake_useragent\\__init__.py'

Substring string in bash

copy iconCopydownload iconDownload
sed -r 's:(.).*\.(.+):\1\.\2:g' {YOUR_FILE.TXT}
-----------------------
sed -E 's/^(.)[^.]+\./\1/' file

xblodot
whadi
awk -F. '{print substr($1,1,1) $2}' file

xblodot
whadi
-----------------------
sed -E 's/^(.)[^.]+\./\1/' file

xblodot
whadi
awk -F. '{print substr($1,1,1) $2}' file

xblodot
whadi
-----------------------
while read ns; do
  echo "${ns::1}${ns#*.}"
done < the_input_file.txt
-----------------------
name=xavier.blodot
shortened_name="${name:0:1}${name##*.}"

ClassCastException by (String) getIn().getBody

copy iconCopydownload iconDownload
String body = exchange.getIn().getBody(String.class);

How do I center the dots (SVG) with the class .stroke1

copy iconCopydownload iconDownload
.strokes {
  display: flex;
  justify-content: center;
  text-align: center;
  align-items: center;
  width: 100%;
}

.stroke1 {
  z-index: 1002;
}
<section class="home" id="home">
            <div class="max-width">
                <div class="star star1"></div>

                <div class="home-content">
                    <div class="text-1">Hello, my name is</div>
                    <div class="text-2">Hadi Zouhbi</div>
                    <div class="text-3">And I'm a <span class="txt-rotate"
                         data-period="2000" 
                         data-rotate='[ "Developer.", "UX Designer.", " Programmer.", "Full-Stack Dev.", "Marketer" ]'
                         id="headSpan"></span></div>
                    <a href="#">Hire Me</a>
                </div>
            </div>
        </section>
    </header>

    <div class="strokes">
    <svg class="stroke1" stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024" height="3em" width="3em" xmlns="http://www.w3.org/2000/svg"><path d="M456 231a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 280a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 280a56 56 0 1 0 112 0 56 56 0 1 0-112 0z"></path></svg>
</div>
-----------------------
.strokes {
  display: flex;
  justify-content: center;
  text-align: center;
  align-items: center;
  width: 100%;
}

.stroke1 {
  z-index: 1002;
}
<section class="home" id="home">
            <div class="max-width">
                <div class="star star1"></div>

                <div class="home-content">
                    <div class="text-1">Hello, my name is</div>
                    <div class="text-2">Hadi Zouhbi</div>
                    <div class="text-3">And I'm a <span class="txt-rotate"
                         data-period="2000" 
                         data-rotate='[ "Developer.", "UX Designer.", " Programmer.", "Full-Stack Dev.", "Marketer" ]'
                         id="headSpan"></span></div>
                    <a href="#">Hire Me</a>
                </div>
            </div>
        </section>
    </header>

    <div class="strokes">
    <svg class="stroke1" stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024" height="3em" width="3em" xmlns="http://www.w3.org/2000/svg"><path d="M456 231a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 280a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 280a56 56 0 1 0 112 0 56 56 0 1 0-112 0z"></path></svg>
</div>

find the specific part of string between special characters

copy iconCopydownload iconDownload
import re

string = "hi i am *hadi* and i have &18& year old"

pattern = r'(?:\*|&)(\w+)(?:\*|&)'

print(re.findall(pattern, string))
['hadi', '18']
-----------------------
import re

string = "hi i am *hadi* and i have &18& year old"

pattern = r'(?:\*|&)(\w+)(?:\*|&)'

print(re.findall(pattern, string))
['hadi', '18']
-----------------------
import re

string = "hello. my name is *hadi* and i am ^18^ years old."

name = re.findall(r"\*(.+)\*", string)
age = re.findall(r"\^(.+)\^", string)

print(name[0], age[0])

Why isn't the exit icon showing when menu is clicked

copy iconCopydownload iconDownload
.fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
}
.fa.fa-times-circle.exit {
    display: inline-block;
}
.fa.fa-times-circle.exit {
    z-index: 999;
    display: none;
    margin: 1.8rem;
}
/*Navbar*/
body {
  background-color: #ccc;
}

.navbar {
  width: 100%;
  position: fixed;
  font-family: "Ubuntu", sans-serif;
  padding: 30px 0;
}

.navbar .logo a {
  font-size: 2rem;
  font-weight: 600;
  color: white;
}

.navbar .logo a span {
  color: crimson;
  transition: all 0.3s ease;
}

.sticky {
  padding: 30px 0;
  background-color: crimson;
}

.sticky .logo a span {
  color: #fff;
}

.menu li {
  display: inline-block;
  list-style: none;
}

.menu li a {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 500;
  margin-left: 35px;
  padding-left: 5px;
  transition: color 0.3s ease;
}

.menu li a:hover {
  border-left: 3px solid white;
  color: crimson;
}

.sticky .menu li a:hover {
  color: white;
}

.navbar .max-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.max-width {
  max-width: 1300px;
  padding: 0 80px;
  margin: auto;
}


/*Menu Button*/

.fa.fa-bars.menuBtn {
  color: #fff;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

.fa.fa-times-circle.exit {
  color: white;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

@media (max-width: 934px) {
  .max-width {
    padding: 0 50px;
  }
  .fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
  }
  .fa.fa-times-circle.exit {
    display: inline-block;
  }
  .menu {
    position: fixed;
    height: 100vh;
    width: 100%;
    left: 0;
    top: 0;
    background-color: #111;
    text-align: center;
    padding-top: 110px;
    display: none;
  }
  .menu ul li {
    display: block;
  }
  .menu ul li a {
    display: inline-block;
    margin: 20px 0;
    font-size: 35px;
  }
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/fontawesome.min.css" integrity="sha384-wESLQ85D6gbsF459vf1CiZ2+rr+CsxRY0RpiF1tLlQpDnAgg6rwdsUF1+Ics2bni" crossorigin="anonymous">

<header>

  <nav class="navbar" id="nav">
    <div class="max-width">
      <div class="logo"><a id="headSpan" href="index.html">Port<span>folio.</span></a></div>
      <div class="menu">
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Skills</a></li>
          <li><a href="#">Projects</a></li>
          <li><a href="#">CV</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </div>
      <div>
        <i class="fa fa-bars menuBtn" id="menuBtn" aria-hidden="true"></i>

        <i class="fa fa-times-circle exit" id="exitBtn" aria-hidden="true"></i>
      </div>
    </div>
  </nav>

  <!--Head Banner-->
  <section class="home" id="home">
    <div class="max-width">
      <div class="home-content">
        <div class="text-1">Hello, my name is</div>
        <div class="text-2">Hadi Zouhbi</div>
        <div class="text-3">And I'm a <span id="headSpan">&#60;Developer&#62;</Developer></span></div>
      </div>
    </div>
  </section>
  
</header>
-----------------------
.fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
}
.fa.fa-times-circle.exit {
    display: inline-block;
}
.fa.fa-times-circle.exit {
    z-index: 999;
    display: none;
    margin: 1.8rem;
}
/*Navbar*/
body {
  background-color: #ccc;
}

.navbar {
  width: 100%;
  position: fixed;
  font-family: "Ubuntu", sans-serif;
  padding: 30px 0;
}

.navbar .logo a {
  font-size: 2rem;
  font-weight: 600;
  color: white;
}

.navbar .logo a span {
  color: crimson;
  transition: all 0.3s ease;
}

.sticky {
  padding: 30px 0;
  background-color: crimson;
}

.sticky .logo a span {
  color: #fff;
}

.menu li {
  display: inline-block;
  list-style: none;
}

.menu li a {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 500;
  margin-left: 35px;
  padding-left: 5px;
  transition: color 0.3s ease;
}

.menu li a:hover {
  border-left: 3px solid white;
  color: crimson;
}

.sticky .menu li a:hover {
  color: white;
}

.navbar .max-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.max-width {
  max-width: 1300px;
  padding: 0 80px;
  margin: auto;
}


/*Menu Button*/

.fa.fa-bars.menuBtn {
  color: #fff;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

.fa.fa-times-circle.exit {
  color: white;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

@media (max-width: 934px) {
  .max-width {
    padding: 0 50px;
  }
  .fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
  }
  .fa.fa-times-circle.exit {
    display: inline-block;
  }
  .menu {
    position: fixed;
    height: 100vh;
    width: 100%;
    left: 0;
    top: 0;
    background-color: #111;
    text-align: center;
    padding-top: 110px;
    display: none;
  }
  .menu ul li {
    display: block;
  }
  .menu ul li a {
    display: inline-block;
    margin: 20px 0;
    font-size: 35px;
  }
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/fontawesome.min.css" integrity="sha384-wESLQ85D6gbsF459vf1CiZ2+rr+CsxRY0RpiF1tLlQpDnAgg6rwdsUF1+Ics2bni" crossorigin="anonymous">

<header>

  <nav class="navbar" id="nav">
    <div class="max-width">
      <div class="logo"><a id="headSpan" href="index.html">Port<span>folio.</span></a></div>
      <div class="menu">
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Skills</a></li>
          <li><a href="#">Projects</a></li>
          <li><a href="#">CV</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </div>
      <div>
        <i class="fa fa-bars menuBtn" id="menuBtn" aria-hidden="true"></i>

        <i class="fa fa-times-circle exit" id="exitBtn" aria-hidden="true"></i>
      </div>
    </div>
  </nav>

  <!--Head Banner-->
  <section class="home" id="home">
    <div class="max-width">
      <div class="home-content">
        <div class="text-1">Hello, my name is</div>
        <div class="text-2">Hadi Zouhbi</div>
        <div class="text-3">And I'm a <span id="headSpan">&#60;Developer&#62;</Developer></span></div>
      </div>
    </div>
  </section>
  
</header>
-----------------------
.fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
}
.fa.fa-times-circle.exit {
    display: inline-block;
}
.fa.fa-times-circle.exit {
    z-index: 999;
    display: none;
    margin: 1.8rem;
}
/*Navbar*/
body {
  background-color: #ccc;
}

.navbar {
  width: 100%;
  position: fixed;
  font-family: "Ubuntu", sans-serif;
  padding: 30px 0;
}

.navbar .logo a {
  font-size: 2rem;
  font-weight: 600;
  color: white;
}

.navbar .logo a span {
  color: crimson;
  transition: all 0.3s ease;
}

.sticky {
  padding: 30px 0;
  background-color: crimson;
}

.sticky .logo a span {
  color: #fff;
}

.menu li {
  display: inline-block;
  list-style: none;
}

.menu li a {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 500;
  margin-left: 35px;
  padding-left: 5px;
  transition: color 0.3s ease;
}

.menu li a:hover {
  border-left: 3px solid white;
  color: crimson;
}

.sticky .menu li a:hover {
  color: white;
}

.navbar .max-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.max-width {
  max-width: 1300px;
  padding: 0 80px;
  margin: auto;
}


/*Menu Button*/

.fa.fa-bars.menuBtn {
  color: #fff;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

.fa.fa-times-circle.exit {
  color: white;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

@media (max-width: 934px) {
  .max-width {
    padding: 0 50px;
  }
  .fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
  }
  .fa.fa-times-circle.exit {
    display: inline-block;
  }
  .menu {
    position: fixed;
    height: 100vh;
    width: 100%;
    left: 0;
    top: 0;
    background-color: #111;
    text-align: center;
    padding-top: 110px;
    display: none;
  }
  .menu ul li {
    display: block;
  }
  .menu ul li a {
    display: inline-block;
    margin: 20px 0;
    font-size: 35px;
  }
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/fontawesome.min.css" integrity="sha384-wESLQ85D6gbsF459vf1CiZ2+rr+CsxRY0RpiF1tLlQpDnAgg6rwdsUF1+Ics2bni" crossorigin="anonymous">

<header>

  <nav class="navbar" id="nav">
    <div class="max-width">
      <div class="logo"><a id="headSpan" href="index.html">Port<span>folio.</span></a></div>
      <div class="menu">
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Skills</a></li>
          <li><a href="#">Projects</a></li>
          <li><a href="#">CV</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </div>
      <div>
        <i class="fa fa-bars menuBtn" id="menuBtn" aria-hidden="true"></i>

        <i class="fa fa-times-circle exit" id="exitBtn" aria-hidden="true"></i>
      </div>
    </div>
  </nav>

  <!--Head Banner-->
  <section class="home" id="home">
    <div class="max-width">
      <div class="home-content">
        <div class="text-1">Hello, my name is</div>
        <div class="text-2">Hadi Zouhbi</div>
        <div class="text-3">And I'm a <span id="headSpan">&#60;Developer&#62;</Developer></span></div>
      </div>
    </div>
  </section>
  
</header>
-----------------------
.fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
}
.fa.fa-times-circle.exit {
    display: inline-block;
}
.fa.fa-times-circle.exit {
    z-index: 999;
    display: none;
    margin: 1.8rem;
}
/*Navbar*/
body {
  background-color: #ccc;
}

.navbar {
  width: 100%;
  position: fixed;
  font-family: "Ubuntu", sans-serif;
  padding: 30px 0;
}

.navbar .logo a {
  font-size: 2rem;
  font-weight: 600;
  color: white;
}

.navbar .logo a span {
  color: crimson;
  transition: all 0.3s ease;
}

.sticky {
  padding: 30px 0;
  background-color: crimson;
}

.sticky .logo a span {
  color: #fff;
}

.menu li {
  display: inline-block;
  list-style: none;
}

.menu li a {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 500;
  margin-left: 35px;
  padding-left: 5px;
  transition: color 0.3s ease;
}

.menu li a:hover {
  border-left: 3px solid white;
  color: crimson;
}

.sticky .menu li a:hover {
  color: white;
}

.navbar .max-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.max-width {
  max-width: 1300px;
  padding: 0 80px;
  margin: auto;
}


/*Menu Button*/

.fa.fa-bars.menuBtn {
  color: #fff;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

.fa.fa-times-circle.exit {
  color: white;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

@media (max-width: 934px) {
  .max-width {
    padding: 0 50px;
  }
  .fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
  }
  .fa.fa-times-circle.exit {
    display: inline-block;
  }
  .menu {
    position: fixed;
    height: 100vh;
    width: 100%;
    left: 0;
    top: 0;
    background-color: #111;
    text-align: center;
    padding-top: 110px;
    display: none;
  }
  .menu ul li {
    display: block;
  }
  .menu ul li a {
    display: inline-block;
    margin: 20px 0;
    font-size: 35px;
  }
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/fontawesome.min.css" integrity="sha384-wESLQ85D6gbsF459vf1CiZ2+rr+CsxRY0RpiF1tLlQpDnAgg6rwdsUF1+Ics2bni" crossorigin="anonymous">

<header>

  <nav class="navbar" id="nav">
    <div class="max-width">
      <div class="logo"><a id="headSpan" href="index.html">Port<span>folio.</span></a></div>
      <div class="menu">
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Skills</a></li>
          <li><a href="#">Projects</a></li>
          <li><a href="#">CV</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </div>
      <div>
        <i class="fa fa-bars menuBtn" id="menuBtn" aria-hidden="true"></i>

        <i class="fa fa-times-circle exit" id="exitBtn" aria-hidden="true"></i>
      </div>
    </div>
  </nav>

  <!--Head Banner-->
  <section class="home" id="home">
    <div class="max-width">
      <div class="home-content">
        <div class="text-1">Hello, my name is</div>
        <div class="text-2">Hadi Zouhbi</div>
        <div class="text-3">And I'm a <span id="headSpan">&#60;Developer&#62;</Developer></span></div>
      </div>
    </div>
  </section>
  
</header>
-----------------------
.fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
}
.fa.fa-times-circle.exit {
    display: inline-block;
}
.fa.fa-times-circle.exit {
    z-index: 999;
    display: none;
    margin: 1.8rem;
}
/*Navbar*/
body {
  background-color: #ccc;
}

.navbar {
  width: 100%;
  position: fixed;
  font-family: "Ubuntu", sans-serif;
  padding: 30px 0;
}

.navbar .logo a {
  font-size: 2rem;
  font-weight: 600;
  color: white;
}

.navbar .logo a span {
  color: crimson;
  transition: all 0.3s ease;
}

.sticky {
  padding: 30px 0;
  background-color: crimson;
}

.sticky .logo a span {
  color: #fff;
}

.menu li {
  display: inline-block;
  list-style: none;
}

.menu li a {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 500;
  margin-left: 35px;
  padding-left: 5px;
  transition: color 0.3s ease;
}

.menu li a:hover {
  border-left: 3px solid white;
  color: crimson;
}

.sticky .menu li a:hover {
  color: white;
}

.navbar .max-width {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.max-width {
  max-width: 1300px;
  padding: 0 80px;
  margin: auto;
}


/*Menu Button*/

.fa.fa-bars.menuBtn {
  color: #fff;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

.fa.fa-times-circle.exit {
  color: white;
  font-size: 35px;
  cursor: pointer;
  display: none;
}

@media (max-width: 934px) {
  .max-width {
    padding: 0 50px;
  }
  .fa.fa-bars.menuBtn {
    display: block;
    padding-left: 10em;
  }
  .fa.fa-times-circle.exit {
    display: inline-block;
  }
  .menu {
    position: fixed;
    height: 100vh;
    width: 100%;
    left: 0;
    top: 0;
    background-color: #111;
    text-align: center;
    padding-top: 110px;
    display: none;
  }
  .menu ul li {
    display: block;
  }
  .menu ul li a {
    display: inline-block;
    margin: 20px 0;
    font-size: 35px;
  }
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/fontawesome.min.css" integrity="sha384-wESLQ85D6gbsF459vf1CiZ2+rr+CsxRY0RpiF1tLlQpDnAgg6rwdsUF1+Ics2bni" crossorigin="anonymous">

<header>

  <nav class="navbar" id="nav">
    <div class="max-width">
      <div class="logo"><a id="headSpan" href="index.html">Port<span>folio.</span></a></div>
      <div class="menu">
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Skills</a></li>
          <li><a href="#">Projects</a></li>
          <li><a href="#">CV</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </div>
      <div>
        <i class="fa fa-bars menuBtn" id="menuBtn" aria-hidden="true"></i>

        <i class="fa fa-times-circle exit" id="exitBtn" aria-hidden="true"></i>
      </div>
    </div>
  </nav>

  <!--Head Banner-->
  <section class="home" id="home">
    <div class="max-width">
      <div class="home-content">
        <div class="text-1">Hello, my name is</div>
        <div class="text-2">Hadi Zouhbi</div>
        <div class="text-3">And I'm a <span id="headSpan">&#60;Developer&#62;</Developer></span></div>
      </div>
    </div>
  </section>
  
</header>

Why isn't my span changing color on scroll

copy iconCopydownload iconDownload
window.addEventListener('scroll', function() {
    
    if (window.scrollY > 20) {
        const navbar = document.querySelector('.home');
        const headSpan = document.querySelector('span');
        navbar.classList.add('sticky');
        headSpan.classList.add('stickyHeadSpan');
    }
})

window.addEventListener('scroll', () => {
    
    if (window.scrollY === 0) {
        const navbar = document.querySelector('.home')
        navbar.classList.remove('sticky')
    }
})
.wrapper{
    height: 200vh;
}

.sticky {
    padding: 30px 0;
    background-color: crimson;
    position: sticky;
    top: 0;
    left: 0;
}

.stickyHeadSpan {
    color: #fff;
}
<div class="wrapper">
  <section class="home" id="home">
          <div class="max-width">
              <div class="home-content">
                  <div class="text-1">Hello, my name is</div>
                  <div class="text-2">Hadi Zouhbi</div>
                  <div class="text-3">And I'm a <span id="headSpan">Developer</span></div>
              </div>
          </div>
  </section>
</div>
-----------------------
window.addEventListener('scroll', function() {
    
    if (window.scrollY > 20) {
        const navbar = document.querySelector('.home');
        const headSpan = document.querySelector('span');
        navbar.classList.add('sticky');
        headSpan.classList.add('stickyHeadSpan');
    }
})

window.addEventListener('scroll', () => {
    
    if (window.scrollY === 0) {
        const navbar = document.querySelector('.home')
        navbar.classList.remove('sticky')
    }
})
.wrapper{
    height: 200vh;
}

.sticky {
    padding: 30px 0;
    background-color: crimson;
    position: sticky;
    top: 0;
    left: 0;
}

.stickyHeadSpan {
    color: #fff;
}
<div class="wrapper">
  <section class="home" id="home">
          <div class="max-width">
              <div class="home-content">
                  <div class="text-1">Hello, my name is</div>
                  <div class="text-2">Hadi Zouhbi</div>
                  <div class="text-3">And I'm a <span id="headSpan">Developer</span></div>
              </div>
          </div>
  </section>
</div>
-----------------------
window.addEventListener('scroll', function() {
    
    if (window.scrollY > 20) {
        const navbar = document.querySelector('.home');
        const headSpan = document.querySelector('span');
        navbar.classList.add('sticky');
        headSpan.classList.add('stickyHeadSpan');
    }
})

window.addEventListener('scroll', () => {
    
    if (window.scrollY === 0) {
        const navbar = document.querySelector('.home')
        navbar.classList.remove('sticky')
    }
})
.wrapper{
    height: 200vh;
}

.sticky {
    padding: 30px 0;
    background-color: crimson;
    position: sticky;
    top: 0;
    left: 0;
}

.stickyHeadSpan {
    color: #fff;
}
<div class="wrapper">
  <section class="home" id="home">
          <div class="max-width">
              <div class="home-content">
                  <div class="text-1">Hello, my name is</div>
                  <div class="text-2">Hadi Zouhbi</div>
                  <div class="text-3">And I'm a <span id="headSpan">Developer</span></div>
              </div>
          </div>
  </section>
</div>

Community Discussions

Trending Discussions on Hadi
  • Bash count occurences based on parameters
  • R convert character string to a dataframe
  • API Laravel - Call Store Procedure with IN and OUT parameter using OCI8 or PDO
  • fake_useragent module not connecting properly - IndexError: list index out of range
  • Unable to reach the Azure storage account via port 445
  • in-Message copied in out-Message
  • Substring string in bash
  • ClassCastException by (String) getIn().getBody
  • How do I center the dots (SVG) with the class .stroke1
  • Discord-buttons Action Row dont show up
Trending Discussions on Hadi

QUESTION

Bash count occurences based on parameters

Asked 2022-Apr-02 at 19:21

I'm new to bash shell and I have to do a script with a csv file.

The file is a list of the participants, countries, sports and medals achieved.

when executing the script, I should give as parameters the nationality (column 3) and the sport (column 8). The script should return the amount of participants of that country for that sport, and the amount of medals achieved.

The amount of medals achieved is the sum of the columns "gold" "silver" "bronze" of each row which are columns 9,10 and 11.

I cannot use grep, awk, sed or csvkit.

So far, I have this code but I'm stuck with the medal counting part.

nacionality=$1
sport=$2
columns= cut -d, -f 3,8 athletes.csv
echo columns | tr -cd $nacionality,$sport | wc -c

Could anyone help me?

The file is: https://github.com/flother/rio2016/blob/master/athletes.csv

The name of the file is script2_4.sh

An example of the output is:

./script2_4.sh POL rowing

 Participants, Medals


 26, 6

A sample of the file:

id,name,nationality,sex,date_of_birth,height,weight,sport,gold,silver,bronze,info
736041664,A Jesus Garcia,ESP,male,1969-10-17,1.72,64,athletics,0,0,0,
532037425,A Lam Shin,KOR,female,1986-09-23,1.68,56,fencing,0,0,0,
435962603,Aaron Brown,CAN,male,1992-05-27,1.98,79,athletics,0,0,1,
521041435,Aaron Cook,MDA,male,1991-01-02,1.83,80,taekwondo,0,0,0,
33922579,Aaron Gate,NZL,male,1990-11-26,1.81,71,cycling,0,0,0,
173071782,Aaron Royle,AUS,male,1990-01-26,1.80,67,triathlon,0,0,0,
266237702,Aaron Russell,USA,male,1993-06-04,2.05,98,volleyball,0,0,1,
382571888,Aaron Younger,AUS,male,1991-09-25,1.93,100,aquatics,0,0,0,
87689776,Aauri Lorena Bokesa,ESP,female,1988-12-14,1.80,62,athletics,0,0,0,
997877719,Ababel Yeshaneh,ETH,female,1991-07-22,1.65,54,athletics,0,0,0,
343694681,Abadi Hadis,ETH,male,1997-11-06,1.70,63,athletics,0,0,0,
591319906,Abbas Abubakar Abbas,BRN,male,1996-05-17,1.75,66,athletics,0,0,0,
258556239,Abbas Qali,IOA,male,1992-10-11,,,aquatics,0,0,0,
376068084,Abbey D'Agostino,USA,female,1992-05-25,1.61,49,athletics,0,0,0,
162792594,Abbey Weitzeil,USA,female,1996-12-03,1.78,68,aquatics,1,1,0,
521036704,Abbie Brown,GBR,female,1996-04-10,1.76,71,rugby sevens,0,0,0,
149397772,Abbos Rakhmonov,UZB,male,1998-07-07,1.61,57,wrestling,0,0,0,
256673338,Abbubaker Mobara,RSA,male,1994-02-18,1.75,64,football,0,0,0,
337369662,Abby Erceg,NZL,female,1989-11-20,1.75,68,football,0,0,0,
334169879,Abd Elhalim Mohamed Abou,EGY,male,1989-06-03,2.10,88,volleyball,0,0,0,
215053268,Abdalaati Iguider,MAR,male,1987-03-25,1.73,57,athletics,0,0,0,
763711985,Abdalelah Haroun,QAT,male,1997-01-01,1.85,80,athletics,0,0,0,

ANSWER

Answered 2022-Apr-02 at 19:21

Here is a pure bash implementation. Build a hash from field name to position ($h):

#!/bin/bash

file=athletes.csv
nationality=$1
sport=$2

IFS=, read -a l < "$file"
declare -A h
for pos in "h${!l[@]}"
do
    h["${l[$pos]}"]=$pos
done

declare -i participants=0
declare -i medals=0
while IFS=, read -a l
do
    if [ "${l[${h["nationality"]}]}" = "$nationality" ] &&
        [ "${l[${h["sport"]}]}" = "$sport" ]
    then
    ((participants++))
        medals=$((
        $medals +
        "${l[${h["gold"]}]}" +
        "${l[${h["silver"]}]}" +
        "${l[${h["bronze"]}]}"
    ))
    fi
done < "$file"
echo "Participants, Medals"
echo "$participants, $medals"

and example output with the first 4 lines of input:

$ ./script2_4.sh CAN athletics
Participants, Medals
1, 1

Source https://stackoverflow.com/questions/71717519

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install Hadi

You can download it from GitHub.
You can use Hadi 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 Hadi 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

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Try Top Libraries by PepeuCps
Compare Database Libraries with Highest Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.