samedi 1 juillet 2017

Youtube on my website

I am developing a web page and I am interested in knowing how I can do that when I upload a video on my youtube channel you leave my web page automatically




Regular border + offset border on button using CSS

css button with double border

I'm trying to acheive the same border effect on the button above.

The closest I can get is the following, but the bottom right corner of the bottom border is not properly rounded:

>

.login__button {
  background: transparent;
  border: none;
  border-width: 2px 1px 2px 2px;
  border-style: solid;
  border-color: pink;
  border-radius: 4px;
  color: pink;
  margin-bottom: 100px;
  position: relative !important;
  text-transform: uppercase;
  height: 33px;
  width: 102px;
  box-shadow:
    3.5px 4px 0px black,
    1.5px 0px 0px pink,
    3.5px 4px 0px black,
    2px 6px 0px pink;
}

.login__button::before {
  background: pink;
  content: '';
  position: absolute;
  height: 35px;
  width: 3.0px;
  border-radius: 3px;
  top: 3%;
  right: -2.8px;
}

>

I feel like this should be possible using just box-shadows but there doesnt appear to be a way to modify the width of the box shadow to get just the black portion inset properly.




what does / means in app.get('/',function(){...}); in express.js?

I just started learning express.js and in that, we do app.get('/'.function(){...});, i want to know what does that / means.I tried to look into google but really couldn't get which will simply describe it without getting too technical.




Angular 2/4 site and direct linking from browser to page?

tell me please.

I make a site on Angular 2/4. Accordingly, there is routing. In the browser when I navigate through the links according to mysite.com/dashboard, the corresponding content is displayed, everything is fine.

But if I directly enter this address in the browser, I get 404. It's logical, because on the backend I have only one route in nginx.

How is this problem solved, and is it possible to solve it? How in this case to share a link to a certain page of the site?

Thanks.




How to draw a picture in web app using Racket?

I'm looking for a way of drawing a pictures in my simple web-app. Basically i'm trying to submit a picture of circle using standard slideshow library, but it doesn't work and i have no idea why. Here is a sample:

#lang web-server/insta

(require slideshow)

(define (start request)
  (response/xexpr '(html
                     (body (circle 10))
                     )
  )
)

Could you tell me a hint how can i draw pictures using standard utils at my html page?

Thank you.




Golang User cookie verification fails randomly

I'm using two structs to hold user's info

// SecureDevice holds a user's device's infos
type SecureDevice struct {
    Name     string // Defined by the user
    DeviceIP string
    Token    struct {
        Token        string
        StartingDate time.Time // The token is supposed to last only a week before becoming invalid
    }
}

// GlobalUser is a struct defining all user's infos registered inside the server
type GlobalUser struct {
    Username          string
    Password          string
    Salt              string
    Mail              string
    ValidationToken   string // Used to validate the user's mail adress
    Lang              string
    ConversationsID   []int // The private messages the user has part in
    SecureDevicesList []SecureDevice
}

And I'm using a function to check if the user is logged in

// IsLoggedIn checks if client's token is valid
func IsLoggedIn(r *http.Request) string {
    ips := strings.Split(r.Header.Get("X-Forwarded-For"), ", ")
    ip := ips[0]
    cookie, err := r.Cookie("auth")
    if err != nil {
        return "ERR$" + "not_connected"
    }
    cookieValue := strings.Split(cookie.Value, "$")
    println(cookie.Value)
    user := GetUser(cookieValue[0])
    userToken := cookieValue[1]
    if user.Username == "" {
        return "ERR$" + "error"
    }
    for _, SecureDevice := range user.SecureDevicesList {
        if SecureDevice.DeviceIP == ip && SecureDevice.Token.Token == userToken { // We make sure that the token provided is actually the user's token
            if time.Since(SecureDevice.Token.StartingDate)*time.Hour >= 168 { // If token is older than 1 week, we throw it away
                return "ERR$" + "error_token_expired"
            } else if time.Since(SecureDevice.Token.StartingDate)*time.Second >= 30 { // If it's age is between 1 hour and one week, we renew it
                db, err := scribble.New("./brony/db", nil)
                if err != nil {
                    return "ERR$" + "error_internal"
                }
                tokenBytes, err := GenerateRandomBytes(64) // Generates a salt
                if err != nil {
                    return "ERR$" + "error_internal"
                }
                token := base64.URLEncoding.EncodeToString(tokenBytes)
                SecureDevice.Token.Token = token
                SecureDevice.Token.StartingDate = time.Now()
                errr := db.Write("users", user.Username, user)
                if errr != nil {
                    return "ERR$" + "error_internal"
                }
                return "TOK$" + user.Username + "$" + SecureDevice.Token.Token
            } else if time.Since(SecureDevice.Token.StartingDate)*time.Hour <= 1 {
                return "NIL$"
            }
        } else if SecureDevice.DeviceIP == ip {
            return "ERR$" + "error_bad_token"
        }
    }
    return "ERR$" + "error_device_not_registered"
}

But almost always when I load the page with

status := IsLoggedIn(r)
println(status)

It often gives me an error, since I'm printing "IsLoggedIn" to understand where the problem comes from

At first I thought it was my token's renewal code which was faulty, but while beeing faulty and unfinished, it doesn't seem to be it's fault since after a few f5, it said that the cookie was ok. I really don't understand where the fault is, and it's starting to get really annoying, as I can't just let it be, it would be very annoying to say the least for a user to do f5 everytime and hope that when the page will refresh, it will miraculously work. The code runs on a debian server




Website rendering differently from the local version

I'm having a strange problem where the local index.html that I open isn't being presented the same way as the index.html being hosted on my domain. Here is the CSS:

/*
==========================
Universal
==========================
*/

* {
  font-family: "Heebo";
}

h1 {
  font-size: 4rem;
  color: #4d4d4d;
}

h4 {
  font-size: 2rem;
  color: #0072ff;
}

h2 {
  font-size: 3rem;
  color: #0072ff;
  padding: 2rem 2rem;
}

p {
  line-height: 2rem;
  padding: 0 2rem;
  font-size: 1.5rem;
  color: #4d4d4d;
}

a {
  outline: none;
}

.center {
  margin-left: auto;
  margin-right: auto;
}

.center-text {
  text-align: center;
}

.center-v {
  display: flex;
  align-items: center;
}

/*
==========================
Home
==========================
*/

.hero {
  background-color: #ffffff;
}

.intro {
  padding-top: 5rem;
}

.img-circle {
  border-radius: 50%;
}

.hero-link {
  color: #000000;
  font-size: 3rem;
}

.fa {
  font-size: 5.5rem;
  padding: 0.5rem 2rem;
  color: #4d4d4d;
}

.fa:focus {
  color: #4d4d4d;
}

.fa:hover {
  color: #0072ff;
}

.fa-home {
    font-size: 3rem;
    position: fixed;
}

.fa-project {
    color: #ffffff;
    z-index: 11;
  font-size: 4rem;
  position: absolute;
  bottom: 0;
  right: 0;
}

/*
==========================
Project tiles
==========================
*/

@media (max-width: 1000px) {
  #project-break {
    width: 100%;
    margin-left: 0;
  }
}

.tile {
  height: 27rem;
  width: 100%;
  margin:10px;
  display:inline-block;
  background-size:cover;
  position:relative;
  cursor:pointer;
  -webkit-transition: all 0.4s ease-out;
  -o-transition: all 0.4s ease-out;
  -moz-transition: all 0.4s ease-out;
  -ms-transition: all 0.4s ease-out;
  transition: all 0.4s ease-out;
  box-shadow: 0px 35px 77px -17px rgba(0,0,0,0.44);
  overflow:hidden;
  color:white;
}

.tile img {
  height:100%;
  width:100%;
  position:absolute;
  top:0;
  left:0;
  z-index:0;
    -webkit-transition: all 0.4s ease-out;
  -o-transition: all 0.4s ease-out;
  -moz-transition: all 0.4s ease-out;
  -ms-transition: all 0.4s ease-out;
  transition: all 0.4s ease-out;
}

.tile .text {
    z-index: 11;
  position:absolute;
  padding:30px;
  height:calc(100% - 60px);
}

.tile h1 {
    color: #ffffff;
  font-size: 2rem;
  font-weight:300;
  text-shadow: 2px 2px 10px rgba(0,0,0,0.3);
}

.tile p {
    color: #ffffff;
  font-weight: 300;
  margin: 20px 0 0 0;
    -webkit-transform: translateX(-200px);
    -o-transform: translateX(-200px);
    -moz-transform: translateX(-200px);
    -ms-transform: translateX(-200px);
  transform: translateX(-200px);
  transition-delay: 0.2s;
}

.animate-text {
  opacity:0;
  -webkit-transition: all 0.6s ease-in-out;
  -o-transition: all 0.6s ease-in-out;
  -moz-transition: all 0.6s ease-in-out;
  -ms-transition: all 0.6s ease-in-out;
  transition: all 0.6s ease-in-out;
}

.tile:hover {
  box-shadow: 0px 35px 77px -17px rgba(0,0,0,0.64);
  -webkit-transform: scale(1.05);
  -o-transform: scale(1.05);
  -moz-transform: scale(1.05);
  -ms-transform: scale(1.05);
  transform: scale(1.05);
}

.tile:hover img {
  opacity: 0.2;
}

.tile:hover .animate-text {
  -webkit-transform: translateX(0);
  -o-transform: translateX(0);
  -moz-transform: translateX(0);
  -ms-transform: translateX(0);
  transform: translateX(0);
  opacity:1;
}

/*
.tile:hover span {
  opacity:1;
  transform:translateY(0px);
    -webkit-transform:translateY(0px);
    -o-transform:translateY(0px);
    -moz-transform:translateY(0px);
    -ms-transform:translateY(0px);
}
*/

@media (max-width: 550px) {
    .tile h1 {
        font-size: 2rem;
    }

    .tile p {
        font-size: 1.3rem;
        line-height: 1.5rem;
    }
}

.fa-fade {
    -webkit-transition: all 0.2s ease-in-out;
    -o-transition: all 0.2s ease-in-out;
    -moz-transition: all 0.2s ease-in-out;
    -ms-transition: all 0.2s ease-in-out;
    transition: all 0.2s ease-in-out;
}

.pomodoro {
  background-image: url("assets/pomodoro-site.png");
    background-position: center;
}

.duelr {
  background-image: url("assets/duelr-site.png");
    background-position: center;
}

.grt-bot {
  background-image: url("assets/grt-site.png");
    background-position: center;
}

.pomodoro:after,
.duelr:after,
.grt-bot:after {
  content: " ";
  z-index: 10;
  position: absolute;
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
}

p > a {
    color: #ffffff;
}

p > a:hover {
    color: #0072ff;
}

As a visual example, here is my font-size which is set to 1.5rem in the CSS. I know rem units scale with the window size, but both are being opened on the same device:

index.html Domain