Skip to content

Instantly share code, notes, and snippets.

@sergnechaev
sergnechaev / Server.java
Created February 7, 2020 01:37
Java HTTP server to log request details
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.util.stream.Collectors;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
@sergnechaev
sergnechaev / cpp
Created October 29, 2018 12:12
libmicrohttpd
// #include <sys/socket.h>
#include <Winsock2.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
@sergnechaev
sergnechaev / file-utils.cpp
Last active October 6, 2018 09:29
C++ read text file to a vector of lines or a string
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
std::vector<std::string> utils::files::readLines(const std::string& filename) {
std::ifstream ifs(filename);
std::vector<std::string> lines;
@sergnechaev
sergnechaev / close_window_by_title.cpp
Created October 11, 2016 06:01
C++ WinAPI, close window by title
#include <windows.h>
#include <iostream>
int main(int argc, char* argv[]) {
if (argc <= 1) {
std::cerr << "ERROR: Please, specify the window title to close" << std::endl;
return EXIT_FAILURE;
#include <cstdio>
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
using namespace std;
int main(int argv, char* argc[]) {
@sergnechaev
sergnechaev / sdl2-2d-plazma
Created July 12, 2016 08:29
SDL2 2D Plazma
#include <iostream>
#include <cmath>
#include <SDL2/SDL.h>
constexpr int SCREEN_WIDTH = 800;
constexpr int SCREEN_HEIGHT = 600;
// SDL stuff
void init_sdl();
@sergnechaev
sergnechaev / sdl_sample.cpp
Created July 12, 2016 08:12
Basic SDL2 2D C++ Application (c++1y)
#include <iostream>
#include <SDL2/SDL.h>
constexpr int SCREEN_WIDTH = 800;
constexpr int SCREEN_HEIGHT = 600;
int main(int argc, char *argv[]) {
if (SDL_Init( SDL_INIT_VIDEO) < 0) {
@sergnechaev
sergnechaev / gist:2022feebc2988a51e195a624a387a641
Created July 12, 2016 02:20
Make a SOAP request via WGET
wget --post-file=soaprequest.xml --header="Content-Type: application/soap+xml" --header="SOAPAction: \"soapaction\"" http://myhost:my_port_number/service/great.do -O response.xml
Where:
soaprequest.xml - contains the soap request (wrapped in SOAP envelop).
http://myhost:my_port_number/service/great.do - service endoint URL
response.xml - contains a response from the server
@sergnechaev
sergnechaev / build.xml
Created October 13, 2015 12:31
Tomcat start/stop/application hot-deployment - ANT script
<?xml version="1.0" encoding="UTF-8"?>
<project name="my project" default="copyStatic">
<property name="INSTALL_ROOT" value="s:/tools/apache-tomcat-8.0.3/webapps/myproject" />
<property name="tomcat.home" value="s:/tools/apache-tomcat-8.0.3" />
<target name="copyStatic">
@sergnechaev
sergnechaev / sdl2_opengl.cpp
Last active September 26, 2022 02:34 — forked from exavolt/sdl2_opengl.c
Very basic SDL2 OpenGL application (C++1y)
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
constexpr int SCREEN_WIDTH = 800;
constexpr int SCREEN_HEIGHT = 600;