Skip to content

Instantly share code, notes, and snippets.

View fedek6's full-sized avatar
🎯
Focusing

Konrad Fedorczyk fedek6

🎯
Focusing
View GitHub Profile
@fedek6
fedek6 / remove_old_log_entries.sql
Last active August 21, 2018 13:19
Log rotation in MySQL table
DELETE FROM logs WHERE id IN (select id from (select id FROM log ORDER BY id DESC LIMIT 1000, 500) x)
@fedek6
fedek6 / Controller.php
Created December 3, 2018 12:39
Prepend application name to site title in Yii2
<?php
/**
* Extension of base controller.
* Add additional controller functions and vars here.
*/
namespace app\components;
use Yii;
@fedek6
fedek6 / selfpacker.sh
Created December 21, 2018 21:16
Packager for web projects on nix systems.
#!/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 June 7, 2019 08:25
szablon testowy WP
<?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 / zippacker.sh
Created June 24, 2019 18:51
Packer for web projects. It will pack public dir in current path. Archive name will include info from package.json.
#!/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 / between_dates.php
Created July 22, 2019 07:32
Do something between exact two dates in 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 / keyboard.ino
Created April 11, 2017 09:02
Simple keyboard implementation for Arduino
/**
* Arduino USB HID Keyboard Demo
* Keys 1, 2, 3 and 4 on pins 4, 5, 6 and 7
*
* @info check details on my website
* @link http://blog.realhe.ro
*/
uint8_t buf[8] = {
0 }; /* Keyboard report buffer */
@fedek6
fedek6 / parse_logs.ps1
Last active February 25, 2020 21:10
Parse logs for Matomo (Piwik) on Windows [using Powershell]
#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"
@fedek6
fedek6 / synergy.conf
Created March 9, 2021 08:49
Synergy config for Linux -> macOS hosting (fix for altgr error)
section: screens
Fabryka:
halfDuplexCapsLock = false
halfDuplexNumLock = false
halfDuplexScrollLock = false
xtestIsXineramaUnaware = false
switchCorners = none
switchCornerSize = 0
Konrads-MacBook-Pro.local:
halfDuplexCapsLock = false
@fedek6
fedek6 / clean-vsc.sh
Created April 8, 2021 08:29
Clean Visual Studio Code settings (macOS)
#!/bin/sh
rm -rfv "$HOME/.vscode"
rm -rfv "$HOME/Library/Application Support/Code"
rm -rfv "$HOME/Library/Caches/com.microsoft.VSCode"
rm -rfv "$HOME/Library/Saved Application State/com.microsoft.VSCode.savedState"
# Thanks goes to offby1 from stackoverflow!