Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar
💭
If I have seen further it is only by standing on the shoulders of giants. Newton

Adrian Statescu thinkphp

💭
If I have seen further it is only by standing on the shoulders of giants. Newton
View GitHub Profile
@thinkphp
thinkphp / Dijkstra.java
Created July 6, 2026 14:11
Dijkstra.java
/*
Algoritmul lui Dijkstra (Tehnica GREEDY):
Structuri de date:
V[x] = lista vecinilor (liste de adiacenta)
C[x] = costurile catre acei vecinilor
distMin[i] = distanta minima cunoscuta de la nodul 1 la nodul i
import java.io.*;
import java.util.*;
public class Main {
static final String FIN = "scmax.in";
static final String FOUT = "scmax.out";
static final int SIZE = 1000009;
static int[] V = new int[SIZE];
@thinkphp
thinkphp / intro-BST.md
Last active July 6, 2026 11:16
Introducere BSST

Introducere în Binary Search Tree (BST)

Un Binary Search Tree (arbore binar de căutare) este o structură de date arborescentă în care fiecare nod are cel mult doi copii (stânga și dreapta), respectând o proprietate de ordonare:

  • Toate valorile din subarborele stâng al unui nod sunt mai mici decât valoarea nodului.
  • Toate valorile din subarborele drept sunt mai mari (sau egale, în funcție de convenție).
  • Această regulă se aplică recursiv pentru fiecare subarbore.

De ce este util

Datorită acestei ordonări, operațiile de bază devin eficiente:

@thinkphp
thinkphp / database-security.md
Last active July 5, 2026 17:29
Database Security

Backup Types — Elaboration

Why backup is part of security, not just "maintenance"

The security measures discussed so far (prepared statements, GRANT/REVOKE, least privilege) aim to prevent an attack. Backup plays a different, complementary role: it assumes that, despite all preventive measures, something might still destroy or corrupt the data — whether a SQL Injection attack using DROP TABLE/DELETE, human error, hardware failure, or ransomware. Backup is the last line of defense: if every other measure fails, a recent, tested backup is the difference between a minor incident and an irreversible data loss.

Full backup

A complete copy of the entire database at a given point in time — all tables, all rows, the complete structure.

@thinkphp
thinkphp / backup.md
Last active July 5, 2026 17:27
Database Security

Tipuri de backup — dezvoltare

De ce backup-ul e parte din securitate, nu doar din "mentenanta"

Măsurile de securitate discutate până acum (prepared statements, GRANT/REVOKE, privilegiu minim) urmăresc să previi un atac. Backup-ul are un rol diferit, complementar: presupune că, în ciuda oricăror măsuri preventive, ceva poate totuși să distrugă sau să corupă datele — fie un atac SQL Injection cu DROP TABLE/DELETE, fie o eroare umană, o defecțiune hardware sau un ransomware. Backup-ul e ultima linie de apărare: dacă toate celelalte măsuri au eșuat, un backup recent și testat e diferența între o incidență minoră și o pierdere ireversibilă de date.

Full backup (backup complet)

O copie completă a întregii baze de date, la un moment dat în timp — toate tabelele, toate rândurile, structura completă.

"SELECT * FROM Countries WHERE country_name = '" + input_python + "'"
WHERE country_name = '' OR '1' = '1' returneaza toate randurile
input_python " Portugalia'; DROP TABLE Countries"
O aplicatie are un formular de cautare a unei tari , iar codul din spate python
country = request.form['country'];//vine direct de la utilizator , netratat
@thinkphp
thinkphp / Medals.sql
Created June 15, 2026 14:27
Tournament medals
-- 1. Creaza tabelul FARA chk_medal_recipient
CREATE TABLE Tournament_Medals (
Tournament_Medals_ID INT AUTO_INCREMENT,
Tournament_ID INT NOT NULL,
Sport_ID INT NOT NULL,
Category_ID INT NOT NULL,
Team_ID INT NULL,
Player_ID INT NULL,
Medal_Type ENUM('Gold','Silver','Bronze') NOT NULL,
@thinkphp
thinkphp / BFSADjList.java
Created June 11, 2026 19:23
BFS cu Adj Lists
import java.io.*;
import java.util.*;
class GraphAdjLinkedList {
private static class Node {
int vecin;
Node urmator;
@thinkphp
thinkphp / DFS-AdjLists.java
Created June 11, 2026 19:04
DFS cu graful reprezentat prin liste de adiacenta
import java.util.Scanner;
/*
0 1
liste de adiacenta:
cap[]
1: 2, 3 cap[1]
2: 1, 5,4 cap[2]
3: 1, 5 cap[3]
@thinkphp
thinkphp / gist:bba4ca0ba450cf83a3fccb9fb5f1f843
Created June 11, 2026 19:03
DFS cu matricea de adiacenta
import java.util.*;
public class Graf {
private final int[][] mat;
public final boolean[] vizitat;
private final int n;