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 / 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 / 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 / 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 / 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
#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 / 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
{
@max-dark
max-dark / restore_tree.php
Last active April 25, 2019 11:23
restore tree from table
<?php
/**
* @file https://gist.github.com/max-dark/f39028cc106ed32e8ce1b55a11643b43
*/
define('ROOT_NODE', null);
/**
* восстанавливает дерево по таблице связей
* @param array $data
@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 / block_pool.c
Last active January 21, 2020 00:01
simple on-array allocator
// task: create two queues that will be located in one array of a fixed size
// solution: create a pool of blocks in this array.
// http://www.cyberforum.ru/algorithms/thread2569313.html
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
// настройки типов
@max-dark
max-dark / fizz_buzz.cxx
Last active January 23, 2020 16:46
fizz buzz without "if"
// task: https://en.wikipedia.org/wiki/Fizz_buzz
// compile: g++ -std=c++14 -Wall -Wpedantic -Werror fizz_buzz.cxx -o fizz_buzz
#include <iostream>
#include <string>
namespace
{
std::string solve(int num);
}
int main()