Skip to content

Instantly share code, notes, and snippets.

View jasper-lyons's full-sized avatar
💭
Full time educator, part time developer

Jasper Lyons jasper-lyons

💭
Full time educator, part time developer
View GitHub Profile
@jasper-lyons
jasper-lyons / JPlayer.java
Created December 21, 2011 01:19
Java media player, should be a package to allow easy creation of a java meia player and a player itself.
/*
* The First Class
*
/*
@jasper-lyons
jasper-lyons / AbstractFactory.py
Last active January 4, 2016 02:49
Creational Design Patterns in Python: Abstract Factory
########## The Factory's base class #########
class AbstractFactory(object):
def create_product(self, **args):
raise NotImplementedError("Requires derived factory class for implementation.")
######### The class of the object that needs creating ###########
class Product(object):
@jasper-lyons
jasper-lyons / Builder.py
Created January 22, 2014 13:26
Creational Design Patterns in Python: The Builder
#### The product to contruct ####
class Product(object):
def __init__(self, extra):
self.extra = extra
def do_somthing(self):
print "Doing Something{0}!".format(self.extra)
#### The Builder for a type of product ####
class SomeClass {
public int someMethod(int[] data) {
//do some things
}
public int someMethod(Integer[] data) {
// this bit convert an Integer array into an int array.
int[] newData = int[data.length];
@jasper-lyons
jasper-lyons / gist:c4ceaa8556a9c2d9e78c
Created September 28, 2014 12:20
Safely remove / purge old linux headers.
dpkg -l linux-{image,headers}-* | awk '/^ii/{print $2}' | egrep '[0-9]+\.[0-9]+\.[0-9]+' | grep -v $(uname -r) | xargs sudo apt-get -y purge
@jasper-lyons
jasper-lyons / Seq.java
Created May 7, 2015 14:23
Super Simple Java7 Functional Collection Interface
package utils;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
// This can be replaced with any other Function / Function2 interface
import play.libs.F.Function;
machine:
environment:
JAVA_TOOL_OPTIONS: '-Dfile.encoding=UTF8 -Duser.timezone=UTC'
_JAVA_OPTIONS: '-Xms512m -Xmx1024m -Xss2m'
java:
version: oraclejdk8
python:
version: 2.7.6
services:
- docker
<link rel="import" href="https://rawgit.com/Polymer/polymer/master/polymer.html">
<dom-module id="my-component">
<template>
<content></content>
</template>
<style>
</style>
List<int> weekendDays = Array.asList(1,7);
List<Thing> productiveThings = Array.asList(study, laundry, foodShopping, gym);
List<Thing> thingsDone = days.stream()
// Split infinite stream of days into those that are wednesdays and those that are not
.collect(Collectors.partitionBy(day -> weekendDays.contains(day.get(Calendar.DAY_OF_WEEK))))
.entrySet().stream().map(entry ->
// if day is not weekend and william isn't "busy"
return (!entry.getKey() && isQuoteBusyEndQuote(william))
? beProductive(william, productiveThings)
@echo off
set/p host=host Address:
set logfile=Log_%host%.log
echo Target Host = %host% >%logfile%
for /f "tokens=*" %%A in ('ping %host% -n 1 ') do (echo %%A>>%logfile% && GOTO Ping)
:Ping
for /f "tokens=* skip=2" %%A in ('ping %host% -n 1 ') do (
echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A>>%logfile%