• Breaking News

    Friday, July 13, 2018

    How to setup JWT on PHP Ask Programming

    How to setup JWT on PHP Ask Programming


    How to setup JWT on PHP

    Posted: 13 Jul 2018 07:06 PM PDT

    Hello friends, I really need some help at this point after working for days with no solution

    I am trying to implement a jwt based authentication on an ANGULAR 2+PHP App

    And I'm trying to make some resource protected (a Json list of users from a db table)

    Here is what I've done so far:

    Imported JWT to my project

    Made an encoded secret key and stored it in my config.php script

    Created my encoded token with user details after login and also with my secret key from config.php

    Now, how do I protect this resource? What should be in the resource php script

    I know I'm suppose to add an authorization header with the user token when making a request to that page from my client But what do I need to add in the php script to make it secure until when authenticated..

    Mind my English. Help if you understand my troubles

    submitted by /u/OLayemii
    [link] [comments]

    What protocol does Facebook Messenger rely on?

    Posted: 13 Jul 2018 08:41 AM PDT

    Or twitter's inbox messages or LinkedIn's inMessages? Do they all use the same protocol?

    submitted by /u/nehri97
    [link] [comments]

    How can I automate a simple text field entry using the Chrome console?

    Posted: 13 Jul 2018 06:54 PM PDT

    Relevant image: https://i.imgur.com/wTcGaVe.jpg

    I'm going through this Microcorruption CTF, and I'd like to repeat the action of entering "s" into the text field shown in the left side of the picture, and each time logging the inner value of a specific element. Is there a way I can do this with a console command, so I don't have to manually send an 's' each time?

    If it help at all, this is what the Network tab looks like after entering the command. It looks like it's loading microcorruption.com/cpu/step

    submitted by /u/speuleralert
    [link] [comments]

    What warnings do you have in your UI that indicate it is in development mode?

    Posted: 13 Jul 2018 09:47 AM PDT

    Where I work we have some additional CSS which is loaded in development mode which makes the header bar bright red, which makes it incredibly easy to distinguish production and development from a glance (it also goes green on staging).

    What do you have in your projects to warn you about what mode your application is in?

    submitted by /u/jackwilsdon
    [link] [comments]

    Trying to automatically set volume on an html <video> tag

    Posted: 13 Jul 2018 05:35 PM PDT

    This is my html code, .music.php is a php script that randomizes the video that gets played on the page.

    <video autoplay controls loop width="150px" height="300px" volume=0.2 src=".music.php" id="VIDEOPLAY"> 

    This is the php script

    <?php // Array of file paths $music = array( '.Music/1.webm', '.Music/2.webm', '.Music/3.webm', '.Music/4.webm', '.Music/5.webm', '.Music/6.webm', '.Music/7.webm', '.Music/8.webm', ); // Redirect to a random file from the above array using status code "303 See Other" if (headers_sent() === false) { header('Location: '.$music[array_rand($music)], true, 303); } 

    Right now the video will play at full volume, id like to set it at a specific volume level or save the clients volume setting whenever they come back to the page, whichever one is easier works.

    submitted by /u/Myspeld
    [link] [comments]

    A new coder in need of help

    Posted: 13 Jul 2018 01:41 PM PDT

    Ok, so I made a program in C to count change, but whenever I try to use it and enter a multiple of 5, it says that there is one penny when there shouldn't be. I've went through the logic of the program and messed with the code for awhile, and I don't see where this extra penny is coming from. Can someone please tell me where I made a faux pas?

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    #include <stdio.h>

    #include <cs50.h>

    int main(void)

    {

    //variables

    int c = 0;

    float q;

    float d;

    float n;

    float p;

    //get change

    float m = get_float("How much change? ");

    //find quarter #

    for(q = 1; q * .25 <= m; q++)

    {

    c++;

    }

    //fix quarter variable

    float q2 = q - 1;

    //get rest of money

    float m2 = m - (q2 * .25);

    //get dime #

    for(d = 1; d * .10 <=m2; d++)

    {

    c++;

    }

    //fix dime #

    float d2 = d - 1;

    //get rest of money

    float m3 = m2 - (d2 * .10);

    //get nickels

    for(n = 1; n * .05 <= m3; n++)

    {

    c++;

    }

    //fix nickel #

    float n2 = n - 1;

    //get rest of money

    float m4 = m3 - (n2 * .05);

    for (p = 0; p * .01 < m4; p++)

    {

    c++;

    }

    printf ("coinies %i\n", c);

    printf ("quarters %f\n", q2);

    printf ("dimes %f\n", d2);

    printf ("nickles %f\n", n2);

    printf ("pennies %f\n", p);

    printf ("m2 %f\n", m2);

    printf ("m3 %f\n", m3);

    printf ("m4 %f\n", m4);

    }

    submitted by /u/tbone6272001
    [link] [comments]

    how safe is this code? (everything included)

    Posted: 13 Jul 2018 05:11 PM PDT

    where is this software on the entire web?

    • nobody seems to know of a software app that does this, im assuming it exist in 2018 tho

    • macos, win10

    timeframe to make

    • i also wanted to know what's the expereince/knoweldge-equivalent to academic classes/semesters to make something liek this

    • they were self-taught so pretty hard to guesstimate/approximate

    comptuer secrutiy

    • while anyone could just put links on their site to download (and i never check if the things i download are safe)

    • and since that is not that diff from reddit, why even check if it's safe?

    • (any sites that auto-checks btw?)

    verification of the safeness is still from a reddit user so it kinda doesnt make sense to ask this.. but this is mitigated & hedged cos it's typically very easy to tell the quality of a user

    submitted by /u/understandthings100
    [link] [comments]

    My function only works for smaller numbers and timeouts on bigger ones.

    Posted: 13 Jul 2018 03:31 PM PDT

    #include <iostream> #include <vector> #include <string> #include <algorithm> #include <list> #include <map> #include <set> using namespace std; bool prime(long long num) // Find if a number is prime { if (num < 12) { return false; } for (double i = 2; i < num; i++) { for (double z = 2; z < num; z++) { if (num / i == z) { return false; } } } return true; } string backwardsPrime(long long start, long long end) // Find only primes which are also prime when read backwards. { string pnums; for (long long i = start; i < end; i++) { if (prime(i))// if i is prime. { string a = to_string(i); // Change i to string and set it to a. string b = a; // Make a copy of a to switch numbers with it. for (int z = 0; z < a.size(); z++) { if (!a.empty()) { a[z] = b[a.size() - 1 - z]; // Set the zth char in a equal the last char minus z. } } if (prime(stoll(a))) // If the new backward number of the original prime i is also prime. { pnums += to_string(i) + " "; // Add the original prime number to pnums. } } } pnums.erase(pnums.end() - 1); // When done erase the last char " ". return pnums; } int main() { cout << backwardsPrime(2, 500) << endl; //This one works. cout << backwardsPrime(9900, 10000) << endl; //This one and bigger numbers timeout. system("PAUSE"); return 0; } 
    submitted by /u/Beerato123
    [link] [comments]

    Guid vs Id, which do you prefer?

    Posted: 13 Jul 2018 11:38 AM PDT

    My team is building a project that will hopefully eventually store terabytes of data, the dataset is real-time and historical status data for tens of thousands of components. Most of the initial code is already implemented using Id's as primary keys, I've migrated the entire project over to Guid primary keys on a separate branch over the last few days.

    Real-time status data will be stored in an SQL database with a redis cache, the historical data will be stored in InfluxDB with a redis cache.

    The main reason I want to migrate to Guids is because data stored by this system will eventually used by 5-10 other systems that my team doesn't own the codebase for, those systems may also store specific subsets of those data based on their function.

    The only downside I can think of is that I'll be adding an additional 8 Bytes to the Identifier of each item, however storage and compute is pretty cheap these days and my company has both in abundance.

    submitted by /u/SilentChiller
    [link] [comments]

    Python program plays audio but doesn't open Tkinter Window

    Posted: 13 Jul 2018 02:39 PM PDT

    My script plays the audio but doesn't open the Tkinter window. Either it plays the sound, or (if I remove the audio) it opens the window. I want my program to do both-- play the sound and open the Tkinter window automatically. I don't want the user to have to press a button, or anything like that. Can someone help me?

    Here's my code:

    import winsound import time from tkinter import * winsound.PlaySound("sound.wav", winsound.SND_LOOP) root = Tk() root.geometry("1024x768") root.title("Cargo Bay Control") root.resizable(FALSE, FALSE) lcars_img = PhotoImage(file = "lcars3.png") lcarspack = Label(root, image = lcars_img).place(x = 0, y = 0) add_category = Button(root, text = "Add Category", bg = "darkorange", fg = "black", font = "arial, 15") add_category.config(width = "15", height = "3") add_category.place(x = 200, y = 100) def placeCB_List(x): CBaysPage = Frame(root).place(x = 0, y = 0) lcarsimg2 = PhotoImage(file = "lcars4.png") lcarsimg2pack = Label(CBaysPage, image = lcarsimg2).place(x = 0, y = 0) view_cargobay = Button(root, text = "View Cargobay...", bg = "cornflowerblue", fg = "black", font = "arial, 15") view_cargobay.config(width = "15", height = "3") view_cargobay.bind("<Button-1>", placeCB_List) view_cargobay.place(x = 400, y = 100) ######################################### def printString(string): """ Typewriter animation for welcome Label """ for char in string: Label.configure(text=Label.cget('text') + char) Label.update() time.sleep(.25) text = "Welcome to your Cargo Bay Control console. To add a new food category, \n \ click the 'Add Category' button. To view the inventory of a specific Cargo Bay, select the\n 'View Cargo Bay...' button." Label = Label(root, font = ("arial", "15", "bold"), bg = "darkorange") Label.place(x = 165, y = 300) printString(tex root.mainloop() 
    submitted by /u/Polymatheo
    [link] [comments]

    Testing Strategies for Enterprise Java Web App?

    Posted: 13 Jul 2018 12:00 PM PDT

    For years I've written code -- mostly Java EE, but also lots of Objective-C and Swift, much of it for very critical applications -- and did very informal testing. Many of these were CRUD-type applications, so my testing consisted of creating a class that saved a bunch of test data to a database. Then, I'd load up my UI and make sure the results were what I was expecting. Obviously, this is not good coding practice. While effective, it also makes it very easy to overlook bugs or introduce new ones in code that previously worked. I'd like to change that moving forward.

    A couple of coworkers and I are about to start on a new enterprise app that will provide some critical functionality for the company. It is a Java EE app, deployed on Wildfly. We will be making use of JPA for data persistence, and JAX-RS services (annotated as stateless EJBs) to provide the services layer. We haven't decided on a UI framework yet, but it will either be based on Angular 2, or deployed as a JSF application. The primary nature of the app will be CRUD operations. Create some records, performing some basic processing and aggregation, then view the records in a different format. My question is, what should our strategy be for testing? What is considered a "standard" way of testing apps like this?

    I've written unit tests in the past using JUnit. I've found them great for testing classes that perform calculations, transformations, etc. What about code that isn't as self-contained? Unit tests are supposed to be small and self-contained. My Data Access classes fall more in line with integration tests. Do I wedge JUnit in there to accomplish this? Or is there a better way? How do I handle the underlying database itself? Rollback the transaction? What about testing my JAX-RS services? Do I test them as Java classes? Or do I test them as RESTful endpoints? I've heard mention of Arquillian as a good framework for unit/integration tests. Is this a recommended way of performing these kinds of tests? Are there any tools like IDE plugins (preferably for Eclipse, but I can settle for IntelliJ IDEA or NetBeans) to make setting up these tests easier? The little I've seen in tutorials for Arquillian makes it look like setting up the test environment (embedded Wildfly, etc.) is a bit involved.

    Our eventual goal is to have sufficient test coverage that we're testing more than just during development, but immediately prior to deployment, too. Our plan is to have a full CI/CD pipeline for deployment into our AWS environment. I'd greatly appreciate hearing your opinions, advice, experience, etc. Like I said, we'd like to make sure that we're doing things the RIGHT way from the very beginning with this project.

    submitted by /u/purplepharaoh
    [link] [comments]

    Is Laravel a good framework for building multi-sided marketplaces?

    Posted: 13 Jul 2018 11:25 AM PDT

    I know that Udemy uses Django, and was wondering if Laravel is a good framework to build a service marketplace.

    submitted by /u/gbentrepreneur
    [link] [comments]

    WordPress - Making thumbnail image size fit into frame

    Posted: 13 Jul 2018 08:47 AM PDT

    I'm beginner in WordPress but have a solid grasp of CSS and HTML. I don't know how this all works together but also can't seem to figure out what/how to change in my settings so my thumbnails (featured image) can, by default, fit into frame I've marked with red rectangle:

    https://imgur.com/GUmF3Sn

    submitted by /u/maybenexttime82
    [link] [comments]

    Help with robotic process automation!

    Posted: 13 Jul 2018 06:58 AM PDT

    Hey guys, Im working on a project and i need to know if this is possible or not, and if not what would be the best avenue to take.

    So what I want to do is take data from excel and have it linked to a Word document. I know how to do this, but I want each new line in excel to generate a new word document for the data in that row.

    Context: it's creating reports for my companies partners, so there's a bunch of information that needs to be compiled into a review for each one of them. And I'm looking for an easy way to go about it.

    Currently I have SQL and excel to work with, any ideas guys?

    submitted by /u/Steven054
    [link] [comments]

    No comments:

    Post a Comment