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 / 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[]) {
@artur-kink
artur-kink / Controller.hpp
Created August 19, 2014 03:17
C++ Webserver using libmicrohttpd. A simple wrapper for libmicrohttpd to create websites using C++.
#ifndef _CONTROLLER_
#define _CONTROLLER_
#include <sstream>
/**
* Base controller for handling http requests.
*/
class Controller{
@caprica
caprica / SwtBrowserCanvas.java
Created October 8, 2013 19:57
Embed an SWT Webkit Browser component inside a Swing JPanel, with non-crashing clean-up.
/*
* This class is made available under the Apache License, Version 2.0.
*
* See http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Author: Mark Lee
*
* (C)2013 Caprica Software (http://www.capricasoftware.co.uk)
*/
@fracek
fracek / CMakeLists.txt
Last active June 22, 2024 21:33
CMake and GTK+ 3
# Thanks to @danger89 and @Ilothar for updating the gist.
# Set the name and the supported language of the project
project(hello-world C CXX)
# Set the minimum version of cmake required to build this project
cmake_minimum_required(VERSION 3.10)
# Use the package PkgConfig to detect GTK+ headers/library files
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED gtkmm-3.0)
@r10r
r10r / gist:2305091
Created April 4, 2012 19:49
embed SWT widget into Swing JFrame
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.browser.Browser;