Skip to content

Instantly share code, notes, and snippets.

View yesasha's full-sized avatar

Aleksandr Yefremov yesasha

  • Israel
View GitHub Profile
@yesasha
yesasha / canvas-not-a-library
Created September 26, 2021 20:33
Not a library for canvas. Just copy the needed functions to your project.
function circle (ctx, x, y, r) {
ctx.beginPath();
ctx.arc(x, y, r, 0, 2 * Math.PI, false);
}
function strokeCircle (ctx, x, y, r) {
ctx.beginPath();
ctx.arc(x, y, r, 0, 2 * Math.PI, false);
ctx.stroke();
}
@yesasha
yesasha / n2o2n.js
Last active May 9, 2018 18:54
Convert node to plain object and back. Development version.
(function (w, defaultNamespaceURI) {
"use strict";
var namespaceURI = defaultNamespaceURI;
function toObj (node) {
if (node == null) {
return null;
}
<?php
define(JSON_ERROR_NONE, 0);
define(JSON_ERROR_DEPTH, 1);
define(JSON_ERROR_STATE_MISMATCH, 2);
define(JSON_ERROR_CTRL_CHAR, 3);
define(JSON_ERROR_SYNTAX, 4);
define(JSON_ERROR_UTF8, 5);
define(JSON_ERROR_RECURSION, 6);
define(JSON_ERROR_INF_OR_NAN, 7);
define(JSON_ERROR_UNSUPPORTED_TYPE, 8);
@yesasha
yesasha / status_message_from_code.php
Last active April 25, 2018 21:45
Get http status message from code.
<?php
/**
* Get http status message from code
*
* @param number $code
* @return string
*/
function status_message_from_code ($code = NULL) {
switch ($code) {
case 100:
@yesasha
yesasha / friendly_error_type.php
Last active April 25, 2018 22:19
Convert error code to friendly readable string
<?php
/**
* Convert error code to friendly readable string.
* http://php.net/manual/ru/errorfunc.constants.php
*
* @param number $type
* @return string
*/
function friendly_error_type ($type) {
switch($type) {
<?php
/**
* http_responce_code function polyfill.
* http://php.net/manual/en/function.http-response-code.php
*
* @param number $code
* @return string
*/
if (!function_exists('http_response_code')) {
function http_response_code ($code = NULL) {
<?php
/**
* http_responce_code function polyfill.
* http://php.net/manual/en/function.http-response-code.php
*
* @param number $code
* @return string
*/
if (!function_exists('http_response_code')) {
function http_response_code ($code = NULL) {
@yesasha
yesasha / .htaccess
Last active April 18, 2018 04:32
Extension to Apache Server Configs for the case when mod_expires.c is not available. Also it does not depend on mod_mime.c since relies only on file extensions.
# MIT License
# Copyright (c) 2018 Aleksandr Yefremov
# Extension to Apache Server Configs v3.0.0
# https://github.com/h5bp/server-configs-apache
# For the case when mod_expires.c is not available
# Also it does not depend on mod_mime.c since relies only on file extension.
<IfModule !mod_expires.c>
<IfModule mod_headers.c>
@yesasha
yesasha / default.css
Last active April 15, 2018 21:15
Most browsers will display elements with the following default values
/* Most browsers will display elements with the following default values */
a:link, a:visited {
color: (internal value);
text-decoration: underline;
cursor: auto;
}
a:link:active, a:visited:active {
color: (internal value);
}
@yesasha
yesasha / alltags.css
Last active April 15, 2018 20:42
Probably all html tags in alphabetical order
/* Tags in alphabetic order */
a, abbr, address, area, article, aside, audio, b, base, bdi, bdo, blockquote,
body, br, button, caption, cite, code, col, colgroup, datalist, dd, del,
details, dfn, dialog, div, dl, dt, em, embed, fieldset, figcaption, figure,
footer, form, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img,
input, ins, kbd, keygen, label, legend, li, link, main, map, mark, menu,
menuitem, meta, meter, nav, noscript, object, ol, optgroup, option, output, p,
param, picture, pre, progress, q, rp, rt, ruby, s, samp, script, section, select,
small, source, span, strong, style, sub, summary, sup, svg, table, tbody, td,
template, textarea, tfoot, th, thead, time, title, tr, track, u, ul, var,