Skip to content

Instantly share code, notes, and snippets.

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

Alexander Bulatov palexandrite

🏠
Working from home
View GitHub Profile
@palexandrite
palexandrite / README.md
Created July 25, 2023 13:44 — forked from njvack/README.md
Color to hex and rgba converter

Simple canvas-based color converter

To answer this StackOverflow question I wrote this — a small solution based on a never-rendered <canvas> element. It fills a 1-pixel canvas with the provided fill-style, and then reads the RGBA values of that pixel. It will work with any CSS color -- name, rgba(), hex, or even something more exotic like a gradient or pattern. Invalid colors are always returned as transparent black. Transparent colors are treated as painted on a newly-cleared canvas.

It's been tested in modern-ish versions of IE, Chrome, Safari, and Firefox. The API is:

color_convert.to_hex(color)   # Converts color to a hex-based RGB triple; to_hex('red') returns '#ff0000'
color_convert.to_rgba(color)  # Converts color to an rgba() string; to_rgba('red') returns 'rgba(255,0,0,1)'
@palexandrite
palexandrite / jQuery - Serialize Form with File inputs
Last active January 11, 2022 10:25 — forked from oswaldoacauan/gist:7580474
jQuery - Serialize Form with File inputs
(function($) {
$.fn.serializeFiles = function() {
var form = $(this),
formData = new FormData()
formParams = form.serializeArray();
$.each(form.find('input[type="file"]'), function(i, tag) {
$.each($(tag)[0].files, function(i, file) {
formData.append(tag.name, file);
});
@palexandrite
palexandrite / SplClassLoader.php
Created September 27, 2018 15:36 — forked from jwage/SplClassLoader.php
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
базовые команды
git clone адрес репозитория - клонировать репозиторий на локальный компютер
git commit -m 'initial commit' комит изменений в локальный репозиторий
git push -u origin master - только первый раз отправка изменений в удаленный репозиторий
git push - все последующие разы отправка изменений в удаленный репозиторий
окат изменений
git pull - скачивается актуальная версия удаленного репозитория и все изменения применяются к локальному репозиторию
checkout - перейти в другую ветку
discard - не отправлять в репозиторий те изменения которые нам не нравятся