Skip to content

Instantly share code, notes, and snippets.

View hightemp's full-sized avatar
🎯
Focusing

Anton Panov hightemp

🎯
Focusing
View GitHub Profile
@hightemp
hightemp / qtyaml.h
Last active June 15, 2017 05:32 — forked from brcha/qtyaml.h
[Cpp][Qt][Yaml] QtYaml support using yaml-cpp library
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* ***** END LICENSE BLOCK ***** */
/*
@hightemp
hightemp / commit_size.pl
Created May 10, 2018 13:12
Determine the Size of Each Git Commit. This script will iterate over a Git repository and return information about the size of each commit.
#!/usr/bin/perl
foreach my $rev (`git rev-list --all --pretty=oneline`) {
my $tot = 0;
($sha = $rev) =~ s/\s.*$//;
foreach my $blob (`git diff-tree -r -c -M -C --no-commit-id $sha`) {
$blob = (split /\s/, $blob)[3];
next if $blob == "0000000000000000000000000000000000000000"; # Deleted
my $size = `echo $blob | git cat-file --batch-check`;
$size = (split /\s/, $size)[2];
$tot += int($size);
@hightemp
hightemp / scrolling.js
Created June 30, 2018 15:26
Detecting end of scrolling window
if (document.documentElement.offsetHeight + document.documentElement.scrollTop == document.documentElement.scrollHeight) {
// CODE
}
@hightemp
hightemp / minify_function.php
Created July 16, 2018 01:17 — forked from dr-dimitru/minify_function.php
HTML MINIFY RegEx
$re = '%# Collapse whitespace everywhere but in blacklisted elements.
(?> # Match all whitespans other than single space.
[^\S ]\s* # Either one [\t\r\n\f\v] and zero or more ws,
| \s{2,} # or two or more consecutive-any-whitespace.
) # Note: The remaining regex consumes no text at all...
(?= # Ensure we are not in a blacklist tag.
[^<]*+ # Either zero or more non-"<" {normal*}
(?: # Begin {(special normal*)*} construct
< # or a < starting a non-blacklist tag.
(?!/?(?:textarea|pre|script)\b)
#!/bin/bash
PROGNAME=${0##*/}
INPUT=''
QUIET='0'
NOSTATS='0'
max_input_size=0
max_output_size=0
usage()
@hightemp
hightemp / cscart.md
Last active November 8, 2024 19:00
CS Cart snippets

CS Cart snippets

Руководство по кодировке UTF-8 в PHP и MySQL

Файловые функции и UTF-8

В Unix и Linux (и, возможно, в OS X тоже) текущая Кодировка файловой системы задается параметром локали LC_CTYPE (см. функцию setlocale() http://php.net/manual/ru/function.setlocale.php). Например, он может иметь значение типа en_US.UTF-8, что означает кодировку UTF-8. Затем имена файлов и их пути могут быть созданы с помощью fopen() или получены с помощью dir() с этой кодировкой.

Кодировка PHP UTF-8 в php.ini-файле

@hightemp
hightemp / index.php
Last active August 31, 2018 08:53
CS-Cart rewritten query processing function
<?php
class Database
{
private $_sTablePrefix;
private $_iMatchesCount = 0;
private $_aReplaceData = [];
private $_oConnection;
@hightemp
hightemp / index.php
Last active August 19, 2018 13:37
Test of str_replace and preg_replace functions
<?php
// file encoding utf-8
echo "encoding utf-8\n\n";
//$a = "\xe1\x84\xbf\x84"; //ᄿ?
$a = "ᄿtest"; //e1 84 bf 74 65 73 74
echo "string ".$a."\n";
echo "bytes ".implode(' ', array_map('dechex', unpack('C*', $a)))."\n\n";
@hightemp
hightemp / index.php
Created August 19, 2018 13:09
mb_chr
<?php
function mb_html_entity_decode($string)
{
if (extension_loaded('mbstring') === true)
{
mb_language('Neutral');
mb_internal_encoding('UTF-8');
mb_detect_order(array('UTF-8', 'ISO-8859-15', 'ISO-8859-1', 'ASCII'));