Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Konrad fedek6

🎯
Focusing
View GitHub Profile
@fedek6
fedek6 / between_dates.php
Created Jul 22, 2019
Do something between exact two dates in PHP
View between_dates.php
<?php
$showDate = "2019-07-16 20:00:00.0";
$hideDate = "2019-07-22 20:00:00.0";
$timezone = new DateTimeZone('Europe/Warsaw');
$now = new DateTime();
$now->setTimezone($timezone);
// If in timeframe
if( $now > new DateTime($showDate, $timezone) && $now < new DateTime($hideDate, $timezone) ) {
do_something();
@fedek6
fedek6 / zippacker.sh
Created Jun 24, 2019
Packer for web projects. It will pack public dir in current path. Archive name will include info from package.json.
View zippacker.sh
#!/bin/sh
# Extract JSON value
parse_json () {
echo $1 | \
sed -e 's/[{}]/''/g' | \
sed -e 's/", "/'\",\"'/g' | \
sed -e 's/" ,"/'\",\"'/g' | \
sed -e 's/" , "/'\",\"'/g' | \
sed -e 's/","/'\"---SEPERATOR---\"'/g' | \
@fedek6
fedek6 / page-test.php
Created Jun 7, 2019
szablon testowy WP
View page-test.php
<?php
/*
* Template Name: Szablon testowy
*/
// taka prościzna do mierzenia czasu wykonania
function timeTook($start, $task = '') {
$execution_time = round( (microtime(true) - $start), 2);
return '<h4>Zadanie: <em>' . $task . '</em> zajęło: ' . $execution_time . ' sekund(y)</h4>';
}
@fedek6
fedek6 / selfpacker.sh
Created Dec 21, 2018
Packager for web projects on nix systems.
View selfpacker.sh
#!/bin/sh
# Extract JSON value
parse_json () {
echo $1 | \
sed -e 's/[{}]/''/g' | \
sed -e 's/", "/'\",\"'/g' | \
sed -e 's/" ,"/'\",\"'/g' | \
sed -e 's/" , "/'\",\"'/g' | \
sed -e 's/","/'\"---SEPERATOR---\"'/g' | \
@fedek6
fedek6 / Controller.php
Created Dec 3, 2018
Prepend application name to site title in Yii2
View Controller.php
<?php
/**
* Extension of base controller.
* Add additional controller functions and vars here.
*/
namespace app\components;
use Yii;
@fedek6
fedek6 / remove_old_log_entries.sql
Last active Aug 21, 2018
Log rotation in MySQL table
View remove_old_log_entries.sql
DELETE FROM logs WHERE id IN (select id from (select id FROM log ORDER BY id DESC LIMIT 1000, 500) x)
@fedek6
fedek6 / .user.ini
Created Jul 27, 2018
Simple PHP large upload test script
View .user.ini
upload_max_filesize = 2048M
post_max_size = 2048M
max_input_time = 3600
@fedek6
fedek6 / web.config
Created Jun 19, 2018
Force https on IIS
View web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Force HTTPS" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
@fedek6
fedek6 / matomo.bat
Created Jun 6, 2018
Automatic log parsing for matomo using Bat
View matomo.bat
@echo off
:: Based on https://matomo.org/docs/log-analytics-tool-how-to/
:: Global config
SET PY_BIN=C:\Program Files\Python\Python27\python.exe
SET IMPORT_LOGS=[path to matomo]\piwik\misc\log-analytics\import_logs.py
SET LOGS_DIR=C:\inetpub\logs\LogFiles
SET TOKEN=****************************
SET URL=http://website.com/piwik/
SET THREADS=2
@fedek6
fedek6 / parse_logs.ps1
Last active Feb 25, 2020
Parse logs for Matomo (Piwik) on Windows [using Powershell]
View parse_logs.ps1
#Based on https://matomo.org/docs/log-analytics-tool-how-to/
#------------------------------------------------------------------------
# Config
#:: Python URL (must be 2.x)
$PY_BIN="C:\Program Files\Python\Python27\python.exe"
#:: Matomo import_logs executable
$IMPORT_LOGS="[path_to_piwik]\piwik\misc\log-analytics\import_logs.py"
You can’t perform that action at this time.