attempting to write with unique constraint or handle from script

I created a script that is taking data from an outside source and writing it into a mysql database. Which would you recommend for preventing duplicates from ending up in the database?

One option I can think of is to enable the unique constraint so that a duplicate value is not stored, but if the script attempts to write the value to the database, then the database has to spend some time determining if the value already exists. The other option I thought of is to initialize a list or set of data from the database each time the script runs and before the script attempts to write to the database, it can cross reference if the value exists in the list that was initialized at the start. From a performance standard, what makes the most sense? Is there something I didn’t consider?

Пропажа Handle [СИ]

Использую CreateProcess.

if (CreateProcess(     "TreeSer.exe",      // имя исполняемого модуля      NULL,              // командная строка      NULL, NULL,        // SDs      true,             // дескриптор параметра наследования      CREATE_NO_WINDOW,  // флажки создания      NULL,              // новый блок конфигурации      NULL,              // имя текущего каталога      &StartupInfo,      // информация предустановки      &ProcessInfo)      // информация о процессе      == false){       printf("ERROR!!!");       if (PauseOnExit == true) system("pause");       return 41;      } 

Далее, по идее хэндл получен в ProcessInfo.hProcess.

if (WaitForSingleObject(ProcessInfo.hProcess, 1000) == WAIT_TIMEOUT){          return 41;         } 

Но, как оказалось – нефига

И отправка SendMessage тоже не доходит:

SendMessage(ProcessInfo.hProcess, WM_COMMAND, (WPARAM) STARTTREE, NULL); 

Код TreSer.exe:

#pragma hdrstop #pragma argsused  // STD  библиотеки и заголовки #include <stdio.h> #include <stdbool.h> #include <conio.h> #include <stdlib.h>  // Windows библиотеки и заголовки #include <windows.h>  // Пределы переменных #include <limits.h>  // Работа со строками #include <String.h>   enum TreeTCommands {     STARTTREE, // Создание дерева-потока         STOPTREE, // Удаление дерева-потока         ADDTREE, // Добавление элемента в дерево         GETMAXTREE, // Найти максимальный элемент         GETMINTREE, // Найти минимальный элемент         PRINTMETREE, // Печать дерева         DELTREE // Удаление элемента из дерева     };  // Структура листа дерева struct TreeLeaf {     int value;     int LChild; // В нулевой ячейке выступает в роли кол-ва элементов     int RChild; };      char *buf;     FILE *file;  // Рекурсии void PrintTree(struct TreeLeaf*, int, int); // Печать дерева int SuccTree(struct TreeLeaf*, int, int); // Поиск следующего за удаляемым элемента struct TreeLeaf* DeleteFromTree(struct TreeLeaf*, int, int); // Удаление из дерева  DWORD WINAPI TreeThreadF(LPVOID);  int main() {      // Переменные     bool exitBB = false; // Отвечает за сообщение выхода     MSG msg; // сообщение     struct TreeLeaf* Tree = NULL; // дерево     int curleaf, prleaf; // текущий лист, предыдущий лист     bool findplace; // найдено ли место?         while (exitBB == false) {         GetMessage(&msg, NULL, 0, 0);         file = fopen("answr.txt", "w");         if (WM_COMMAND == msg.message) {             switch (msg.wParam) {             case STARTTREE:                 // Инициализация дерева                 if (Tree == NULL) {                     Tree = (struct TreeLeaf*)malloc(sizeof(struct TreeLeaf));                     if (Tree == NULL)                         return 41; // Если что-то с RAM                     Tree[0].LChild = 0; // Изначально элементо нет                 }                 break;             case STOPTREE:                 free(Tree);                 break;              case DELTREE:                 Tree = DeleteFromTree(Tree, 1, msg.lParam);                 break;             ...             default:                 printf("Unknown command\n");                 break;             }          }          fclose(file);     }      return 0; } 

How to handle multiple objects on the same day in my timeline?

I am making an app where a series of posts are shown side by side chronologically. Then on the same page, there is a timeline at the bottom where each post is represented by a colored tick. You can see it here

Animated GIF - Find & Share on GIPHY

As you see, there is a track pin at the bottom in the exact middle showing you where the post you are currently viewing shows up at the timeline. When you scroll through the posts, the timeline adjusts to always show that corresponding tick under the pin.

Also, when you scroll the timeline every time a tick passes under the tracker pin, the post updates to that corresponding post.

Right now its done on a day by day basis. Each tick is a single day and if there is more than 1 post in a day like in that gif, they are drawn in the exact same spot. The problem is that now, when they scroll to that day using the timeline, they only see 1 post and don’t understand that there is more than 1 post in that day – even though they can scroll to it in the upper posts section.

I am not sure how to handle this case. Should I alter the appearance of the tick to show 2 somehow? Or should I add a page control (those multiple horizontal dots that show the active “page”?

What would be the most intuitive for the user?

PS. This will eventually be a fitness app. The purpose of this view is to show progress over time in a particular exercise. One reason the posts are broken down by day is that there is not much chance for progress over the course of a single day – most people work out at most once a day.

Command prompt handle to run commands in specific command prompt

I have a utility abc.exe that launches a special command prompt. By special I mean, certain environment variables are set on that prompt. Next I have to run a set of commands on this special command window. I have combined all such commands into a batch file and run this bat file. However, these are still 2 steps.

  1. Launch special command prompt through abc.exe(can be run through command line)
  2. Run commands.bat

I want to combine these 2 steps in single batch file such that, the commands.bat or rather the commands contained in that file are run on special command prompt only. Is this possible by somehow restricting/directing commands on a specific command prompt?

Now I do not have code for abc.exe, so only thing I can do with it is launch the special command prompt through it.