Skip to content

Instantly share code, notes, and snippets.

View arthurkushman's full-sized avatar
👨‍💻
Geeks will inherit the world

Arthur Kushman arthurkushman

👨‍💻
Geeks will inherit the world
  • Milky Way
View GitHub Profile
package fibonacci
func fib(n uint) uint64 {
return uint64(math.Round(math.Pow(1.618, float64(n)) / 2.236))
}
<?php
function fib(int $n)
{
return number_format(round(1.618 ** $n / 2.236));
}
@arthurkushman
arthurkushman / AntiSpam.php
Last active August 29, 2015 14:19
Anit spam filter based on counters like n (messages) per t (period) k times + protection from repeated images/text content via md5 hash (byte in case of image) comparison, also as additional params passed through to protect accidential repetition of text messages and images
/**
* $userId - int
* $text - post, message etc. text - string
* $img - image - resource usually $_FILES['image']['tmp_name']
* $counterLimit - limit of n messages in t period - int
* $countFails - limit of x failes after which user will be blocked - int
* $addParams - ex.: array('period_same_counter'=>3, 'period_same_time'=>15*60); - array
*/
class AntiSpam {
@arthurkushman
arthurkushman / NudeFilter
Last active August 29, 2015 14:06
NudeFilter class filters nudity/porn content 85% garanty - 15% is positive/negative (weakly tested)
package com.anumbers.core;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.imageio.ImageIO;
@arthurkushman
arthurkushman / lightning.js
Last active December 22, 2015 21:39
Lightning class offers frequently (daily) used methods (functions) to free programmer`s hands, avoiding regular/repeated practices
/*
* Lightning class offers frequently (daily) used methods (functions)
* to free programmer`s hands, avoiding regular/repeated practices
*
* Some functions have been inherited from PHP stdlib (like numberFormat, htmlspecialchars)
* to make lives easier
*
* Copyright (C) <2015> <Arthur Kushman>
*
* This program is free software: you can redistribute it and/or modify