Skip to content

Instantly share code, notes, and snippets.

View sunmeat's full-sized avatar
🐈
MEOW

Oleksandr Zahoruiko sunmeat

🐈
MEOW
View GitHub Profile
@sunmeat
sunmeat / client.cpp
Created April 7, 2026 15:57
приклад на парі 07.04.2026
#define WIN32_LEAN_AND_MEAN
#include <iostream>
#include <ws2tcpip.h>
using namespace std;
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib") // AcceptEx(), ConnectEx(), WSASendMsg() тощо
#pragma comment (lib, "AdvApi32.lib") // Security API, Registry API, Service Control Manager тощо
@sunmeat
sunmeat / main.cpp
Created April 3, 2026 05:30
get file from hosting mac os version
#include <iostream>
#include <string>
#include <curl/curl.h>
using namespace std;
size_t write_data(void* ptr, size_t size, size_t nmemb, FILE* stream) {
return fwrite(ptr, size, nmemb, stream);
}
@sunmeat
sunmeat / main.cpp
Created April 3, 2026 05:27
get html page text C++ example HTTP GET mac os version
#include <iostream>
#include <string>
#include <cstring>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
using namespace std;
int main() {
string url = "google.com";
@sunmeat
sunmeat / different files.kt
Created March 29, 2026 11:33
jetpack compose example
build.gradle.kts (Project):
plugins {
alias(libs.plugins.android.application) apply false
kotlin("plugin.compose") version "2.0.21" apply false // !!!
}
==================================================================================================================
build.gradle.kts (Module:app):
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0A0A0F">
<!-- Декоративне коло вгорі -->
<View
@sunmeat
sunmeat / different files.cpp
Created March 27, 2026 09:04
one server multiple clients C++ example (UDP) mac os version
SERVER SIDE:
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
@sunmeat
sunmeat / different files.cpp
Created March 27, 2026 06:49
client server UDP C++ example mac os version
CLIENT SIDE:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
using namespace std;
@sunmeat
sunmeat / views.py
Created March 25, 2026 14:09
запити1-М та агрегування + raw queries
from datetime import datetime
from django.shortcuts import render
from django.http import HttpRequest
from django.db.models import Avg, Count, Sum, Max, Min, F, Q
from app.models import Author, Book
# =============================================================================
# CRUD ДЛЯ AUTHOR (це було вже :)
# =============================================================================
@sunmeat
sunmeat / views.py
Created March 25, 2026 13:08
розширені запити
...
# ── РОЗШИРЕНІ ЗАПИТИ ──────────────────────────────────────────────────────────
def author_filter_advanced(request):
"""filter з різними умовами"""
# lte / gte - менше або рівно / більше або рівно
authors = Author.objects.filter(rating__gte=8.0) # rating >= 8.0
authors = Author.objects.filter(rating__lte=5.0) # rating <= 5.0
@sunmeat
sunmeat / views.py
Created March 25, 2026 12:56
CRUD операції. одна таблиця. команди для python manage.py shell
from datetime import datetime
from django.shortcuts import render
from django.http import HttpRequest
from app.models import Author
# ── CREATE ────────────────────────────────────────────────────────────────────
def author_create_method1(request):
"""Вставка автора через objects.create() - один рядок, одразу зберігає в БД"""