<commit_before># -*- coding: utf-8 -*-

require 'sqlite3'

@database_yml = ARGV[0]

@nomnichi_db = SQLite3::Database.new("nomnichi.sqlite3")
print "User : "; user = gets.chomp
print "Pass : "; pass = gets.chomp
salt = '<PASSWORD>'#Time.<PASSWORD>.to_s
puts salt
pass_sha = `echo -n '#{salt}#{pass}' | shasum`.chomp.split(' ').first

puts pass_sha
max_id_sql = <<SQL
select max(id) from user;
SQL
id = @nomnichi_db.execute(max_id_sql).flatten.first.to_i + 1

add_user_sql = <<SQL
insert into user values (#{id}, '#{user}', '#{pass_sha}', '#{salt}');
SQL
@nomnichi_db.execute(add_user_sql)


# yaml_data = YAML.load_file("./#{@database_yml}")
# into_article_table(yaml_data)
@nomnichi_db.close
<commit_msg>Fix bug in script to add user to sqlite3<commit_after># -*- coding: utf-8 -*-

require 'sqlite3'
require 'digest/sha1'

@nomnichi_db = SQLite3::Database.new("nomnichi.sqlite3")

print "User : "; user = gets.chomp
print "Pass : "; pass = gets.chomp

salt = Time.now.to_s

pass_sha = Digest::SHA1.hexdigest(salt + pass)

max_id_sql = <<SQL
select max(id) from user;
SQL
id = @nomnichi_db.execute(max_id_sql).flatten.first.to_i + 1

add_user_sql = <<SQL
insert into user values (#{id}, '#{user}', '#{pass_sha}', '#{salt}');
SQL
@nomnichi_db.execute(add_user_sql)

@nomnichi_db.close

{'fraction_non_alphanumeric': 0.17990654205607476, 'fraction_numerical': 0.010903426791277258, 'mean_word_length': 5.330049261083744, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2718492', 'n_tokens_mistral': 535, 'n_tokens_neox': 524, 'n_words': 108}