mercredi 31 juillet 2019

JavaScript: RegExp literal vs constructor for security

The problem is more on using regular expression securely. If instantiating a "new RegExp..." can handle dynamic expressions, can we say it is preferred in terms of secure coding per se?

It rings a bell for me when I saw write-up for using RegExp Object (constructor) usage for dynamic creation of regular expression versus the literal pre-defined one. I read a number of forums, write-ups, and pages highlighting the benefits of literals in terms of performance, but not in terms of security.

literals: /[A-Z\d\s]/ constructor: new RegExp('[A-Z\d\s]')

Expected results would be on security.




this code is not working on android browsers


this javascript code is not working on android browsers like Opera - Chrome, But works on iPhone (Safari), PC ...

;(function($){
          $.fn.extend({
              donetyping: function(callback,timeout){
                  timeout = timeout || 1e3;
                  var timeoutReference,
                      doneTyping = function(el){
                          if (!timeoutReference) return;
                          timeoutReference = null;
                          callback.call(el);
                      };
                  return this.each(function(i,el){
                      var $el = $(el);
                      $el.is(':input') && $el.on('keyup keypress paste',function(e){
                          if (e.type=='keyup' && e.keyCode!=8) return;
                          if (timeoutReference) clearTimeout(timeoutReference);
                          timeoutReference = setTimeout(function(){
                              $('.profile-wr-diary-time').html('<font color="orange"><?php echo bliz_gp('saving'); ?>...</font>');
                              doneTyping(el);
                          }, timeout);
                      }).on('blur',function(){
                          doneTyping(el);
                      });
                  });
              }
          });
        })(jQuery);




Can I use "request" and "cheerio" libraries to extract data from a .html file?

I'm creating a React Web Application and using request and cheerio to do some Web Scrapping. I need to extract data from a .html file. The user enters with a .html in an input:

<input type='file' />

How can I extract data from the file? It is possible with those libraries? I know that request needs an url and I guess that it will be the local path to file. I used the following code to do Web Scrapping:

const foo = await new Promise(function (resolve, reject) {
    request.get(url, (err, res2, data) => {
        const $ = cheerio.load(data)
        let s = $("tbody < table.table_lt").text().replace(/\t/g, '').replace(/\n/g, '')
        resolve(s)
    })  
})

But this work just with Web.




CSS element with curved bended border/edge or line

I would like to create curved/bended shapes for my containters and also as a individual separators/elements. Here is the example: https://imgur.com/26mQYEs please look at the blue shape(I know this is not sharp but this is only a fast example)

How I can create effect like this one in 2019 and make this responsive? What methods, elements and tools I should use? Could you please give me examples?

Of course I want to make this solution responsive.

I have no idea how to do it, of course I can cut this as jpg image from photoshop but it will be not responsive.




HTTP webpage served on HTTPS Page

I have one issue: On the website I'm having, I need to get data from another website. My website is in HTTPS, but the website I need to get data from is HTTP only. I can't use iFrames or similar since when I get data (using get request), I need to parse it and do something based on the parse.

Is there anything I can do regarding this? I was thinking of some kind of website, that would read data from HTTP website and then deliver it to me using HTTPS. Is there such a thing? What is the alternative?

Thank you in advance!

EDIT: I can't use the backend to get that data, needs to be frontend only solution.




Javascript file included in HTML file not loaded correctly with RequestDispatcher.forward()

I have a simple gameboard.html file containing a

<script src="gameboard.js"></script>

at the end.

The gameboard.js file loads and runs correctly if I go directly to localhost:8080/gameboard.html.

However, when I try to forward to the HTML file from a servlet (in the interest to keep another URL), the gameboard.js file in developer tools shows the code of gameboard.html and gives a syntax error as it's invalid Javascript. The HTML code runs, but not the Javascript.

Servlet:

@WebServlet(name = "GameServlet", urlPatterns = {"/game/*"}, loadOnStartup = 1)
public class GameServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        request.getRequestDispatcher("/gameboard.html").forward(request, response);
    }
}

Result going directly to localhost:8080/gameboard.html - both HTML and Javascript files loaded correctly: Result going directly to localhost:8080/gameboard.html - both HTML and Javascript files loaded correctly

Result using the servlet forward to gameboard.html - Javascript file ends up with HTML code: Result using the servlet forward to gameboard.html - Javascript file ends up with HTML code




Create dynamic link using Firebase Functions

Im trying to set up a dynamic link that is auto created when a item is added to a the firestore database. 1) How do I get the dynamic link to create using a cloud function? 2) When the link is generated how do I add it to the database?

    >     import * as functions from 'firebase-functions'; 
    >     import * as admin from 'firebase-admin'; 
    > 
    > 
    > admin.initializeApp(functions.config().firebase);
    > 
    > 
    > export const link_gen =
    > functions.firestore.document('/Users/{userID}/Events/{eventsID}').onCreate((snapshot,
    > context) => {
    >     console.log("Event Created - Starting Link Generaction")
    >     console.log("Starting Link Gen For Guest Upload")
    > 
    >     //getting room and event data strings
    >     const userID = context.params.userID
    >     const eventID = context.params.eventsID
    >     console.log(userID)
    >     console.log(eventID)
    > 
    > 
    >     //getting all data in the new event
    >     const data = snapshot.data()
    >     console.log(data)
    > 
    >     //creating the dynamic link service from firebase
    >     POST https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=APIKEY
    >     Content-Type: application/json
    >     console.log("running")
    >     {    "longDynamicLink": "https://woke.page.link/Pages/gh/main.html?u=" + userID + "&e=" +
    > eventID;
    >     }
    > 
    > 
    > });




NVDA/Screen reader HTML Table accessiblity

I am working on a web application that should be fully accessible through keyboard and/or screen readers.

In this application I have some data tables. The information I could find about tables is that its html should be semantically correct, it must contain caption and tr/th and scope and aria-row/colcount... But what I can't find is how this should be accessed.

(1) Should I add a roving tabindex so, tab would focus on the first cell and other cell/rows be accessible through arrows, and another tab key would move focus to next focusable element on the screen, leaving the table?

(2.1) If my table has focusable elements inside (but only for one column per row) the focus move to the element, but somehow I should be able to read the content of each cell, right? In this case, should it be accessible to arrows or only through specific keys (ctrl+alt+->, for example)?

(2) I tried installing NVDA and pressing "T" to read the table, but even though I have all the aria attributes in a semantically correct html, it simply ignores the table; Same thing happened in other websites...

(3) I've added caption and labelledby but since the table is not a focusable element, NVDA doesn't really read it.




Flask shopping cart, how can i caclulate the total price of all the items in my cart

I have successfully been able to add to basket using flask Sessions but I am having trouble with caclulating the total price of all the products. I have tried to set a varible which calculates the price using the value in the list but that doesn't work and returns the first item instead. Could someone point me in the right direction. I also have a feeling that there would be a better way of doing this is anyone is aware then could they let me know as this is my one of my flask apps and would help a lot, thanks.

@app.route("/Menu")
def menu():
    MenuItems = Menu.query.all()
    return render_template("menu.html", MenuItems=MenuItems)

@app.route("/AddToCart", methods=["POST", "GET"])
def addToCart():
    itemId = int(request.form.get("productId"))
    MenuItem = Menu.query.get(itemId)

    if MenuItem is None:
        return render_template("error.html", errorMessage="There has been an issue adding this item to your basket")

    sVars = session['cart']

    sVars.append([str(MenuItem.ItemName), float(MenuItem.ItemPrice)])
    session['cart'] = sVars

    allPrices = sum(sVars[1])

    return render_template("cart.html", cartSession=session['cart'], allPrices=allPrices)




Determine if a button clicked did not result in a page load?

I am implementing a spinning wheel for my website. I first implemented it by displaying a spinning wheel on beforeunload and hiding on load but the animated gif stops spinning on IE so I am now implementing it when a link or button is clicked. However, the gif never hits onload when a button is clicked just for an alert or anything that doesnt redirect/refresh the page. How can I check if a link/button does not cause a page to reload?




What for we write

What for we write .

actually, I am reading source code and not getting the reason behind it.




How to solve FatalErrorException (E_UNKNOWN) Cannot use [] for reading?

whenever i want to view a profile it showing me a fatal error, with the message "FatalErrorException (E_UNKNOWN) Cannot use [] for reading" why it is happening

@if($user->is_employer() || $user->is_agent()) logo_url[] }}" class="img-fluid" style="max-width: 100px;" /> @endif

        <table class="table table-bordered table-striped mb-4">

            <tr>
                <th>@lang('app.name')</th>
                <td></td>
            </tr>

            <tr>
                <th>@lang('app.email')</th>
                <td></td>
            </tr>
            <tr>
                <th>@lang('app.gender')</th>
                <td></td>
            </tr>
            <tr>
                <th>@lang('app.phone')</th>
                <td></td>
            </tr>
            <tr>
                <th>@lang('app.address')</th>
                <td></td>
            </tr>
            <tr>
                <th>@lang('app.country')</th>
                <td>
                    @if($user->country)
                        
                    @endif
                </td>
            </tr>

            <tr>
                <th>@lang('app.created_at')</th>
                <td></td>
            </tr>
            <tr>
                <th>@lang('app.status')</th>
                <td></td>
            </tr>
        </table>




        @if($user->is_employer() || $user->is_agent())
                <h3 class="mb-4">About Company</h3>

                <table class="table table-bordered table-striped">
                <tr>
                    <th>@lang('app.state')</th>
                    <td></td>
                </tr>
                <tr>
                    <th>@lang('app.city')</th>
                    <td></td>
                </tr>

                <tr>
                    <th>@lang('app.website')</th>
                    <td></td>
                </tr>
                <tr>
                    <th>@lang('app.company')</th>
                    <td></td>
                </tr>
                <tr>
                    <th>@lang('app.company_size')</th>
                    <td></td>
                </tr>
                <tr>
                    <th>@lang('app.about_company')</th>
                    <td></td>
                </tr>
                <tr>
                    <th>@lang('app.premium_jobs_balance')</th>
                    <td></td>
                </tr>
            </table>
        @endif


        @if( ! empty($is_user_id_view))
            <a href="">
                <i class="la la-pencil-square-o"></i> @lang('app.edit') </a>
        @else
            <a href=""><i class="la la-pencil-square-o"></i> @lang('app.edit') </a>
        @endif

i want to view the profile and edit after i click the edit button.




Hello! I have the question. So how can i create a possibility of publication?

I'm a beginner web-developer (full-stack). Now, I create a site for my family. And I had a problem with how to make the publish button. That is, whatever we click on it, select a description for it and click the 'ready' to publish.




I need to populate dropdown from sqlserver which have onSelected property and databind

This is runtime image for my rendered web page I have inserted data in my sql server database, now I am trying to update those records so that changes can be made but when I populate textboxes using datatable functions its working fine but it does not populate selected "Program, Group and Class dropdownlists" from selected database value or selecteditems.

protected void campus_SelectedIndexChanged(object sender, EventArgs e)
                {
                    program.DataSource = dm.getData("SELECT DISTINCT cpCampusCode, cpCamName, cpProgramCode, cpProgName  From   CampusPrograms Where cpCampusCode = '" + campus.SelectedValue + "'");
                    program.DataTextField = "cpProgName";
                    program.DataValueField = "cpProgramCode";
                    program.DataBind();
                    program.Items.Insert(0, new ListItem("Select Program", "0"));



                }

         protected void program_SelectedIndexChanged(object sender, EventArgs e)
                {
                    Group.DataSource = dm.getData("Select DISTINCT a.ProgramCode, a.ProgramName, a.GroupCode AS GroupCode, a.GroupName AS GroupName from ProgramGroup a Inner Join CampusPrograms b ON b.cpProgramCode=a.ProgramCode Where b.cpProgramCode =  '" + program.SelectedValue + "' Order by GroupName ASC");
                    Group.DataTextField = "GroupName";
                    Group.DataValueField = "GroupCode";
                    Group.DataBind();
                    Group.Items.Insert(0, new ListItem("Select Group", "0"));
                }


         protected void stdid_SelectedIndexChanged(object sender, EventArgs e)
                {
                    Button1.Enabled = false;
                    UpdtBtn.Enabled = true;
                    DataTable dt = dm.getData("select * from StudentInquiry si inner join CampusPrograms a on si.iProgramCode=a.cpProgramCode  Where si.inqID='" + stdid.SelectedValue + "'");
                    foreach (DataRow dr in dt.Rows)
                    {
                        doi.Text = "" + dr["iDateOfInquiry"];
                        campus.SelectedValue = "" + dr["iCamCode"];
                        program.SelectedValue = "" + dr["iProgramCode"];
                        Group.SelectedValue = "" + dr["iGroupCode"];
                        Class.SelectedItem.Text = "" + dr["iClassCode"];


                        stName.Text = "" + dr["iStName"];
                        stCnic.Text = "" + dr["iCnic"];
                        dob.Text = "" + dr["iDOB"];
                        birthCity.SelectedItem.Text = "" + dr["iPlaceOfBirth"];
                        sphone.Text = "" + dr["iPhoneNo"];
                        smobile.Text = "" + dr["iMobileNo"];
                        semail.Text = "" + dr["iEmailID"];
                        saddress.Text = "" + dr["iAddress"];
                        gender.SelectedItem.Text = "" + dr["iGender"];
                        Religion.SelectedItem.Text = "" + dr["iReligion"];
                        DropDownList2.SelectedItem.Text = "" + dr["iMaritalStatus"];
                        Countries.SelectedItem.Text = "" + dr["iNationality"];
                        ffname.Text = "" + dr["iFFName"];
                        flname.Text = "" + dr["iFLName"];
                        fmob.Text = "" + dr["iFMobile"];
                        fnic.Text = "" + dr["iFCnic"];
                        qua.SelectedItem.Text = "" + dr["iLastQualification"];
                        lastins.Text = "" + dr["iLastInstitute"];
                        pyear.SelectedItem.Text = "" + dr["iPassingYear"];
                        Grade.Text = "" + dr["iGrade"];
                        RadioButtonList1.SelectedValue = "" + dr["iSource"];
                        remarks.Text = "" + dr["iRemarks"];
                    }

                }




Google captcha v2 token farming not working

Google Recaptcha version : v2

I tried to farm token of a website's google recaptcha and used it in forget password section of the same website. It's working perfectly.

The way i farm is , open google chrome anonymous tab and solve the captcha and get the g-recaptcha-response and put it another browser.

Hence, i try to do the same way for my actual purpose which is submit booking page. But the recaptcha validation cannot pass through. I've checked data-sitekey of the google recaptcha v2 is exactly same with the one i used to farm the token in forget password section.

Is there anything i missed out ?




Wordpress redirecting sites ending in "\"

I ran my site through an SEO checker and it told me I had 2 temporary redirects.. the redirect moves the page "http://flowersforeveryone.co.za/my-account\" to "http://flowersforeveryone.co.za/my-account/"

Does anyone know why there would be "\" in any of the URLs to begin with?

I found this piece of code in the functions.php file that is think is doing it...

// Remove Menu Tooltips

function my_menu_notitle( $menu ){
  return $menu = preg_replace('/ title=\"(.*?)\"/', '', $menu );

}
add_filter( 'wp_nav_menu', 'my_menu_notitle' );
add_filter( 'wp_page_menu', 'my_menu_notitle' );
add_filter( 'wp_list_categories', 'my_menu_notitle' );

I want to try fix this if I can as i'm trying to optimise SEO




Request from one website. In cpanel shows another domain

I have two website user requests something from website A but in c panel shows requests come from website B. I bought something from online shopping example onlineshoping.com. When I go to my website cpanel it shows another domain example asanshing.com.




Flutter For Web is there a way to store data?

I am building a web application with flutter for web, i know for sure that in the mobile version of flutter there is a way to store data in the device, but i don't know if this was even implemented in flutter for web yet.




how to draw map by mapinfo file(.tab .ID .mif)

I have some MapInfo map files, which open source tools can draw map files on the QT or web?

I transformed .tab files to .shp, then use openlayer to draw map.but it will lose some data(color).




REST is recognized by wrong (partially right) class, how to prevent from this?

I've got

@Path("web-filters/wizard/{type}/{id}/clone") annotation on one class

and

@Path("web-filters/wizard/filters") annotation on the other class.

filters can be passed as type path param.

And my problem is that REST i.e. host-and-etc/web-filters/wizard/filters/123/clone tries to found a path in the second class, co I've got 404. Is there an option to prevent from this?

I can move RESTs from first to second resource, but that is not what I want to do, at least I wish I can do it smarter.




the jQuery File is saved but not changing in the browser

I've made some changes on my jquery code and saved it but when opening the browser the code enter image description herehasn't been changed it's still the same as I didn't save it!.

enter image description heretack.imgur.com/ceyf8.png




mardi 30 juillet 2019

The meaning of status=Finished in chrome devtool network panel? What caused?

I got a HAR file from customer, the network shows 1 key request got a status with Finished and size 0, what caused this issue? And how to solve this issue?

enter image description here

Not all users have this issue, just a few of.




Why my CSS file doesn t work in my project

I wrote a project and want to add a template there. All styles work except one. It does not work for me "styleadmin.css". Although I think everything is written correctly. You can see if you made a mistake and did not write correctly. I want my style "styleadmin.css" to work on two pages - AdminDecorator.JSP and allStudentsAdmin.JSP

enter image description here

AdminDecorator.JSP

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">
        <title>Mountain King - Bootstrap Template</title>
        <!-- Bootstrap core CSS -->
        <link href="bootstrap/css/theme.css" rel="stylesheet">
        <!-- Custom styles for this template -->
        <link href="css/styleadmin.css" rel="stylesheet">
        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,300,700,100' rel='stylesheet' type='text/css'>
        <link href='https://fonts.googleapis.com/css?family=Raleway:300,700,900,500' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/typicons/2.0.7/typicons.min.css">
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
        <link rel="stylesheet" href="css/pushy.css">
        <link rel="stylesheet" href="css/masonry.css">
        <link rel="stylesheet" href="css/animate.css">
        <link rel="stylesheet" href="css/magnific-popup.css">
        <link rel="stylesheet" href="css/odometer-theme-default.css">
        <script>
        window.odometerOptions = {
          selector: '.odometer',
          format: '(,ddd)', // Change how digit groups are formatted, and how many digits are shown after the decimal point
          duration: 13000, // Change how long the javascript expects the CSS animation to take
          theme: 'default'
        };
        </script>

</head>
<!DOCTYPE html>
<body class="">
      <!-- Pushy Menu -->
      <nav class="pushy pushy-left">
        <ul class="list-unstyled">
            <li><a href="#home">Home</a></li>
            <li><a href="#feat">Features</a></li>
            <li><a href="#about">About me</a></li>
            <li><a href="#news">My Blog</a></li>
            <li><a href="#history">My History</a></li>
            <li><a href="#photos">Look my Photos</a></li>
            <li><a href="#contact">Get in Touch!</a></li>
        </ul>
      </nav>

      <!-- Site Overlay -->
      <div class="site-overlay"></div>

        <header id="home">
            <div class="container-fluid">
                <!-- change the image in style.css to the class header .container-fluid [approximately row 50] -->
                <div class="container">
                    <div class="row">
                        <div class="col-md-3 col-xs-10">
                            <a href="#" class="thumbnail logo">
                                <img src="images/your_logo.png" alt="" class="img-responsive">
                            </a>
                        </div>
                        <div class="col-md-1 col-md-offset-8 col-xs-2 text-center">
                          <div class="menu-btn"><span class="hamburger">&#9776;</span></div>
                        </div>
                    </div>

        </footer>
        <!-- Bootstrap core JavaScript
    ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <script src="js/jquery.min.js"></script>
        <script src="bootstrap/js/bootstrap.min.js"></script>
        <script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/js/bootstrap-scrollspy.js"></script>
        <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
        <script src="/js/ie10-viewport-bug-workaround.js"></script>
        <script src="http://masonry.desandro.com/masonry.pkgd.js"></script>
        <script src="js/masonry.js"></script>
        <script src="js/pushy.min.js"></script>
        <script src="js/jquery.magnific-popup.min.js"></script>
        <script src="js/wow.min.js"></script>
        <script src="js/scripts.js"></script>
        <script src="js/odometer.js"></script>


        <sitemesh:write property='body'/>
    <jsp:include page="/WEB-INF/template/admintemplate.jsp"/>  
    </body>
</html>

styleadmin.css

/*------------------------------------*\
    COMMONS CLASSES
\*------------------------------------*/

h1, h2, h3, h4, h5, h6
{
    font-family: 'Roboto Slab', serif;
}

h1, h2, h3, h4, h5, h6
{
    margin-bottom: 1.1em;
}

.features,
.blog,
.gallery,
.clients,
.prefooter .container-fluid
{
    padding-top: 3.3em;
    padding-bottom: 4.2em;
}

span.typcn::before, i.typcn::before
{
    font-size: 2em;
}

span.x2:before, i.x2:before
{
    font-size: 3.4em;
}

span.x3:before, i.x3:before
{
    font-size: 4.4em;
}

span.x4:before, i.x4:before
{
    font-size: 6em;
}


/*------------------------------------*\
    HEADER
\*------------------------------------*/

header .container-fluid
{
    background-image: url('https://unsplash.it/2560/1707?image=961');
    background-repeat: no-repeat;
    background-size: cover;
    height: 100vh;
    padding-top: 36px;
}

.hamburger
{
    font-size: 2.3em;
    color: #000;
}

.hamburger:hover
{
  color: #FFF;
  cursor: pointer;
}


.logo
{
    background: none;
    border: 0px;
}

.jumbotron
{
    background: none;
    text-align: center;
}

.jumbotron h1,
.jumbotron h2,
.jumbotron h3,
.jumbotron h4,
.jumbotron h5,
.jumbotron h6,
.jumbotron small
{
    color: #FFFFFF;
}

.jumbotron p
{
    color: #FFFFFF;
    margin-bottom: 5%;
}


/*------------------------------------*\
    SECTIONS
\*------------------------------------*/

.number .container-fluid
{
    background-image: url('https://unsplash.it/3000/2000?image=685');
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

.opaline
{
    padding-top: 3em;
    padding-bottom: 3em;
    background-color: rgba(128, 215, 247, 0.660);
}

.opaline h1,
.opaline h2,
.opaline h3,
.opaline h4,
.opaline h5,
.opaline h6,
.opaline p
{
    color: #FFFFFF;
}

.opaline .boxes
{
    margin-top: 30px;
    padding-top: 20px;
    padding-bottom: 5px;
    border: 1px solid #FFF;
}

.boxes .odometer.odometer-theme-default
{
  font-family: 'Roboto Slab', serif;
}

.story .container-fluid
{
    background-image: url('https://unsplash.it/3000/2000?image=531');
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}

.gallery
{
    background-color: #dddddd;
}

.prefooter .container-fluid
{
    background: linear-gradient(
      rgba(33, 37, 43, 0.6),
      rgba(33, 37, 43, 0.6)
    ),

    url(https://unsplash.it/4000/3000?image=528);
}

.prefooter h1,
.prefooter h2,
.prefooter h3,
.prefooter h4,
.prefooter h5,
.prefooter h6,
.prefooter p
{
    color: #FFFFFF;
}

/*------------------------------------*\
    FOOTER
\*------------------------------------*/

footer
{
    background-color: rgba(36, 50, 59, 1);
    padding-top: 2em;
    padding-bottom: 1.2em;
}

footer h1,
footer h2,
footer h3,
footer h4,
footer h5,
footer h6,
footer p
{
    color: #FFFFFF;
}

.social
{
    padding-top: 50px;
}

AllStudentsAdmin.JSP

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
        <link href="/css/styleadmin.css" rel="stylesheet" type="text/css">
        <style><%@include file="/css/styleadmin.css"%></style>
        <title>Все студенты</title>
    </head>
    <body>
            <br>
            <br>
            <br>
            <br>
            <div class="it">
                <h3 style="color:greenyellow" >Список всех студентов</h3>
                ${message}

                <br>
                <br>
                <table class="table">
                    <thead>
                        <tr>
                            <th bgcolor="#000000"><font color="#green" scope="col"># </font></th>
                            <th bgcolor="#000000"><font color="#green" scope="col">Name </font></th>

                            <th bgcolor="#000000"><font color="#green" scope="col">Surname </font></th>
                            <th bgcolor="#000000"><font color="#green" scope="col">Avatar </font></th>
                            <th bgcolor="#000000"><font color="#green" scope="col">Edit </font></th>
                            <th bgcolor="#000000"><font color="#green" scope="col">Delete </font></th>

                        </tr>
                    </thead>
                    <tbody>
                        <c:forEach var="student" items="${studentList}">
                            <tr>
                                 <th bgcolor="#000000"><font color="#fff"  scope="row">1 </font></th>
                                 <td bgcolor="#000000"><font color="#fff">${student.name}</font></td>
                                 <td bgcolor="#000000"><font color="#fff">${student.surname}</font></td>

                                <td bgcolor="#000000">
                                    <c:if test="${empty student.avatar}">
                                        <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/No_image_available.svg/768px-No_image_available.svg.png"
                                             style="max-height: 200px; max-width: 200px;"/>
                                    </c:if>
                                    <c:if test="${not empty student.avatar}">
                                        <img src="${pageContext.request.contextPath}/avatar?avatar=${student.avatar}"
                                             style="max-height: 200px; max-width: 200px;"/>
                                    </c:if>
                                </td>

                                <td bgcolor="#000000">
                                    <a href="${pageContext.request.contextPath}/admin/editStudent/${student.id}">
                                        <button type="button" class="btn btn-primary">Edit</button>
                                    </a>
                                </td>
                                <td bgcolor="#000000">
                                    <a href="${pageContext.request.contextPath}/admin/deleteStudent/${student.id}">
                                        <button type="button" class="btn btn-primary">Delete</button>
                                    </a>
                                </td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>

            </div>

    </body>
</html>

MySitemeshFilter

public class MySiteMeshFilter extends ConfigurableSiteMeshFilter {

  @Override
  protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {

            builder.addDecoratorPath("/*", "/WEB-INF/decorators/homeDecorator.jsp");

           builder.addDecoratorPath("/allStudents", "/WEB-INF/decorators/homeDecorator.jsp");

           builder.addDecoratorPath("/login", "/WEB-INF/decorators/loginDecorator.jsp");
           builder.addDecoratorPath("/admin/allStudentsAdmin", "/WEB-INF/decorators/adminDecorator.jsp");




what's wrong with my javascript code? (display toggle)

i made a button that makes my div hide and visible. It works well once or twice but and then It doesn't (I click the button with column1 doesn't open the column 1's hidden div then I click the column2 column2's hidden div is opening....)

<style>
  div {
    display: none;
  }
  
  div.hidden,
  li.on div.hidden {
    display: none;
  }
  
  li.on div {
    display: block;
  }
</style>
</head>

<body>
  <ul>
    <li class="on">column1
      <div>box</div>
      <div>box</div>
      <div>box</div>
      <div class="hidden">box</div>
      <div class="hidden">box</div>
      <div class="hidden">box</div>
    </li>
    <li>column2
      <div>box</div>
      <div>box</div>
      <div>box</div>
      <div class="hidden">box</div>
      <div class="hidden">box</div>
      <div class="hidden">box</div>
    </li>
    <li>column3
      <div>box</div>
      <div>box</div>
      <div>box</div>
      <div class="hidden">box</div>
      <div class="hidden">box</div>
      <div class="hidden">box</div>
    </li>
  </ul>
  <button>click!</button>
  <script>
    var tabList = document.querySelectorAll("li");

    tabList.forEach(function(tab, index) {
      tab.addEventListener('click', function() {
        removeOther();
        tab.classList.toggle("on");
        btnEvent(tab);
      });
    });

    function removeOther() {
      for (var i = 0; i < tabList.length; i++) {
        if (tabList[i].classList.contains("on")) {
          tabList[i].classList.remove("on");
        }
      }
    }

    var btn = document.getElementsByTagName("button")[0];

    function btnEvent(tab) {
      var hiddenTabs = tab.querySelectorAll('.hidden');
      btn.addEventListener("click", function() {
        for (var i = 0; i < hiddenTabs.length; i++) {
          hiddenTabs[i].classList.toggle("hidden");
        }
      })
    }
  </script>
</body>

It seems works well but when I try 3 or more times then the button is not work well




Show logo full size when post link website on facebook

I want to the logo show full size when I post link my website on facebook. But it not working. My logo (4267 x 1375)px

I think logo is too big

Thanks so much!

enter image description here




my javascript code with classList.toggle doesn't work well

i made a button that makes my div hide and visible. It works well once or twice but and then It doesn't (I click the button with column1 doesn't open the column 1's hidden div then I click the column2 column2's hidden div is opening....)

sorry for my bad english but I really wanna know why😂

<!DOCTYPE html>
<html lang="ko">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<ul>
  <li class="on">column1
    <div>box</div>
    <div>box</div>
    <div>box</div>
    <div class="hidden">box</div>
    <div class="hidden">box</div>
    <div class="hidden">box</div>
  </li>
  <li>column2
    <div>box</div>
    <div>box</div>
    <div>box</div>
    <div class="hidden">box</div>
    <div class="hidden">box</div>
    <div class="hidden">box</div>
  </li>
  <li>column3
    <div>box</div>
    <div>box</div>
    <div>box</div>
    <div class="hidden">box</div>
    <div class="hidden">box</div>
    <div class="hidden">box</div>
  </li>
</ul>
<button>click!</button>
<script>
    var tabList = document.querySelectorAll("li");

    tabList.forEach(function(tab, index){
        tab.addEventListener('click', function(){
            removeOther();
            tab.classList.toggle("on");
            btnEvent(tab);
        });
    });

    function removeOther(){
        for(var i = 0; i < tabList.length; i++){
            if(tabList[i].classList.contains("on")){
                tabList[i].classList.remove("on");
            }
        }
    }

    var btn = document.getElementsByTagName("button")[0];

    function btnEvent(tab){
        var hiddenTabs = tab.querySelectorAll('.hidden');
        btn.addEventListener("click", function(){
            for(var i = 0; i < hiddenTabs.length; i++){
                hiddenTabs[i].classList.toggle("hidden");
            }
        })
    }
</script>
</body>
</html>




How to get back informations about location or state from coordinates

I'm working on web application where i should be able to retreive informations of a specific place using only geo coordinates.Eg . I have a latitude and a longitude that are given and known but no other informations about the country,state,city,etc.Is it possible to retreive informations about the country,state,city with a kind of API that takes latitude and a longitudeas params and return some raw json that contains country,state,city of a given place?




need help solving the problem of installing an e-commerce website at XAMPP

saya mendapatkan code open source dari https://github.com/kirilkirkov/Ecommerce-CodeIgniter-Bootstrap berhubung saya adalah pemula saya mendapatkan masalah dari instalasinya. bantu saya dalam langkah menginstall website ini di XAMPP

I have tried installing Xampp but the code appears like this

Severity: Warning

Message: mysqli::real_connect(): (HY000/1045): Access denied for user 'adnan'@'localhost' (using password: YES)

Filename: mysqli/mysqli_driver.php

Line Number: 201

Backtrace:

File: C:\xampp\htdocs\Ecommerce-CodeIgniter-Bootstrap-master\application\third_party\MX\Loader.php Line: 109 Function: DB

File: C:\xampp\htdocs\Ecommerce-CodeIgniter-Bootstrap-master\application\third_party\MX\Loader.php Line: 65 Function: initialize

File: C:\xampp\htdocs\Ecommerce-CodeIgniter-Bootstrap-master\application\third_party\MX\Base.php Line: 55 Function: __construct

File: C:\xampp\htdocs\Ecommerce-CodeIgniter-Bootstrap-master\application\third_party\MX\Base.php Line: 60 Function: __construct

File: C:\xampp\htdocs\Ecommerce-CodeIgniter-Bootstrap-master\application\third_party\MX\Controller.php Line: 4 Function: require

File: C:\xampp\htdocs\Ecommerce-CodeIgniter-Bootstrap-master\application\third_party\MX\Modules.php Line: 123 Function: include_once

File: C:\xampp\htdocs\Ecommerce-CodeIgniter-Bootstrap-master\application\core\MY_Controller.php Line: 3 Function: spl_autoload_call

File: C:\xampp\htdocs\Ecommerce-CodeIgniter-Bootstrap-master\index.php Line: 292 Function: require_once




How redirect to https, www (https://www) and if it is images (https://cdn)

How to redirect to https, www (https://www.domain.xx) and if media css, js, png, svg redirect to (https://cdn.domain.xx)

The code below almost works.

RewriteCond %{HTTPS} !=on [NC,OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} !^.+\.(jpe?g|ico|png|svg|css|js)$ [NC]
RewriteRule ^(.*)$ https://www.domain.xx%{REQUEST_URI} [R=301,L]




Accessing ${parameters} from .java file to a .jsp file

How can I access a parameter from a Servlet into .jsp file?? I am creating a simple web application and all of the tutorials, as well as the one I'm following to build the application encourage me to use just ${parameter} in the .jsp file, but it does not work.

I've been browsing through the answers and the only one I get is either to access this parameter through ${} or through <% request.getAttribute("name", name) %> which I don't want to be using, how can I make ${} work?? (I want it to be printed in welcome.jsp file after I put the parameters into a in a index.jsp file)

My code is as following:

LoginServlet.java

    public class LoginServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public LoginServlet() {
        super();
    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.getWriter().append("Served at: ").append(request.getContextPath());
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        doGet(request, response);

        String name = request.getParameter("name");
        String password = request.getParameter("password");
        String url = "/welcome.jsp";

        HttpSession session = request.getSession();
        session.setAttribute("name", name);
        getServletContext().getRequestDispatcher(url).forward(request, response);

    }

}

web.xml

    <!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <servlet>
    <servlet-name>LoginServlet</servlet-name>
    <display-name>LoginServlet</display-name>
    <description></description>
    <servlet-class>com.zurciu.servlet.LoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/logmein</url-pattern>
  </servlet-mapping>
</web-app>

index.jsp

    <html>
<body>


<form action="logmein" method="post">

<pre>

Login :  <input type="text" name="name">  Password :  <input type="password" name="password">  <input type="submit" value="submit">
</pre>

</form>


</body>
</html>


welcome.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Welcome</title>
</head>
<body>

Welcome user!

${name}
${password}


</body>
</html>

pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.zurciu.maven</groupId>
    <artifactId>JSP_ACCESS_PARAMETER</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>JSP_ACCESS_PARAMETER Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.servlet/jsp-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>JSP_ACCESS_PARAMETER</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <verbose>true</verbose>
                    <source>1.8</source>
                    <target>1.8</target>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/</path>
                    <contextReloadable>true</contextReloadable>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

What am I missing?




How to exclude js file from minify on 'npm run build'?

Is it possible to mark somehow files that shouldn't be minified when I execute 'npm run build'? I want to leave files where others can simply add own logic in already builded project.




Server Object Error 'ASP 0177 : 800aea5f Server.CreateObject Failed

Hi we have a web application that are migrated to another server. Now, when accessing the application in the IIS, It displays an Server Object Error 'ASP 0177 : 800aea5f Server.CreateObject Failed error.

I've tried restarting the IIS but still displays the same error. Im also not familiar with the IIS, DLL, registry. Hope someone can guide me to this




classpath or relative path

Hi I have created a web spring project with netbeans, but I am not able to access project resources (images, css, etc). I have tried everything I know, I've even put the resources in the project classpath (/springweb2/resource.jpg). but I am not able to read those resources from the jsp pages of the project.

If I have resources in the classpath, while http: / localhost: 8080 / springweb2 is the root directory of my project, shouldn't I be able to read a resource from, for example, http: / localhost: 8080 / springweb2 / resource .jpg?




Can't login to a website with python request

I'm trying to log to a website https://app.factomos.com/connexion but that doesn't work, I still have the error 403, I try with different headers and different data, but I really don't know where is the problem...

I try another way with MechanicalSoup but that still return to the connection page.

If someone can help me... Thank you for your time :/

import requests
from bs4 import BeautifulSoup as bs

url = 'https://factomos.com'
email = 'myemail'
password = 'mypassword'
url_login = 'https://factomos.com/connexion'

headers = requests.utils.default_headers()
headers.update({
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36',
})

data_login = {
    'appAction': 'login',
    'email': email,
    'password': password
}

with requests.Session() as s:
    dash = s.post(url_login, headers=headers, data=data_login)
    print(dash.status_code)


# MechanicalSoup
import mechanicalsoup
browser = mechanicalsoup.StatefulBrowser()
resp = browser.open("https://app.factomos.com/connexion")
browser.select_form('form[id="login-form"]')
browser["email"] = 'myemail'
browser["password"] = 'mypassword'
response = browser.submit_selected()
print("submite: ", response.status_code)
print(browser.get_current_page())

I expect a response 200 with the dashboard page but the actual response is 403 or the connection page.




Display a GUI app (javaFX) on web page with Docker

I have a GUI application made with JavaFX that I can run with Docker without problem.

But instead of displaying this app into the terminal, I want to display it on a HTML page. Like the example from http://epfl-sti.github.io/octave-x11-novnc-docker/ (He display octave GUI on localhost with novnc)

Is there any solution for this problem assuming I want to display my application on my own web Page instead of the novnc template ?




WorkFlow for Asp.Net Core Web API - C#

Please share the detail about Asp.Net Core Web API project workflow

  • Added Controller and Models
  • Model class has properties
  • Controller has POST method

In POST call,I am doing some validation from Request data and assigned values to model properties.

Now , Where to create the method for processing further task by using model properties.

Shall I create another class file inside Models Folder or Create new directory and place the class file and write the methods ?

Also, How to call above methods from Controller POST method?




Download/files management software for clients for website

I've got different versions of a software that I'd like to distribute to clients (B2B). For example, one might be the base version, an extended version, and a trial version. These would be separate zip files. They are versioned as well.

These files are made available to clients either for trial or after they sign up for a license, and different licenses would give them access to different variants of the "software" (it's not exactly a software, it's just a file, but it doesn't matter for the sake of this question).

Putting these files on a webserver and allow password-protected HTTP access is not ideal as it doesn't allow a fine-grained enough permission model, e.g. for example I may want to give one client access to an update or a beta version, and not to another, and I'd end up creating a separate folder for each client for each version, which is very messy and means duplication a lot of files.

I guess what I am looking for is some simple, web-based "download portal" software, where I can create a web account for each customer. Ideally this would support the concept of "release channels" or something like that, and I could then assign each customer to a release channel, and to specific files in addition to that, to steer which customer has access to which files. I am using a self-hosted WordPress for the main website so I was thinking it would be great to have such a portal on a sub-domain like download.company.com and it ideally would use the WordPress authentication mechanism.

I don't want to program such a software myself though and I also didn't find an existing WP plugin that would do something like that. I am mentioning WP but this is not a WP-question, I am looking for any (good) solution - if it was able to use the WP-authentication mechanism, it would just be a really useful feature.

Does any solution like this exist? How would I best go about it? It seems that any B2B company distributing files and/or software to customers would have this problem. Do they all develop their own solution?

I wasn't 100% sure whether this fits on the StackOverflow, SuperUser, WebApps or Webmasters sites, if it's not appropriate here, I am happy to be directed to the most appropriate place.




create .json file on run time in javascript and save it in the end

This is my script. It is doing 2 things.

  • on mouse up it highlights the text
  • on highlight text, when it is clicked, it opens up a context Menu

What I want to do next is:

  • take the highlighted text as key
  • take the selected option from context Menu as value

  • save key:value pairs in JSON format

  • write JSON to file


I am new to web, need suggestions on how to do it. so far , my menu items are clickable but what to do next and how to implement what i want to implement is the question i want help with.

<!DOCTYPE html>
<html>
<head>
<title>TEST</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="context_menu.js"></script>


<style type="text/css">
.red {
    color: red;
};
        body {
  font-family: "Roboto", san-serif;
}

.center{
  text-align: center;
}
.menu {
  width: 120px;
  z-index: 1;
  box-shadow: 0 4px 5px 3px rgba(0, 0, 0, 0.2);
  position: fixed;
  display: none;
  transition: 0.2s display ease-in;

  .menu-options {
    list-style: none;
    padding: 10px 0;
    z-index: 1;

    .menu-option {
      font-weight: 500;
      z-index: 1;
      font-size: 14px;
      padding: 10px 40px 10px 20px;
      // border-bottom: 1.5px solid rgba(0, 0, 0, 0.2);
      cursor: pointer;

      &:hover {
        background: rgba(0, 0, 0, 0.2);
      }
    }
  }
}



button{
  background: grey;
  border: none;

  .next{
    color:green;
  }

  &[disabled="false"]:hover{
    .next{
      color: red;
      animation: move 0.5s;
      animation-iteration-count: 2;
    }
  }
}

@keyframes move{
  from{
    transform: translate(0%);
  }
  50%{
    transform: translate(-40%);
  }
  to{
    transform: transform(0%);
  }
}
    </style>

<body>


<div class="menu">
  <ul class="menu-options">
    <li class="menu-option" id="demo" onclick="myFunction()" >Animal</li>
    <li class="menu-option">Bird</li>
    <li class="menu-option">Human</li>
    <li class="menu-option">Alien</li>
    <li class="menu-option">No one</li>
  </ul>
</div>

<div class="select--highlight--active">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset imply dummy text sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>

</body>
<script>
const menu = document.querySelector(".menu");
console.log(menu)
let menuVisible = false;
const toggleMenu = command => {
    console.log("Togel : "+command)
  menu.style.display = command === "show" ? "block" : "none";
  menuVisible = !menuVisible;
};

const setPosition = ({ top, left }) => {
  console.log(top)
  console.log(left)
  menu.style.left = `${left}px`;
  menu.style.top = `${top}px`;
  toggleMenu("show");
};

// window.addEventListener("click", e => {
//      
// });

    $(function() {  
        thisRespondHightlightText(".select--highlight--active");
   });
/*thisRespondHightlightText(".select--highlight--active");*/


    function thisRespondHightlightText(thisDiv){
        $(thisDiv).on("mouseup", function () {
            console.log ("EVENT")
            var selectedText = getSelectionText();
            var selectedTextRegExp = new RegExp(selectedText,"g");
            var text = $(this).text().replace(selectedTextRegExp, "<span class='red'>" + selectedText + "</span>");
            console.log("Text "+ selectedText)
            $(this).html(text);
            if (selectedText == ""){
                toggleMenu("hide");
            }
            else{

                const origin = {
                    left: 100   ,
                    top: 100
                 };
                setPosition(origin);
            }      

        });
    }

    function getSelectionText() {
        var text = "";
        if (window.getSelection) {
            text = window.getSelection().toString();
        } else if (document.selection && document.selection.type != "Control") {
            alert("In else")
            text = document.selection.createRange().text;
        }

        return text;
    }
    function myFunction() {
      document.getElementById("demo").innerHTML = "I am an Animal!";
    }
</script>
</head>



</html>




Fail with bind Ajax to Socket io. And am I actually need this?

I have trouble with binding AJAX to Socket IO. I make a web chat with registration. After registration client send ajax request to the server and it opens web socket to chatting. And i actually don't know am I actyally do this(I mean can I just open socket without AJAX)

var app = express();
var cors = require('cors')
var server = app.listen(4000);

...

            function WebSocket(server, accessMessage)
            {
                var io = require('socket.io')(server);
                    io.on('connection', (ws) => { // ws  -- web socket
                        var currentroom = room_list[0]; // Global room (like a menu)
                        console.log(accessMessage);

                        for (var i = 0; i <= user_list.length; i++) {

                            if (!user_list[i]) {

                                user_list[i] = {
                                    Id: ws,
                                    name: "",
                                    room: "",
                                    Auth: false,
                                    data: {
                                        ImgHASH: ""
                                    }
                                };
                                //joinroom(ws,currentroom);
                                break;

                            }
                        }
                    }
            }




Sitemesh in my project does not work correctly

On the JSP pages "allStudents" and "Login" template works. But on the page "allStudentsAdmin" it does not work. I sort of wrote it right, but it doesn't work.I run it through netbeans through Tomcat. Look at the code. Maybe something is wrong.

MySiteMeshFilter.

import org.sitemesh.builder.SiteMeshFilterBuilder;
import org.sitemesh.config.ConfigurableSiteMeshFilter;

public class MySiteMeshFilter extends ConfigurableSiteMeshFilter {

  @Override
  protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {

            builder.addDecoratorPath("/*", "/WEB-INF/decorators/homeDecorator.jsp") 

           .addDecoratorPath("/allStudents", "/WEB-INF/decorators/homeDecorator.jsp")

           .addDecoratorPath("/login", "/WEB-INF/decorators/loginDecorator.jsp")
           .addDecoratorPath("/allStudentsAdmin", "/WEB-INF/decorators/allStudentsAdminDecorator.jsp");






  }

}

AllStudentsAdminDecorator

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="styleadmin.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<!DOCTYPE html>
<div id="header-wrapper">
    <div id="header">
        <div id="menu">
            <ul>
                <li class="current_page_item"><a href="${pageContext.request.contextPath}/">Главная страница</a></li>
                                <sec:authorize access="hasRole('ADMIN') || hasRole('USER')">
                                <li><a href="${pageContext.request.contextPath}/addStudent">Добавить студента</a></li>
                                </sec:authorize>
                                <sec:authorize access="!isAuthenticated()">
                <li><a href="${pageContext.request.contextPath}/login"></a>Войти</li>
                                </sec:authorize>
                                <sec:authorize access="isAuthenticated()">
                <li><a href="${pageContext.request.contextPath}/logout" class="last">Выйти</a></li>
                                </sec:authorize>
            </ul>
        </div>
        <!-- end #menu -->
        <div id="search">
            <form method="get" action="">
                <fieldset>
                    <input type="text" name="s" id="search-text" size="15" />
                    <input type="submit" id="search-submit" value="GO" />
                </fieldset>
            </form>
        </div>
        <!-- end #search -->
    </div>
</div>
<!-- end #header -->
<!-- end #header-wrapper -->
<div id="logo">
    <h1><a href="#">Predilection </a></h1>
    <p><em> template design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a></em></p>
</div>





        <sitemesh:write property='body'/>
    <jsp:include page="/WEB-INF/template/allStudentsAdmintemplate.jsp"/>  
    </body>
</html>

AllStudentsAdmin

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
        <title>Home</title>

    </head> 
    <body>

        <div class="add">
            <br>
            <br>
            <br>

            <br>
            <center>
                <h1>${headerMessage}</h1>

                <form:form method="POST" action="${pageContext.request.contextPath}/admin/addStudentAdmin" enctype="multipart/form-data">
                    <table>

                        <tr>
                            <td><label path="Name">Name</label></td>
                            <td><input type="text" name="name"/></td>
                        </tr>

                        <tr>
                            <td><label path="Surname">Surname</label></td>
                            <td><input type="text" name="surname"/></td>
                        </tr>
                        <tr>
                            <td><label path="Avatar">Avatar:</label></td>
                            <td>
                                <input type="file" name="avatar"/>
                            </td>

                        </tr>




How can i configure lampp for c++ web development

I have this project with some time complexity issues and some complex algorithms and using c++ would be a great help in my project. Thank You.




lundi 29 juillet 2019

how to display web api result to a dropdown list control?

I got response from a Web API.The API is returning a list of objects in JSON format.but couldn't display results to dropdownlist control.

you can see my codes in these pictures.Please help me?




Twitter says 'Sorry, that page doesn’t exist!'

When I go to this url (https://twitter.com/statuses/1155474249823354881) it gives me a page called "Sorry, that page doesn’t exist!"

But when I open the same url on private browser it shows me the correct page.

what is the issue with that?




Upload Files/Image From SD Card to Server with Nodemcu ESP8266?

I want to upload a file or image in my server (for testing, i use free hosting server 000webhost). The file or image is in SD Card. Then in the hardware, i have ESP8266 NodeMCU and SD Card module to read the files and send it to server using WiFi Internet.

I have tried using POSTMAN and it works perfectly (so i think, there is no problem with PHP code). But when i try to upload files with ESP8266 NodeMCU and SD Card module, it is not working. The files is not uploaded, but there is not error.

This is my PHP code:

<?PHP

  if(!empty($_FILES['data']))
  {
  echo "uploading..";
    $path = "data/";
    $path = $path . basename( $_FILES['data']['name']);
    if(move_uploaded_file($_FILES['data']['tmp_name'], $path)) {
      echo "The file ".  basename( $_FILES['data']['name']). 
      " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
  }
exit;
?>

and This is my ESP8266 NodeMCU code:

#include <ESP8266WiFi.h>
#include <SPI.h>
#include <SD.h>

File myFile;

const char* ssid     = "zzz";
const char* password = "xxx";
String host = "xxxx.000webhostapp.com";

void setup() {
  Serial.begin(115200);
  delay(10);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  Serial.print("connecting to ");
  Serial.println(host);

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }

  File myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test file:ok");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
  int filesize = myFile.size();
  Serial.print("filesize=");
  Serial.println(filesize);
  String fileName = myFile.name();
  String fileSize = String(myFile.size());

  Serial.println("reading file");

  String url = "/upload.php";

  String boundary = "WebKitFormBoundary7MA4YWxkTrZu0gW";
  String contentType = "text/plain";
  // post header
  String postHeader = "POST " + url + " HTTP/1.1\r\n";
  postHeader += "Host: " + host + " \r\n";
  postHeader += "Content-Type: multipart/form-data; boundary=----" + boundary + "\r\n";
  String keyHeader = "------" + boundary + "\r\n";
  keyHeader += "Content-Disposition: form-data; name=\"data\"\r\n\r\n";
  String requestHead = "------" + boundary + "\r\n";
  requestHead += "Content-Disposition: form-data; name=\"data\"; filename=\"" + fileName + "\"\r\n";
  requestHead += "Content-Type: " + contentType + "\r\n\r\n";

  // post tail
  String tail = "\r\n------" + boundary + "--\r\n\r\n";

  // content length
  int contentLength = keyHeader.length() + requestHead.length() + myFile.size() + tail.length();
  postHeader += "Content-Length: " + String(contentLength, DEC) + "\n\n";

  // send post header
  char charBuf0[postHeader.length() + 1];
  postHeader.toCharArray(charBuf0, postHeader.length() + 1);
  client.write(charBuf0);
  Serial.print("send post header=");
  Serial.println(charBuf0);

  // send key header
  char charBufKey[keyHeader.length() + 1];
  keyHeader.toCharArray(charBufKey, keyHeader.length() + 1);
  client.write(charBufKey);
  Serial.print("send key header=");
  Serial.println(charBufKey);

  // send request buffer
  char charBuf1[requestHead.length() + 1];
  requestHead.toCharArray(charBuf1, requestHead.length() + 1);
  client.write(charBuf1);
  Serial.print("send request buffer=");
  Serial.println(charBuf1);

  // create buffer
  const int bufSize = 2048;
  byte clientBuf[bufSize];
  int clientCount = 0;

  // read myFile until there's nothing else in it:
  while (myFile.available())
  {
    clientBuf[clientCount] = myFile.read();
    clientCount++;
    if (clientCount > (bufSize - 1))
    {
      client.write((const uint8_t *)clientBuf, bufSize);
      clientCount = 0;
    }
  }
  if (clientCount > 0)
  {
    client.write((const uint8_t *)clientBuf, clientCount);
    Serial.println("Sent LAST buffer");
  }

  // send tail
  char charBuf3[tail.length() + 1];
  tail.toCharArray(charBuf3, tail.length() + 1);
  client.write(charBuf3);
  Serial.print(charBuf3);

  Serial.println("end_request");


  String lastline;
  while (client.connected())
  {
    while (client.available())
    {
      String line = client.readStringUntil('\r');
      lastline = line;
      Serial.print(line);
      if (line.indexOf("{") > 0)
      {
        client.stop();
      }
    }
  }
  Serial.println(lastline);
  myFile.close();
  Serial.println("closing connection");
}

void loop(){
}

And the result from my serial monitor is:

WiFi connected
IP address: 
192.168.43.169
Initializing SD card...initialization done.
connecting to serveriot.000webhostapp.com
test file:ok
filesize=144
reading file
send post header=POST /upload.php HTTP/1.1
Host: serveriot.000webhostapp.com 
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Length: 386


send key header=------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="data"


send request buffer=------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="data"; filename="test.txt"

Sent LAST buffer

------WebKitFormBoundary7MA4YWxkTrZu0gW--

end_request
HTTP/1.1 200 OK
Date: Tue, 30 Jul 2019 01:32:19 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: awex
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Request-ID: 5d9decf0575d7243f6fce1135504e3db

1


0



closing connection




Using a C# application to control functions on a method?

this way seem vague, but I have certain tasks already coded in .net that I want to run from a website. I'm thinking some kind of call to the c sharp app to perform the task and return the results.

How would I make that connection is my question, how can I get my website to talk with my .net application.




how to have pdf links on chrome browsers without being blocked?

We have a website that chrome is blocking pdfs which have been written with href="x.pdf", I have been researching and saw that we have to change the header of the page to become pdf by Content-Disposition , another solution was to have the pdfs on an iframe.

I was wondering what is the best way to have pdfs which can be read by all browsers without any issues, for example iframe might not be a good solution for SEO purposes, or changing a header on server side might not be very applicable.

I would be glad to know your thoughts.




Font Awesome only displaying brand icons

I'm trying to use Font Awesome icons on my website, but any icon other than the 'brand' icons (fab) just display as boxes.

This is what appears:

https://imgur.com/a/HIukIAr

The second icon should have been a camera icon, but it appears as a box because it is not a 'brand' icon.

Here's how I've set up Font Awesome (I followed the instructions on their website). I have this in my <header> tag (I've hidden part of the URL for security purposes):

<script src="https://kit.fontawesome.com/--------.js"></script>

When I used the Github brand icon, this was the code I used:

<span style="padding-bottom: 30px;"><i class="fab fa-github fa-2x"></i></span>

And to use the camera icon, this is the code I used:

<span style="padding-bottom: 30px;"><i class="fas fa-camera fa-2x"></i></span>

It should display a camera icon on the right (see image), but it just displays an empty box. I have tried several solid icons (fas) but they all display as boxes. Only the icons listed under the brand category (fab) seem to work.




Is there a specific software license recommended for use when developing a personal website?

I do not know what software license to use when creating my own personal website containing skillsets, resumes, contact information and features, etc.

I have been perusing the Internet for answers to this question, but everyone seems to have a different response for what software license to use for a personal website developing using whatever particular framework.




How do I retrieve JSON from web page without a dedicated .json url?

I am building a web scrape for this website https://www.kucoin.com/news and I want to be able to pick up the latest news. For other websites, I would simply get the JSON and parse it into python and constantly monitor it to see if there any changes. However, for this web page, there are no dedicated JSON URL I can access when I looked through the Network Tab in Google Chrome. Apparently, the JSON is on the same page as that web (when I view source, it is at the bottom). How can I extract the JSON itself so I can setup a web scrape / monitor for it?




how to grap data from a local website with python

I need a hint how to grap data from a website. I am quite new to web grapping. The special thing is that I have no access to the website because it runs locally on another network. For development I only have the website as an html file. Know my problem is that I get an error with my following code. I think the problem is quite simple but I do not have an idea so far.

import requests
import urllib.request
import time
from bs4 import BeautifulSoup

url = 'file:///tmp/mozilla/LiveData.html' # file is locally so far
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")

I get the following error: NewConnectionError: : Failed to establish a new connection: [Errno -2] Name or service not known

Maybe it does not work when it is local and not a "real" website. Thanks for any help!




Angular static rendering with dynamic meta update causing problem with Google crawling

I have an Angular 7 app in which, for SEO reasons, I dynamically update the title and meta description inside onNgInit by collecting these information from database. I am building my project using Angular universal, but I take the static version and host it on my shared server.

The website works perfectly, updating the title and description correctly (verified in inspect) after the page loads (which takes couple of seconds).

BUT, the problem is after using query inspection in google search console to ask google to crawl/index my pages. After its done, I search for my webpages on google, the title appears correct same as it is in database, however google displays in the description the keyword undefined or for other pages it displays some content from the webpage itself.

Things I know are:

  1. If no meta description is provided, google takes the first 150 characters from the page itself and displays them.
  2. If I was using server-side rendering probably my problem would be fixed, but I have limitation to use static rendering since my hosting plan does not allow server-side rendering.
  3. We might think that the undefined comes out because when google crawls the webpage it collects the description before its value is retrieved from database. But why not the same for the title? Why it collects the title correctly and not the description? And by default, I have a title and description set statically in my pages and I only update their values once I get the response from database. So in the worst situation, why not displaying the static meta information instead of the undefined?
  4. Last, for some pages, and do not ask me why, google was able to retrieve the correct description from the database and it displays it correctly!



How to get mobile providers to update cached content more frequently?

I have new content on a Wordpress site that has updated on desktop view, but not mobile, even after clearing the browser cache.

I've purged my site, CDN and mobile browser caches.




HTTP response from upstream proxy (Cntlm) only correct if Burp Proxy used as intermediary proxy?

HTTP response from upstream proxy (Cntlm) only correct if Burp Proxy used as intermediary proxy?

I'm using a browser setup as follows:

Browser -> Burp -> Cntlm

For some reason, if I remove Burp from the equation and use Cntlm directly, then some webpages won't get displayed correctly, as can be seen below.

Anyone that has experienced something similar?

Browser -> Burp -> Cntlm

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/html;charset=utf-8
Vary: Accept-Encoding
Server: Microsoft-IIS/8.5
X-UA-Compatible: IE=EmulateIE9
X-UA-Compatible: IE=EmulateIE9
Date: Mon, 29 Jul 2019 14:33:41 GMT
Content-Length: 210
Proxy-Connection: keep-alive
Connection: keep-alive

{success:false,status:'5',userId:'0',isPartitionUser:false,loginMessage:'',message:'',reason:'',isICMUser:'0',isIntegrationEnabled:'false',time_frame_pref:'null',isSSOEnabledForUser:'true',isSSOLogin:'false'}

Browser-> Cntlm

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/html;charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/8.5
X-UA-Compatible: IE=EmulateIE9
X-UA-Compatible: IE=EmulateIE9
Date: Mon, 29 Jul 2019 14:22:24 GMT
Content-Length: 259
Proxy-Connection: keep-alive
Connection: keep-alive

��`I�%&/m�{J�J��t�`$ؐ@������iG#)�*��eVe]f@�흼��{���{���;�N'���?\fdl��J�ɞ!���?~|?"~q��N�yt��M>jڬ]7�>���h�������;���eV�E[T˯�Sm[V��




Thymeleaf templatespring boot jpa can't get data fom the dabase,404 error

: Resource not found
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : "ERROR" dispatch for GET "/error", parameters={}
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Writing [{timestamp=Mon Jul 29 05:04:25 PDT 2019, status=404, error=Not Found, message=No message available,  (truncated)...]
2019-07-29 05:04:25.835 DEBUG 18656 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Exiting from "ERROR" dispatch, status 404
2019-07-29 05:04:37.741 DEBUG 18656 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : GET "/favicon.ico", parameters={}
2019-07-29 05:04:37.742 DEBUG 18656 --- [nio-8080-exec-3] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler [class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/], class path resource []]
2019-07-29 05:04:37.754 DEBUG 18656 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : Completed 200 OK

The problem is data already exist in the database but it's not being displayed in HTML table

EmployerController.java

package io.javabrains;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.hibernate.mapping.Index;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.javabrains.Entity.Employer;

@Controller
public class EmployerController {


    @Autowired
    private EmployerService service;




    @RequestMapping("/")
    public String newForm() {
        return "form1";
    }






     public List<Employer>getAllEmployers()
     {


        return  service.getAllEmployers();



     }

        @RequestMapping(value="/tables",method=RequestMethod.GET)

    public String getAllEmployers(Model model)
    {
         List<Employer>employers = service.getAllEmployers(); 
        model.addAttribute("Employer",employers);
        return "tables";
    }





      @RequestMapping("/employer/{id}") 
      public Employer getEmployer(@PathVariable Integer id) { 
          return service.getEmployers(id);
      }



    @RequestMapping(method=RequestMethod.POST,value="/employer")
    public void addEmployer(@RequestBody Employer employer) {
        service.addEmployer(employer);

    }


    @RequestMapping(method=RequestMethod.PUT,value="/employer/{id}")
    public void updateEmployer(@RequestBody Employer employer,@PathVariable int id) {
        service.updateEmployer(id,employer);
    }




      @RequestMapping(method=RequestMethod.DELETE,value="/create/{id}") 
     public void deleteEmployer(@PathVariable int id)
     {
          service.deleteEmployer(id);
     }

EmployerService.java

package io.javabrains;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import io.javabrains.Entity.Employer;

@Service
public class EmployerService {
    @Autowired
    private Repository repository;

    public List<Employer>getAllEmployers(){
        List<Employer>employers = new ArrayList<>();
        repository.findAll()
        .forEach(employers::add);
        return employers;

    }

    public void addEmployer(Employer employer) {
        repository.save(employer);
    }


    public void updateEmployer(int id, Employer employer) {
        repository.save(employer);
    }


    public void deleteEmployer(int id) {
        repository.deleteById(id);
        ;
    }



      public Employer getEmployers(int id) 
      { 
          return repository.getOne(id);

      }





}

Employer.Java

package io.javabrains;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import io.javabrains.Entity.Employer;

@Service
public class EmployerService {
    @Autowired
    private Repository repository;

    public List<Employer>getAllEmployers(){
        List<Employer>employers = new ArrayList<>();
        repository.findAll()
        .forEach(employers::add);
        return employers;

    }

    public void addEmployer(Employer employer) {
        repository.save(employer);
    }


    public void updateEmployer(int id, Employer employer) {
        repository.save(employer);
    }


    public void deleteEmployer(int id) {
        repository.deleteById(id);
        ;
    }



      public Employer getEmployers(int id) 
      { 
          return repository.getOne(id);

      }





}

table.html

<tbody>
                    <tr th:each="$(employers)">
                      <td th:text="${employers.name}"></td>
                      <td th:text="${employer.position}"></td>
                      <td th:text="${employer.office}"></td>
                      <td th:text="${employer.age}"></td>
                     <td th:text="${employer.salary}"></td>
                    </tr>

......




Instafeed exclude by tag or post

I would like to exclude certain posts from the Instafeed. Either by tag or by some post ID. I know how to apply a filter that let's only pass images specified by tag:

  filter: function(image) {
    console.log(image);
    return image.tags.indexOf('thisTagPasses') >= 0;
  }

However, I have no idea how to exclude/skip certain images. Any idea's?




Spring boot Resource Not Found 404 error html

I built a crud application called Employer. Operations are working fine however when it comes to display them in html console shows error Not Found

: Resource not found
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : "ERROR" dispatch for GET "/error", parameters={}
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
2019-07-29 05:04:25.834 DEBUG 18656 --- [nio-8080-exec-1] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Writing [{timestamp=Mon Jul 29 05:04:25 PDT 2019, status=404, error=Not Found, message=No message available,  (truncated)...]
2019-07-29 05:04:25.835 DEBUG 18656 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Exiting from "ERROR" dispatch, status 404
2019-07-29 05:04:37.741 DEBUG 18656 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : GET "/favicon.ico", parameters={}
2019-07-29 05:04:37.742 DEBUG 18656 --- [nio-8080-exec-3] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler [class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/], class path resource []]
2019-07-29 05:04:37.754 DEBUG 18656 --- [nio-8080-exec-3] o.s.web.servlet.DispatcherServlet        : Completed 200 OK

I tried to restart the app and change the name of Entity,but it didnt work.Below are what I tried

EmployerController.java

package io.javabrains;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.hibernate.mapping.Index;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.javabrains.Entity.Employer;

@Controller
public class EmployerController {


    @Autowired
    private EmployerService service;




    @RequestMapping("/")
    public String newForm() {
        return "form1";
    }






     public List<Employer>getAllEmployers()
     {


        return  service.getAllEmployers();



     }

        @RequestMapping(value="/tables",method=RequestMethod.GET)

    public String getAllEmployers(Model model)
    {
         List<Employer>employers = service.getAllEmployers(); 
        model.addAttribute("Employer",employers);
        return "tables";
    }





      @RequestMapping("/employer/{id}") 
      public Employer getEmployer(@PathVariable Integer id) { 
          return service.getEmployers(id);
      }



    @RequestMapping(method=RequestMethod.POST,value="/employer")
    public void addEmployer(@RequestBody Employer employer) {
        service.addEmployer(employer);

    }


    @RequestMapping(method=RequestMethod.PUT,value="/employer/{id}")
    public void updateEmployer(@RequestBody Employer employer,@PathVariable int id) {
        service.updateEmployer(id,employer);
    }




      @RequestMapping(method=RequestMethod.DELETE,value="/create/{id}") 
     public void deleteEmployer(@PathVariable int id)
     {
          service.deleteEmployer(id);
     }




}

EmployerService.java

package io.javabrains;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import io.javabrains.Entity.Employer;

@Service
public class EmployerService {
    @Autowired
    private Repository repository;

    public List<Employer>getAllEmployers(){
        List<Employer>employers = new ArrayList<>();
        repository.findAll()
        .forEach(employers::add);
        return employers;

    }

    public void addEmployer(Employer employer) {
        repository.save(employer);
    }


    public void updateEmployer(int id, Employer employer) {
        repository.save(employer);
    }


    public void deleteEmployer(int id) {
        repository.deleteById(id);
        ;
    }



      public Employer getEmployers(int id) 
      { 
          return repository.getOne(id);

      }





}

Employer.Java

package io.javabrains;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import io.javabrains.Entity.Employer;

@Service
public class EmployerService {
    @Autowired
    private Repository repository;

    public List<Employer>getAllEmployers(){
        List<Employer>employers = new ArrayList<>();
        repository.findAll()
        .forEach(employers::add);
        return employers;

    }

    public void addEmployer(Employer employer) {
        repository.save(employer);
    }


    public void updateEmployer(int id, Employer employer) {
        repository.save(employer);
    }


    public void deleteEmployer(int id) {
        repository.deleteById(id);
        ;
    }



      public Employer getEmployers(int id) 
      { 
          return repository.getOne(id);

      }





}

table.html

 <tbody>
                    <tr th:each="$(employers)">
                      <td th:text="${employers.name}"></td>
                      <td th:text="${employer.position}"></td>
                      <td th:text="${employer.office}"></td>
                      <td th:text="${employer.age}"></td>
                     <td th:text="${employer.salary}"></td>
                    </tr>

....




Check out my website! (I know this is not a question but anyways.)

I know this is not a question but anyways just check my website out! It's my first website and I hope its not like a too low-level website for you. Its about the top 10 you-tubers 2019 July. Anyways, here's the link! Just click the link!




How to use a .net framework library (which consumes a wcf service) in a web api build in .net framework

        In my case I have 
        1. A library project built in .NET Framework 4.7.1 which consumes two WCF web services.
        2. An Web API built in .NET Framework 4.7.1 which consumes the above library project.


        In the above library project I create a system ServiceModel ChannelFactory using endpointConfiguration name and then consumes the WCF Web Service.

        The problem is I am not able to Create ChannelFactory instance and getting the exception "Attribute 'binding' is required on 'endpoint' element"

        I have copied the <system.serviceModel> configuration settings to the Web API Web.config. But no success. Looks like the system.serviceModel section is not getting loaded from web.config

Web.config

        <system.serviceModel>
            <bindings>
              <basicHttpsBinding>
                <binding name="HTTPMyService" maxReceivedMessageSize="2147483647" openTimeout="00:05:00" closeTimeout="00:05:00" sendTimeout="00:05:00"
                  receiveTimeout="00:05:00"/>
                <binding name="ServiceSoap">
                  <security mode="Transport"/>
                </binding>
                <binding name="ServiceSoap1"/>
              </basicHttpsBinding>
            </bindings>
            <client>
              <endpoint address="https://myservice.com:8444/MyService.svc/BasicHttpInt" binding="basicHttpsBinding"
                bindingConfiguration="HTTPSMyService" contract="MyService.MyService" name="CustomBinding_MyService1"/>
              <endpoint address="https://MobileAuthenticateService.com/MobileAuthenticate/Service.asmx" binding="basicHttpsBinding" bindingConfiguration="ServiceSoap"
                contract="MobileAuthenticationService.ServiceSoap" name="ServiceSoap"/>
            </client>
          </system.serviceModel>

WCF Client library

    namespace MyDemoServices
    {    
          public delegate void UseMobileAuthenticationServiceDelegate<T>(T proxy);

            public static class MobileAuthenticationServiceBase<T>
            {
                public static ChannelFactory<T> _channelFactory = new ChannelFactory<T>(ResolveBindingByName("ServiceSoap"));

                public static void Use(UseMobileAuthenticationServiceDelegate<T> codeBlock)
                {
                    IClientChannel proxy = (IClientChannel)_channelFactory.CreateChannel();
                    bool success = false;

                    try
                    {
                        codeBlock((T)proxy);
                        proxy.Close();
                        success = true;
                    }
                    finally
                    {
                    }
                }
        }
   }

Expectation is that WCF web service should be invoked successfully. I have investigated and found the the ConfigurationManager is not loading the from Web.config, but other sections like unity, logging , appsettings, and connection strings are getting loaded successfully.

Another point is when I explicitly load the Web.config using OpenMappedExeConfiguration then all settings and sections are getting loaded . Not sure what is going wrong here