Skip to content

Instantly share code, notes, and snippets.

@jacobwyke
jacobwyke / gist:4622583
Created January 24, 2013 14:54
PHP code to work out the number of weekdays between two DateTime objects.
/**
* Weekdays between dates
*
* Works out the number of weekdays between two dates.
* @param DateTime $objStartDate The start date
* @param DateTime $objEndDate The end date
* @return int The number of weekdays or -1 if end date is before start date.
*/
function weekdaysBetweenDates(DateTime $objStartDate, DateTime $objEndDate){
//set the time of the day to the same values since we only care about days
@jacobwyke
jacobwyke / gist:20f7a44434fe612a34fa
Created September 24, 2015 14:44
Solr address synonyms
alley => alley, aly
aly => alley, aly
annex => annex, anx
anx => annex, anx
apartment => apartment, apt
apt => apartment, apt
arc => arc, arcade
arcade => arc, arcade
ave => ave, avenue
avenue => ave, avenue
@jacobwyke
jacobwyke / puppetserver
Last active August 10, 2016 22:51
Puppetserver Monit config file
#
# /etc/monit/conf.d/puppetserver
# Monit file for puppetserver
#
check process puppetserver with pidfile /var/run/puppetlabs/puppetserver/puppetserver.pid
start program "/usr/bin/service puppetserver start" with timeout 120 seconds
stop program "/usr/bin/service puppetserver stop" with timeout 120 seconds
if failed port 8140 with timeout 30 seconds and retry 3 times 3 times within 3 cycles then restart
if 5 restarts within 5 cycles then timeout
@jacobwyke
jacobwyke / beanstalkd
Created May 22, 2016 06:51
Beanstalkd Monit File
#
# /etc/monit/conf.d/beanstalkd
#
check process beanstalkd with pidfile /var/run/beanstalkd.pid
start "/usr/bin/service beanstalkd start"
stop "/usr/bin/service beanstalkd stop"
if failed port 11300
send "stats\r\n"
expect "OK [0-9]{1,}\r\n"
@jacobwyke
jacobwyke / memcached
Created May 22, 2016 07:04
Memcached Monit File
#
# /etc/monit/conf.d/memcached
#
check process memcached with pidfile /var/run/memcached.pid
group memcache
start program = "/usr/bin/service memcached start"
stop program = "/usr/bin/service memcached stop"
if failed host 127.0.0.1 port 11211 protocol MEMCACHE then restart
if 5 restarts within 5 cycles then timeout
@jacobwyke
jacobwyke / url.py
Created November 6, 2017 17:06
Long url regex over allowed line length in PEP8/flake8
urlpatterns = [
url(r'^reset_password/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
views.reset_password, name='reset_password'),
]
@jacobwyke
jacobwyke / url.py
Created November 6, 2017 17:08
Split URL regex so that it passes PEP8/flake8 line length requirements
urlpatterns = [
url(r'^reset_password/(?P<uidb64>[0-9A-Za-z_\-]+)/'
r'(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
views.reset_password, name='reset_password'),
]
@jacobwyke
jacobwyke / tox.ini
Created November 6, 2017 17:20
Jenkins specific tox enviroments
[tox]
envlist = assets, flake8, py35
[tox:jenkins]
envlist = flake8, py35
@jacobwyke
jacobwyke / build.xml
Last active November 6, 2017 17:37
How to pass params to tox via ant build script
<exec dir="${basedir}/src/" executable="/usr/bin/tox" failonerror="true">
<arg line="-e environment -- --option=1 --option2=2"/>
</exec>
@jacobwyke
jacobwyke / build.xml
Created November 6, 2017 17:39
Ant build commands to breakdown tox tests into different components
<exec dir="${basedir}/src/" executable="/usr/bin/tox" failonerror="true">
<arg line="-e py35 -- tests/unit --cov=./ --cov-report=xml --junitxml=junit-unit.xml --cov-append"/>
</exec>
<exec dir="${basedir}/src/" executable="/usr/bin/tox" failonerror="true">
<arg line="-e py35 -- tests/functional --cov=./ --cov-report=xml --junitxml=junit-unit.xml --cov-append"/>
</exec>