Skip to content

Instantly share code, notes, and snippets.

@jurchiks
jurchiks / USAGE.md
Last active May 12, 2022 17:52
PHP class to calculate workdays/holidays after a given date/between dates
$weekdayCalculator = new WeekdayCalculator();
$weekdayCalculator->addSpecialWorkday(new Date('2022-01-08')); // Override Saturday as a workday.
// Sunday stays a normal holiday as usual.
$weekdayCalculator->addSpecialHoliday(new Date('2022-01-10')); // Override the following Monday as a holiday.
// As a result, we've shifted the workday one day back.

var_dump(
	$weekdayCalculator->isWorkday(new Date('2022-01-08')), // Returns TRUE - we manually set this date as a workday.
	$weekdayCalculator->isHoliday(new Date('2022-01-09')), // Returns TRUE - normal holiday.
@jurchiks
jurchiks / input.scss
Created May 9, 2022 16:51
Generated by SassMeister.com.
.icon:before {
font-family: "your-font-name";
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-style: normal;
font-variant: normal;
font-weight: normal;
text-decoration: none;
text-transform: none;
}
@jurchiks
jurchiks / input.scss
Created May 9, 2022 16:41
Generated by SassMeister.com.
.icon:before {
font-family: "your-font-name";
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-style: normal;
font-variant: normal;
font-weight: normal;
text-decoration: none;
text-transform: none;
}
@jurchiks
jurchiks / ExceptionTestCase.php
Created September 25, 2019 10:13
PHPUnit - broken public method calls in constructor
<?php
use PHPUnit\Framework\TestCase;
class ExceptionTestCase extends TestCase
{
public function testException()
{
$this->expectException(TypeError::class);
$this->expectExceptionMessage('call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object');
$this->getMockBuilder(Foo::class)
@jurchiks
jurchiks / git_update_master.bat
Last active January 22, 2021 02:13
Switch to master, pull from upstream, push to origin (+optionally delete feature branch)
@echo off
set main_branch=master
REM store current branch name in variable
for /f "delims=" %%a in ('git rev-parse --abbrev-ref HEAD') do @set branch=%%a
git checkout %main_branch% & git pull upstream %main_branch% & git push
REM this GOTO crap is only necessary because CMD doesn't support IF (foo && bar)
@jurchiks
jurchiks / multiple.conf
Last active January 12, 2016 18:02
Nginx config for multiple hosts, multi-user, multi-project
server {
listen 80;
server_name ~^(?<project>.+)\.(?<username>.+)\.hhvm\.dyninno\.net$;
if (!-d /home/$username/public_html/$project) {
return 405;
break;
}
set $root /home/$username/public_html/$project;
@jurchiks
jurchiks / Output.txt
Last active January 5, 2016 16:58
php pdo query() throws error AND exception when mysql server has gone away
PHP Warning: PDO::query(): MySQL server has gone away in C:\Users\Juris\Desktop\test\test.php on line 23
Warning: PDO::query(): MySQL server has gone away in C:\Users\Juris\Desktop\test\test.php on line 23
PHP Warning: PDO::query(): Error reading result set's header in C:\Users\Juris\Desktop\test\test.php on line
23
Warning: PDO::query(): Error reading result set's header in C:\Users\Juris\Desktop\test\test.php on line 23
Exception: connection problem. Message: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
@jurchiks
jurchiks / closeOnOverlayClick.patch
Created November 1, 2013 12:17
jQuery UI modal dialog close on overlay click option.
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index c5bd42a..9512c10 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -26,6 +26,7 @@ $.widget( "ui.dialog", {
autoOpen: true,
buttons: [],
closeOnEscape: true,
+ closeOnOverlayClick: false,
closeText: "Close",
import java.util.HashSet;
import java.util.Set;
import listeners.IBlockingAltListener;
import listeners.IBlockingListener;
import listeners.IItemReceiveListener;
import listeners.IPlayerDeathListener;
public enum EventDispatcher
{