Skip to content

Instantly share code, notes, and snippets.

View ziggi's full-sized avatar
🏠
Working from home

Sergei Marochkin ziggi

🏠
Working from home
View GitHub Profile
@ziggi
ziggi / GetTickDiff.pwn
Last active February 5, 2024 18:56
Function to calculate the time elapsed between the two calls GetTickCount(), given the possibility of overflow passed values.
stock GetTickDiff(newtick, oldtick)
{
if (oldtick > newtick) {
return (cellmax - oldtick + 1) - (cellmin - newtick);
}
return newtick - oldtick;
}
@ziggi
ziggi / bmp_read.cpp
Last active January 24, 2023 15:58
bmp reader
#include <iostream>
#include <fstream>
#include "main.h"
int main(int argc, char *argv[])
{
if (argc < 2) {
std::cout << "Usage: " << argv[0] << " file_name" << std::endl;
return 0;
@ziggi
ziggi / proxdetector.pwn
Last active January 4, 2023 08:56
SA-MP ProxDetector function
stock ProxDetector(playerid, Float:max_range, color, const string[], Float:max_ratio = 1.6)
{
new
Float:pos_x,
Float:pos_y,
Float:pos_z,
Float:range,
Float:range_ratio,
Float:range_with_ratio,
clr_r, clr_g, clr_b,
@ziggi
ziggi / .bashrc
Last active October 7, 2022 02:33
.bashrc
# color aliases
alias sudo='sudo '
alias ls='ls --color=always'
alias dmesg='dmesg --color=always'
alias grep='grep --color=always'
alias gcc='gcc -fdiagnostics-color=always'
alias pacman='pacman --color=always'
alias dir='dir --color=always'
alias diff='diff --color=always'
@ziggi
ziggi / parents.js
Last active August 11, 2022 16:10
Vanilla JS jQuery.parents() realisation (npm module: https://github.com/ziggi/dom-parents)
Element.prototype.parents = function(selector) {
var elements = [];
var elem = this;
var ishaveselector = selector !== undefined;
while ((elem = elem.parentElement) !== null) {
if (elem.nodeType !== Node.ELEMENT_NODE) {
continue;
}
@ziggi
ziggi / regsys.pwn
Last active June 21, 2021 18:39
MySQL ORM Register System
/*
About: mysql orm register system
Author: ziggi
*/
#include <a_samp>
#include "a_mysql"
stock Float:frandom(Float:max)
{
return floatdiv(float(random(0)), floatdiv(float(cellmax), max));
}
stock rgba2bgra(color)
{
return
(color & 0xFF)
| ((color & 0xFF00) << 16)
| (color & 0xFF0000)
| ((color >> 16) & 0xFF00);
}
@ziggi
ziggi / IsIpAddress.pwn
Last active October 1, 2018 13:09
Return 1 if string is ip address else 0
#if !defined IS_IN_RANGE
#define IS_IN_RANGE(%0,%1,%2) (((%0) - ((%1) + cellmin)) < (((%2) + 1) - ((%1) + cellmin)))
#endif
stock IsIpAddress(const string[])
{
new
octet,
j = 100;
@ziggi
ziggi / sq_api_example.pwn
Last active July 3, 2018 15:09 — forked from Westie/gist:234209
SampQueryAPI (for sa-mp 0.3.7) example
<?php
include "SampQueryAPI.php";
$query = new SampQueryAPI('127.0.0.1', '7777');
if ($query->isOnline()) {
$aInformation = $query->getInfo();
$aServerRules = $query->getRules();