Skip to content

Instantly share code, notes, and snippets.

@iredun
iredun / bk.py
Created February 19, 2018 12:57
The python script at the start of which copies all the files in the View folder in the "Download" folder to the folder in the format %d_%m_%Y_bk, also moves the previously created folders every week to a folder of the format %d_%m_%Y_week_db
import shutil
import os
import datetime
from winreg import *
with OpenKey(HKEY_CURRENT_USER, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders') as key:
Downloads = QueryValueEx(key, '{374DE290-123F-4565-9164-39C4925E467B}')[0]
main_folder = Downloads + "\\"
now = datetime.datetime.now()
@iredun
iredun / saveAllSheetstoFiles.vba
Created July 13, 2017 05:59
Сохраняет все активные листы в разные файлы xls
Sub SaveSheets()
Dim s As Worksheet
Dim wb As Workbook
Set wb = ActiveWorkbook
For Each s In wb.Worksheets
s.Copy
ActiveWorkbook.SaveAs Filename:=wb.Path & "\" & s.Name, FileFormat:=xlExcel8
Next
End Sub
@iredun
iredun / sslcurl.php
Created April 24, 2017 15:42
get ssl page php func
function getSslPage($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
@iredun
iredun / js.js
Created April 20, 2017 11:52
scrollTo jQuery extend
jQuery.fn.extend(
{
scrollTo : function(speed, easing)
{
return this.each(function()
{
var targetOffset = $(this).offset().top;
$('html,body').animate({scrollTop: targetOffset}, speed, easing);
});
}
@iredun
iredun / encoder.py
Created March 17, 2017 17:53
Python скрипт для рекурсивного перевода файлов(можно указать несколько типов файлов) из кодировки CP1251 в UTF8
import os, codecs
for (dir, _, files) in os.walk("./"):
for f in files:
path = os.path.join(dir, f)
if f.endswith(('php')):
if os.path.exists(path):
data = open(path, "rb").read()
print(path)
if data.startswith(codecs.BOM_UTF8):
continue
@iredun
iredun / new.js
Created January 26, 2017 12:10
Target _new
jQuery('a[target^="_new"]').click(function() {
return openWindow(this.href);
}
function openWindow(url) {
if (window.innerWidth <= 640) {
// if width is smaller then 640px, create a temporary a elm that will open the link in new tab
var a = document.createElement('a');
@iredun
iredun / soc_sharing.md
Created January 26, 2017 12:10
Social sharing doc

Facebook Share

Стандартная кнопка для “шаринга” URL с дополнительным текстом. HTTP-endpoint: http://www.facebook.com/sharer.php Параметры: u — url t — сопровождающий текст UPD: Для передачи описания страницы используйте OpenGraph, обсуждение на SO

@iredun
iredun / export.php
Created January 21, 2017 16:57
Перенос пользовательских свойств 1С-Битрикс (с названиями + в обход тех которые уже есть)
<?php
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Export");
$arResult = array();
$rsData = CUserTypeEntity::GetList( array("ID"=>"ASC"), array("LANG" => "ru") );
while($arRes = $rsData->Fetch())
{
$ar_res = CUserTypeEntity::GetByID( $arRes['ID'] );
$arResult[] = $ar_res;
}
@iredun
iredun / lvm.txt
Last active January 19, 2017 14:31
Как увеличить LVM раздел OS Linux CentOS Оригинал - https://anart.ru/server/2013/07/23/uvelichenie-diska-virtualbox-i-gostevoj-sistemyi-linux.html
Смотрим, что у нас имеется на данный момент из устройств/разделов
# fdisk -l
Диск /dev/sda: 21.5 ГБ, 21474836480 байт
...
Устр-во Загр Начало Конец Блоки Id Система
/dev/sda1 * 1 64 512000 83 Linux
/dev/sda2 64 653 4729856 8e Linux LVM
/dev/sda3 653 1305 5239532+ 8e Linux LVM
@iredun
iredun / init.php
Last active January 18, 2017 12:15
Выводит инфоблоки в админке только текущего сайта (https://dev.1c-bitrix.ru/community/webdev/user/11948/blog/2692/)
<?
AddEventHandler('main', 'OnBuildGlobalMenu', 'ASDOnBuildGlobalMenu');
function ASDOnBuildGlobalMenu(&$aGlobalMenu, &$aModuleMenu)
{
$arSites = array(
'www.site.ru' => 's1',
'site.ru' => 's1',
);
$arIBsites = array();