Skip to content

Instantly share code, notes, and snippets.

View patrickbeeson's full-sized avatar

Patrick Beeson patrickbeeson

View GitHub Profile
@patrickbeeson
patrickbeeson / gist:e7e848e3398f287c86ea
Created December 26, 2014 15:34
Python Weekend Checker
"""
Function to check if today's date is a weekend day (i.e. Saturday or Sunday)
"""
import datetime
def check_if_weekend(today):
try:
isinstance(today, datetime.datetime)
upper_limit = today + datetime.timedelta(days=(6 - today.weekday()))
lower_limit = today + datetime.timedelta(days=(5 - today.weekday()))

Exercism and IntelliJ IDEA

So, you want to use IntelliJ IDEA for your Exercism.io Java exercises?

Here’s my workflow. Note, using IntelliJ IDEA CE 14.

Gradle setup

  • [ ] cd to $EXERCISM_DIR/java/the-exercise
  • [ ] Run gradle idea to generate the *.iml* and =.idea files/dirs
@patrickbeeson
patrickbeeson / js_redirect.js
Last active March 25, 2016 00:45
JS Redirect
<script type="text/javascript">
location = 'domaintoredirectto.com';
</script>
function htmlEncode(value){
return $('<div/>').text(value).html();
};
@patrickbeeson
patrickbeeson / gist:36bc6a30c158862af17a
Created February 8, 2015 12:37
AJAX Prefilter function
$.ajaxPrefilter( function( options, originalOptions, jqXHR ) {
options.url = 'http://backbonejs-beginner.herokuapp.com' + options.url;
});
@patrickbeeson
patrickbeeson / gist:056f2bf810c6a2b393aa
Created February 8, 2015 12:36
Function to serialize object
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
@patrickbeeson
patrickbeeson / gist:b2505a7de937ec9d963b
Created January 28, 2015 16:09
Python Callables with Hysterersis
>>> class Factorial(Callable):
... def __init__(self):
... self.previous = {}
... def __call__(self, n):
... if n not in self.previous:
... self.previous[n] = self.compute(n)
... return self.previous[n]
... def compute(self, n):
... if n == 0 : return 1
... return n*self.__call__(n-1)
@patrickbeeson
patrickbeeson / gist:bdf92777ca6db5c59d02
Created November 24, 2014 19:50
Find MX records via the command line
dig -t mx website.com
@patrickbeeson
patrickbeeson / gist:56a8f951cdd18d1910ff
Created November 17, 2014 19:10
Use Vitualenvwrapper with pyvenv
# Put in bashrc
export VIRTUALENVWRAPPER_VIRTUALENV="pyvenv"
@patrickbeeson
patrickbeeson / dev_requirements.txt
Created October 14, 2014 15:22
Basic dev requirements
coverage
sphinx
pyflakes
pep8