Skip to content

Instantly share code, notes, and snippets.

View max-dark's full-sized avatar

Maxim Timakov max-dark

View GitHub Profile
@max-dark
max-dark / signed_area.cxx
Last active January 7, 2020 22:11
signed triangle area / rotation direction
#include <iostream>
#include <iomanip>
struct point_t
{
using coord_t = int;
coord_t x;
coord_t y;
};
@max-dark
max-dark / visitor-example.cpp
Created August 11, 2017 17:52
Visitor pattern example
// https://en.wikipedia.org/wiki/Visitor_pattern
#include <iostream>
#include <memory>
class A;
class B;
class C;
struct Visitor
{
#include <unistd.h>
//...
ssize_t buf_size = ...;
char * buffer = (char *) malloc(buf_size);
//....
ssize_t read_count = 0;
int file_in;
file_in = open(...);
@max-dark
max-dark / Password.php
Created September 12, 2016 10:34
password generator
<?php
/**
* @copyright Copyright (C) 2016 Max Dark maxim.dark@gmail.com
* @license MIT; see LICENSE.txt
*/
namespace Tools{
/**
* Class Password
@max-dark
max-dark / ajax.js
Created September 7, 2016 20:48
Simple XMLHttpRequest wrapper
/**
* Simple XMLHttpRequest wrapper
*
* @constructor
* @this {Ajax}
*/
var Ajax = function () {
/**
* @type {XMLHttpRequest}
*/
@max-dark
max-dark / parent.cxx
Created August 12, 2016 02:18
Создает алиас 'parent' для родительского класса
#include <iostream>
using namespace std;
template <
class T
>
/**
* @brief The Class struct
*
* Создает алиас 'parent' для родительского класса T
* Позволяет обращаться к методам родительского класса parent::methodName()
@max-dark
max-dark / bumbom.php
Last active July 21, 2016 21:10
Утилита для пакетного удаления BOM
<?php
/**
* bumbom.php
* @link https://gist.github.com/max-dark/01d2bc7c54fa2f161d54add970763807
*
* Утилита для пакетного удаления BOM
* Использование:
* 0 создать бекап всех файлов
* 1 Закинуть в папку с файлами
* 2 поправить(если надо) $ext_list
@max-dark
max-dark / vzsh.php
Created July 16, 2016 17:30
v Zero Shell - simple web-based CLI
<?php
/*
________
\___ _/ ___ _ __ ___
.-. ,-, / / / _ \| .-\| / \
\ \/ / _/ /__ | __/| | | | |
\__/ /______\\___||_| \___/
______ _ ___ _ _
/ _____\| |___ / _ \| || |
\_____ \| ,-. || __/| || |
@max-dark
max-dark / callback_form.html
Last active July 13, 2016 06:25
Bootstrap 3 Modal Dialog Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap 3 Modal Dialog Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- #include <jquery-1-12> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<!-- #include <jquery-1-12> -->
<!-- #include <bootstrap-3-3> -->
@max-dark
max-dark / debug_mode.php
Created July 12, 2016 00:40
Enable all errors. Convert Errors to Exceptions
<?php
const DEBUG = true;
error_reporting(DEBUG ? E_ALL : 0);
ini_set('display_errors', DEBUG ? 'on' : 'off');
set_error_handler(function($err_no, $err_str, $err_file, $err_line ) {
if (!(error_reporting() & $err_no)) {
return;