Skip to content

Instantly share code, notes, and snippets.

View macik's full-sized avatar

Andrey Matsovkin macik

View GitHub Profile
@macik
macik / IP-Guide.md
Last active January 6, 2018 15:48 — forked from Golpha/IP-Guide.md
The PHP IP Guide

The PHP IP Guide

This guide shows you common practices to convert IPv4- and IPv6-Addresses into their binary representation.

Who is responsible for this ?

This guide has been written by Matthias Kaschubowski, a autodidactical software developer from germany with about 14 years of practice converting coffee to code. He works in his free time as a php evangelist on a lot of platforms ( last shown as tr0y on php.de, a german PHP related forum and as himself as an adminstrator at the largest PHP-related facebook group ).

Basics

@macik
macik / cot_string_truncate.php
Last active August 29, 2018 08:58
Function to truncate string allowes treat it as HTML code.
<?php
/**
* Truncates text.
*
* Cuts a string to the length of $length
*
* @param string $text String to truncate.
* @param integer $length Length of returned string, including ellipsis.
* @param boolean $considerhtml If true, HTML tags would be handled correctly *
<?php
$dom = new DOMDocument; // create new DOMDocument instance
$dom->load('books.xml'); // load DOMDocument with XML data
$dit = new RecursiveIteratorIterator(
new RecursiveDOMIterator($dom),
RecursiveIteratorIterator::SELF_FIRST);
@macik
macik / README.rst
Created April 13, 2014 20:18 — forked from dupuy/README.rst

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@macik
macik / cotonti-netbeans.md
Last active April 20, 2023 05:06
Краткая инструкция по настройке связки программ IDE-WAMP (на примере NetBeans IDE) для разработки под Cototnti.

Настройка среды разработки под Cotonti

В данной инструкции кратко расскажу о настройке программного окружения для простой и удобной разработки под CMF Cotonti (для ОС Windows).

Конкретно этот материал будет на примере программ NetBeans + OpenServer (WAMP).

Основной упор сделан на краткость и начинающий уровень пользователя. Задача настроить сервер, установить сайт, и отлаживать его в IDE с помощью удобного отладчика.

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).

@macik
macik / convBase.php
Created February 11, 2013 22:19
Convert an arbitrarily large number from any base to any base.
<?php
/*
Convert an arbitrarily large number from any base to any base.
string convBase(string $numberInput, string $fromBaseInput, string $toBaseInput)
$numberInput number to convert as a string
$fromBaseInput base of the number to convert as a string
$toBaseInput base the number should be converted to as a string
examples for $fromBaseInput and $toBaseInput
@macik
macik / arabic2roman.php
Created February 11, 2013 22:11
Short arabic2roman conveter
<?php
function rome($N){
$c='IVXLCDM';
for($a=5,$b=$s='';$N;$b++,$a^=7)
for($o=$N%$a,$N=$N/$a^0;$o--;$s=$c[$o>2?$b+$N-($N&=-2)+$o=1:$b].$s);
return $s;
}
?>
@macik
macik / mail_servers_settings.md
Created December 31, 2012 14:32
Popular MAIL Server Settings

Hotmail

The Microsoft Hotmail Mail service now offers standard POP3/SMTP access.

  • SMTP - smtp.live.com (TLS enabled, port 25)
  • POP3 - pop3.live.com (SSL enabled, port 995)

GMail by Google

@macik
macik / time_limit.php
Created December 31, 2012 14:29
Setting time limit for script execution
<?php
/* The following code snippet with set the maximum execution time
* of your script to 300 seconds (5 minutes)
* Note: set_time_limit() does not work with safe_mode enabled
*/
$safeMode = ( @ini_get("safe_mode") == 'On' || @ini_get("safe_mode") === 1 ) ? TRUE : FALSE;
if ( $safeMode === FALSE ) {
set_time_limit(300); // Sets maximum execution time to 5 minutes (300 seconds)