Skip to content

Instantly share code, notes, and snippets.

View Ichinya's full-sized avatar
🎯
Focusing

Ichi Ichinya

🎯
Focusing
View GitHub Profile
@Ichinya
Ichinya / WordPress query_posts
Created March 18, 2015 17:25
Цикл для вывода записи в Wordpress
<?php if ( have_posts() ) : query_posts('p=1');
while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php the_post_thumbnail(array(100, 100)); ?>
<? endwhile; endif; wp_reset_query(); ?>
@Ichinya
Ichinya / upload.php
Created June 22, 2020 16:54
Проверка расширение файла при загрузке
$allowedExtensions = ['jpg', 'png', 'gif'];
$extension = pathinfo($srcFileName, PATHINFO_EXTENSION);
if (!in_array($extension, $allowedExtensions)) {
$error = 'Загрузка файлов с таким расширением запрещена!';
}
@Ichinya
Ichinya / config
Created June 23, 2020 04:24
при работе в разных ОС (Win, Unix, Mac) - делать одинаковые окончания строк в GIT
через терминал
в одном проекте
git config core.autocrlf true
во всех проектах
git config --global core.autocrlf true
или в файле проекта .git\config
[core]
autocrlf = true
@Ichinya
Ichinya / addListener.html
Created October 31, 2020 08:04
Вещаем события в разных браузерах (addListener и removeListerner)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Определение функций на этапе инициализации</title>
</head>
<body>
<script>
var utils = {
addListener: null,
removeListener: null
@Ichinya
Ichinya / gist:ae0e3c50d48aadcace66a79d30c38def
Created November 26, 2020 12:12
Удалить дубликаты в многомерном массиве
<?php
$arr = array(
array(
'id' => 12345,
'date' => 277345533
),
array(
'id' => 12345,
'date' => 277345533
),
@Ichinya
Ichinya / del-commit-github.sh
Last active May 5, 2022 11:37 — forked from vorozhba/Как удалить commit в Github.txt
Как удалить commit в Github
#1. Получаем хэш-код коммита, к которому хотим вернуться.
#2. Заходим в папку репозитория и пишем в консоль:
# $ git reset --hard ХЭШ-КОМИТА
# $ git push --force
# Или
$ git reset --hard HEAD~1
$ git push --force
@Ichinya
Ichinya / cmd
Created March 31, 2021 04:10
git: удаляет из индекса файлы из .gitignore
foreach ($i in iex 'git ls-files -i --exclude-from=.gitignore') { git rm --cached $i }
@Ichinya
Ichinya / tree.php
Created June 3, 2021 10:23
генерирует древовидную структуру массива. Элемент привязывается по связке id=> parent_id, добавляется к родительскому элементу в поле childs.
<?php
function generate_tree($data, $parent = 'parent_id', $childs = 'childs')
{
$tree = array();
foreach ($data as $id => &$node)
{
if (!$node[$parent] || !isset($data[$node[$parent]]))
{
unset($node[$parent]);
$tree[$id] = &$node;
@Ichinya
Ichinya / bash.sh
Last active June 12, 2021 04:21
после установки ubuntu-server
#!/bin/bash
sudo apt update
sudo apt dist-upgrade -y
sudo apt install openssh-server -y
sudo ifconfig
# если нет ifconfig, то устанавливаем
sudo apt install net-tools
#устанавливаем nginx
@Ichinya
Ichinya / \etc\nginx\sites-available\default
Last active June 12, 2021 05:33
настройка php8.0 под laravel 8.5
server {
listen 80;
listen [::]:80;
server_name laravel.local;
root /var/www/laravel/public;
index index.php index.html index.htm;
client_max_body_size 64m;
location / {