Skip to content

Instantly share code, notes, and snippets.

View equalent's full-sized avatar
🇵🇸

Andrei Tsurkan equalent

🇵🇸
View GitHub Profile
@equalent
equalent / readme.md
Created January 13, 2018 08:55 — forked from RaVbaker/readme.md
[HOWTO] Rewrite all urls to one index.php in Apache

Redirect All Requests To Index.php Using .htaccess

In one of my pet projects, I redirect all requests to index.php, which then decides what to do with it:

Simple Example

This snippet in your .htaccess will ensure that all requests for files and folders that does not exists will be redirected to index.php:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

@equalent
equalent / string_split.cpp
Created October 7, 2018 14:52 — forked from float-tw/string_split.cpp
c++ string split
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void split(string source, string delim, vector<string>& result)
{
string tmp;
size_t now=-1, next=-1;
@equalent
equalent / LogonTime.cs
Last active July 21, 2019 08:16 — forked from anlai/LogonTime.cs
Classes for working with Active Directory logon time
public class LogonTime
{
public DayOfWeek DayOfWeek { get; set; }
public DateTime BeginTime { get; set; }
public DateTime EndTime { get; set; }
public LogonTime(DayOfWeek dayOfWeek, DateTime beginTime, DateTime endTime)
{
DayOfWeek = dayOfWeek;
BeginTime = beginTime;
@equalent
equalent / ca.md
Created June 20, 2019 07:12 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@equalent
equalent / human-size.c
Created July 23, 2019 09:00 — forked from dgoguerra/human-size.c
Format a quantity in bytes into a human readable string (C)
#include <stdio.h>
#include <stdlib.h> // atoll
#include <stdint.h> // uint64_t
#include <inttypes.h> // PRIu64
static const char *humanSize(uint64_t bytes)
{
char *suffix[] = {"B", "KB", "MB", "GB", "TB"};
char length = sizeof(suffix) / sizeof(suffix[0]);
@equalent
equalent / capture.cpp
Created August 18, 2019 16:41 — forked from holmesconan/capture.cpp
Capture screen by GDI on Windows
HDC hdc = GetDC(NULL); // get the desktop device context
HDC hDest = CreateCompatibleDC(hdc); // create a device context to use yourself
// get the height and width of the screen
int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
// create a bitmap
HBITMAP hbDesktop = CreateCompatibleBitmap( hdc, width, height);
@equalent
equalent / aligned_malloc.cpp
Created October 1, 2019 15:52 — forked from ashwin/aligned_malloc.cpp
Aligned memory allocation
// Assume we need 32-byte alignment for AVX instructions
#define ALIGN 32
void *aligned_malloc(int size)
{
// We require whatever user asked for PLUS space for a pointer
// PLUS space to align pointer as per alignment requirement
void *mem = malloc(size + sizeof(void*) + (ALIGN - 1));
// Location that we will return to user
@equalent
equalent / ack_short.py
Created October 10, 2019 16:13 — forked from justjkk/ack_short.py
Ackermann Function in python
import sys
count=0
sys.setrecursionlimit(50000)
cache={}
def a(m,n):
global count
global cache
count=count+1
if cache.has_key(m) and cache[m].has_key(n):
return cache[m][n]
@equalent
equalent / Qt 5 Dark Fusion Palette
Created February 3, 2020 23:56 — forked from QuantumCD/Qt 5 Dark Fusion Palette
This is a complete (I think) dark color palette for the Qt 5 Fusion theme, as well as a nice style sheet for the tool tips that make them blend better with the rest of the theme. To have immediate effect, be sure to put this in your main function before showing the parent window. Child windows should automatically inherit the palette unless you …
qApp->setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53,53,53));
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(25,25,25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53));
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);