Password-reset mechanism based on Sessions

I was wondering if the following password-reset mechanism is safe:

The user clicks on ‘I forgot my password’ and enters his mail. After he has submitted, a security_token gets generated. This token consists of the following combination: entered_email + timestamp + a randomized string of 15 truly random bytes. The randomized string is different for each reset.

This security token gets saved in a session-variable.

If the entered email-address exists in the database, we retrieve the ID of that user and also put that in a separate session-variable. Than a mail is sent to that mail-adres.

The mail contains a URL containing the security token. Like https://example.com/reset.php?key=THAT_RANDOM_SECURITY_TOKEN_THAT_IS_ALSO_SET_IN_SESSION_VAR.

After clicking that URL in the mail there is a check to see if the content of the url-parameter key matches with the security_token in the session variable. If it matches, the user’s password gets updated with the new password he has entered. We know which row to update because we also putted the user-id in a session variable.

I think this is save for the following reasons:

  1. The secret URL is hard to guess
  2. Even if someone intercepts the mail/secret token, he still needs to perform a session_hijack to put the security_token in his session variable.

c# – Unity – how to make a countdown timer based on localtime

I have a problem. In my GetTime.cs script, I am getting local Time from a android/ios, and simply assigning it to a Text component.

private void Update()
    {
        time = System.DateTime.Now.ToLocalTime().ToString("HH:mm:ss");
        timeText.text = time;      
    }

I am making a travel system, that takes X amount of seconds to get from point A to point B. While in travel, you cannot do any actions. How can I make a countdown timer based on localtime? For example, I want to do travel from point A to point B like that:
I am in point A, choosing option to travel to point B -> waiting 30s -> I am in point B
But it has to be on localtime, and it has to work in background, even when the app is not running.

MS Word: Automatically update text in file based on text above

I am trying to set up a Word file such that when a certain value is updated at the beginning of the document, all corresponding values in the rest of the document are changed. Therefore, how can I link certain text in my document to reference one specific piece of text.

I have tried playing around with Objects, however, I have not been able to find what I am looking for.

For example:

“Thomas is a cat.”

..further down in the document

“Since Thomas is a cat, he…”

If I change the first sentence to
“Thomas is a dog.”

then the second sentence should automatically change to

“Since Thomas is a dog, he..”

I will collect a niche based email list for $5

I will collect a niche based email list

I will provide you targeted emaillists of any business or country niche you need. If any business person or

company wants to start to advertise their own company products or something,

then the email list is the best way. If you want to promote your business

through email list,then you need an active and verified email list.I am an

expert at this kind of service. I have more than 5 years working experience in

this sector. Check my service bellow.
my service: 

any kind of bulk email list 

country or targeted city based email list 

any country email list 

targeted audience development

no duplication

active and verified email list 

any niche based email list 

clean and formatting database
why me: 

email list from any social media platform (instargram,facebook, linkedin, twitter, )

best service 

quick service

quality assurance

 

100% satisfaction guarantee

on time delivery 

I will provide you my best service.

note: when you post an order please give me your keyword ofbusiness and location name 

thank you.

.(tagsToTranslate)Emaillist(t)EMAILMARKETING(t)SOCAILMEDIA(t)verified(t)email(t)l

sharepoint server – jQuery hiding column based on another column’s value

Try adding below code on your EditForm.aspx page:

$(document).ready(function() {
    if ($("select(title='Check SharePoint?')").val() != "Yes") {
        $('nobr:contains("Date SharePoint Checked")').closest('tr').hide();
    }
    else {
        $('nobr:contains("Date SharePoint Checked")').closest('tr').show();
    }
});

OR*:

function runAfterPageLoads(){
    if ($("select(title='Check SharePoint?')").val() != "Yes") {
        $('nobr:contains("Date SharePoint Checked")').closest('tr').hide();
    }
    else {
        $('nobr:contains("Date SharePoint Checked")').closest('tr').show();
    }
}
_spBodyOnLoadFunctionNames.push("runAfterPageLoads");

If this doesn’t work then try one of the solutions given in my answer in below link:

Run Javascript after page loads

symbolic – How to define a function based on an operation with parameters

I would like to define a function as the output of another operation depending on a few parameters. For example

s[t1_,t2_]:= Integrate[t^n,{t,t1,t2}] 
s[0,1]

I only get back an echo s[0,1] rather than a function dependent on $a, n$. What is the correct format for the definition?

I tried the following.

s[n_,t1_,t2_]:= Integrate[t^n,{t,t1,t2}] 
s[2,0,1]

Edit:
I got a conditional expression after a long wait. How do I specify $n$ to be a real number for this integral?

python – How to update a column in sql based on another table’s last row, column value

I’m currently on the process of making a CRUD Database program. I’m having some trouble with the database. I would like to link 2 columns with each other. It’s quite different from usual though, it’s a little more complicated.

So, I have a table named items_list which have a column called ‘Item Name’ where each item has its own ‘Stock Count'(another column).

Each of these items then have their own table (item_name) which have columns of Date, Description, and Stock Count. I would like to know how I could connect these tables together so that when I add the latest stock count (with the latest date) into the (item_name) table, it would automatically update the ‘Stock Count’ in the items_list table.

Additionally, I would like to know how to automatically create a new table when a new item is added into the items_list.

I know it might be very confusing but if you have further questions, feel free to email me at owenn2106@icloud.com. Thank you so much in advance.

Below is the program code I have:

from tkinter import *
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
import sqlite3


def update(rows):
    tree.delete(*tree.get_children())
    for i in rows:
        tree.insert('', 'end', value=i)

def search():
    q2 = q.get()
    query = "SELECT TipeBarang, NoKartu, JumlahStok FROM items_list WHERE TipeBarang LIKE '%"+q2+"%'"
    cursor.execute(query)
    rows = cursor.fetchall()
    update(rows)

def clear():
    query = "SELECT TipeBarang, NoKartu, JumlahStok FROM items_list"
    cursor.execute(query)
    rows = cursor.fetchall()
    update(rows)

def getrow(event):
    rowid = tree.identify_row(event.y)
    print(rowid)
    item = tree.item(tree.focus())
    t1.set(item('values')(0))
    t2.set(item('values')(1))
    t3.set(item('values')(2))

def update_item():
    new = t1.get()
    new_card = t2.get()
    new_count = t3.get()
    if messagebox.askyesno('Confimation', 'Yakin ubah?'):
        query = "UPDATE items_list SET JumlahStok = ? WHERE TipeBarang = ? AND NoKartu = ?"
        parameters = (new_count, new, new_card)
        cursor.execute(query, parameters)
        clear()
    else:
        return True

def add_item():
    new = t1.get()
    new_card = t2.get()
    new_count = t3.get()
    if messagebox.askyesno('Confirmation', 'Tambah Barang Baru?'):
        query = "INSERT INTO items_list(TipeBarang, NoKartu, JumlahStok) VALUES(?, ?, ?)"
        parameters = (new, new_card, new_count)
        cursor.execute(query, parameters)
        clear()
    else:
        return True

def delete_item():
    item_id = ent1.get()
    if messagebox.askyesno('Confirmation', 'Yakin Hapus?'):
        query = "DELETE FROM items_list WHERE TipeBarang = "+"'"+item_id+"'"
        cursor.execute(query)
        clear()
    else:
        return True

def open_card_window():

    def update_small(rows):
        smalltree.delete(*smalltree.get_children())
        for i in rows:
            smalltree.insert('', 'end', value=i)

    def getrow_small(event):
        rowid = smalltree.identify_row(event.y)
        print(rowid)
        item = smalltree.item(smalltree.focus())
        text1.set(item('values')(0))
        text2.set(item('values')(1))
        text3.set(item('values')(2))
        text4.set(item('values')(3))
        text5.set(item('values')(4))

    def update_card():
        return True

    def add_card():
        return True

    def delete_card():
        return True

    card_content = Toplevel(root)
    card_content.title('Kartu Stok')

    text1 = StringVar()
    text2 = StringVar()
    text3 = StringVar()
    text4 = StringVar()
    text5 = StringVar()

    subframe1 = LabelFrame(card_content)
    subframe2 = LabelFrame(card_content, text='Ubah Konten')
    subframe1.pack(fill='both', expand='True', padx=20, pady=10)
    subframe1.config(bg='light grey')
    subframe2.pack(fill='both', expand='True', padx=20, pady=10)
    subframe2.config(bg='light grey')

    smalltree = ttk.Treeview(subframe1, height=20, columns=(1,2,3,4,5), show='headings')
    smalltree.pack(expand=True, fill='x')
    smalltree.heading(1, text='Tanggal')
    smalltree.heading(2, text='Keterangan')
    smalltree.heading(3, text='Masuk')
    smalltree.heading(4, text='Keluar')
    smalltree.heading(5, text='Total Stok')

    smalltree.bind('<Double 1>', getrow_small)


    #User Data Section
    label1 = Label(subframe2, text='Tanggal:')
    label1.grid(row=0, column=0, padx=5, pady=3)
    label1.config(bg='light grey')
    entry1 = Entry(subframe2, textvariable=text1)
    entry1.grid(row=0, column=1, padx=5, pady=3)

    label2 = Label(subframe2, text='Keterangan:')
    label2.grid(row=1, column=0, padx=5, pady=3)
    label2.config(bg='light grey')
    entry2 = Entry(subframe2, textvariable=text2)
    entry2.grid(row=1, column=1, padx=5, pady=3)

    label3 = Label(subframe2, text='Masuk:')
    label3.grid(row=2, column=0, padx=5, pady=3)
    label3.config(bg='light grey')
    entry3 = Entry(subframe2, textvariable=text3)
    entry3.grid(row=2, column=1, padx=5, pady=3)

    label4 = Label(subframe2, text='Keluar:')
    label4.grid(row=3, column=0, padx=5, pady=3)
    label4.config(bg='light grey')
    entry4 = Entry(subframe2, textvariable=text4)
    entry4.grid(row=3, column=1, padx=5, pady=3)

    label5 = Label(subframe2, text='Total:')
    label5.grid(row=4, column=0, padx=5, pady=3)
    label5.config(bg='light grey')
    entry5 = Entry(subframe2, textvariable=text4)
    entry5.grid(row=4, column=1, padx=5, pady=3)

    upd_crd = Button(subframe2, text='Update', command=update_card)
    add_crd = Button(subframe2, text='Add New', command=add_card)
    del_crd = Button(subframe2, text='Delete', command=delete_card)

    add_crd.grid(row=5, column=0, padx=5, pady=3)
    upd_crd.grid(row=5, column=1, padx=5, pady=3)
    del_crd.grid(row=5, column=2, padx=5, pady=3)

    item_id = ent1.get()
    query = "SELECT * FROM "+"'"+item_id+"'"
    cursor.execute(query)
    rows = cursor.fetchall()
    update_small(rows)


#Connecting to Database
db = sqlite3.connect('stok.db')
cursor = db.cursor()

root = Tk()
q = StringVar()
t1 = StringVar()
t2 = StringVar()
t3 = StringVar()

#SUB-FRAMES
wrapper1 = LabelFrame(root, text='List Stok')
wrapper2 = LabelFrame(root, text='Search')
wrapper3 = LabelFrame(root, text='Update Data')
wrapper1.pack(fill='both', expand='True', padx=20, pady=10)
wrapper1.config(bg='light grey')
wrapper2.pack(fill='both', expand='True', padx=20, pady=10)
wrapper2.config(bg='light grey')
wrapper3.pack(fill='both', expand='True', padx=20, pady=10)
wrapper3.config(bg='light grey')

#TREEVIEW
tree = ttk.Treeview(wrapper1, height=17, columns=(1,2,3), show='headings')
tree.pack(expand=True, fill='x')
tree.heading(1, text='Tipe Barang')
tree.heading(2, text='Nomor Kartu')
tree.heading(3, text='Jumlah Stok')

ttk.style = ttk.Style()
ttk.style.configure('Treeview', font=('helvetica',16))
ttk.style.configure('Treeview.Heading', font=('helvetica', 18, 'bold'))

tree.bind('<Double 1>', getrow)

query = 'SELECT TipeBarang, NoKartu, JumlahStok FROM items_list'
cursor.execute(query)
rows = cursor.fetchall()
update(rows)

#Search Section
searchfield = Entry(wrapper2, textvariable=q)
searchfield.pack(side=tk.LEFT, padx=25)
btn= Button(wrapper2, text='Search', command=search)
btn.pack(side=tk.LEFT, padx=6)
clr = Button(wrapper2, text='Clear', command=clear)
clr.pack(side=tk.LEFT, padx=6)

#User Data Section
lbl1 = Label(wrapper3, text='Tipe Barang:')
lbl1.grid(row=0, column=0, padx=5, pady=3)
lbl1.config(bg='light grey')
ent1 = Entry(wrapper3, textvariable=t1)
ent1.grid(row=0, column=1, padx=5, pady=3)

lbl2 = Label(wrapper3, text='Nomor Kartu:')
lbl2.grid(row=1, column=0, padx=5, pady=3)
lbl2.config(bg='light grey')
ent2 = Entry(wrapper3, textvariable=t2)
ent2.grid(row=1, column=1, padx=5, pady=3)

lbl3 = Label(wrapper3, text='Jumlah Stok:')
lbl3.grid(row=2, column=0, padx=5, pady=3)
lbl3.config(bg='light grey')
ent3 = Entry(wrapper3, textvariable=t3)
ent3.grid(row=2, column=1, padx=5, pady=3)

upd_btn = Button(wrapper3, text='Update', command=update_item)
add_btn = Button(wrapper3, text='Add New', command=add_item)
del_btn = Button(wrapper3, text='Delete', command=delete_item)

open_card = Button(wrapper3, text='Open Card', command=open_card_window)

add_btn.grid(row=5, column=0, padx=5, pady=3)
upd_btn.grid(row=5, column=1, padx=5, pady=3)
del_btn.grid(row=5, column=2, padx=5, pady=3)
open_card.grid(row=1, column=3, padx=10)

root.title('Stok Barang Sumber Makmur')
root.configure(background='light grey')
root.geometry('800x700')
root.mainloop()

Note: the column names are in Bahasa Indonesia. Where TipeBarang basically means Item Name and JumlahStok is Stock Count

What’s the use of a wide-column NoSQL db such as Cassandra over a K-V store or a document based db?

Say we’re making a simple photo app. This link says that we can store the image in S3 and now have a URL. Great. Next, we need a mapping of a UserID to the many images they’ve created. For this, it recommends Cassandra where the key would be UserID and the value would be the list of PhotoIDs stored in different columns.

However, why can’t we use a document DB like mongo instead? It can have something like:

{
    “UserID” : abc
    “PhotoIDs” : {
           url1,
           url2,
           url3,
            ..
      }
}
    

Or a persistent K-V store like DynamoDB?

What is Cassandra’s column-based storage giving us here that these don’t?

I realize that the unbounded nature of photoURLs could be an issue. Say a user has 10,000 photos, adding one to this would mean fetching the 10,000 item large document, adding to it and then updating the document. But does cassandra solve that? Would it be able to have 10k columns for that one prolific user?