Skip to content

Instantly share code, notes, and snippets.

View jacobwalkr's full-sized avatar

jacob jacobwalkr

  • On The Beach
  • Sheffield
View GitHub Profile
@jacobwalkr
jacobwalkr / viewfactory.class.php
Last active December 11, 2015 17:28
ViewFactory class file. I'd like three classes that have the same logic as ViewFactory, but that implement their own build() logic. Is it possible to do it so that all three sub-classes are ViewFactorys? I'm especially trying to avoid copying and pasting the code because that seems to contradict OOP principles.
<?php
abstract class ViewFactory
{
private $view;
private $viewParameters;
private $database;
public function __construct($_database)
{
$this->view = new View(); // Defined elsewhere
@jacobwalkr
jacobwalkr / CodeTeam10.java
Created November 7, 2013 14:16
Code team 10
/*
* COM1001 Crossover Assignment 1
* Team 10
*/
import sheffield.*;
public class CodeTeam10 {
private static Student[] students;
private static Lecturer[] lecturers;
@jacobwalkr
jacobwalkr / fizzbuzz.hs
Last active August 29, 2015 14:07
Start of Fizzbuzz in Haskell
noRem :: Int -> Int -> Bool
noRem x y = (rem x y) == 0
fizzbuzz :: Int -> String
fizzbuzz x
| noRem x 15 = "fizzbuzz"
| noRem x 3 = "fizz"
| noRem x 5 = "buzz"
| otherwise = show x
@jacobwalkr
jacobwalkr / 02-lastbutone.hs
Created October 21, 2014 14:58
H-99 problem 2
myLastButOne :: [a] -> a
myLastButOne [] = error "Not enough elements!"
myLastButOne [x] = error "Not enough elements!"
myLastButOne [x,y] = x
myLastButOne (_:xs) = myLastButOne xs
require "curses"
include Curses
SNAKE = "\u2588\u2588"
init_screen
begin
crmode
curs_set 0
use std::io;
use std::collections::HashMap;
use std::borrow::ToOwned;
fn get_number() -> u32 {
let mut number = String::new();
io::stdin().read_line(&mut number).expect("expected number");
return number.trim().parse::<u32>().ok().expect("expected number");
}
module Main (main) where
import Control.Monad
import Control.Applicative
isOpener :: Char -> Bool
isOpener '(' = True
isOpener '[' = True
isOpener '{' = True
isOpener _ = False
@jacobwalkr
jacobwalkr / simple_text_editor.c
Last active July 21, 2016 00:35
C solution for Simple Text Editor on HackerRank
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define APPEND 1
#define DELETE 2
#define PRINT 3
#define UNDO 4
#define MAX_INPUT 1000000
@jacobwalkr
jacobwalkr / 00000000000000_convert_to_gutentag.gutentag.rb
Created February 16, 2018 11:54
Converts an ActsAsTaggableOn database structure for use with Gutentag
# frozen_string_literal: true
# adapted from Gutentag's install migrations
# https://github.com/pat/gutentag
superclass = ActiveRecord::VERSION::MAJOR < 5 ?
ActiveRecord::Migration : ActiveRecord::Migration[4.2]
class ConvertToGutentag < superclass
def up
## taggings
.callout {
padding: 1.25rem;
margin-top: 1.25rem;
margin-bottom: 1.25rem;
border: $card-border-width solid $card-border-color;
border-left-width: .25rem;
@include border-radius($card-border-radius);
h2,h3,h4,h5 {
margin-top: 0;