Skip to content

Instantly share code, notes, and snippets.

View meza's full-sized avatar
👋
tweet me if I missed a PR

Meza meza

👋
tweet me if I missed a PR
  • London, United Kingdom
  • 03:13 (UTC +01:00)
View GitHub Profile
@meza
meza / CalculatorTest.java
Last active August 29, 2015 13:56
Mini-blogpost in response of a twitter correspondence
/**
* Disclamer: This is sort of a rant, but without any negative feelings towards the creators of the project
* in question.
* I value their desire to help people write more readable code, and wish there were more people doing this!
* The only thing I'm questioning is the ever growing trend of tools over craft.
*
* This is a mini blog-post in response to https://twitter.com/hhariri/status/435457449232171008
*
* The reason I have some negative feelings is that writing readable code is not rocket
* science, and with tools like Spek, we're basically allowing people to be ignorant about crafting clean
@meza
meza / Gruntfile.js
Created June 11, 2014 19:46
Example of grunt
grunt.loadNpmTasks('grunt-appcache'); // Handles the appcache
grunt.loadNpmTasks('grunt-contrib-jshint'); // Checks if javascript codes are nice or not
grunt.loadNpmTasks('grunt-contrib-clean'); // Removes generated assets
grunt.loadNpmTasks('grunt-contrib-compass'); // Sass shorthands
grunt.loadNpmTasks('grunt-contrib-copy'); // Copies files
grunt.loadNpmTasks('grunt-contrib-cssmin'); // Minifies CSS
grunt.loadNpmTasks('grunt-contrib-watch'); // Watches for changes and acts on them
grunt.loadNpmTasks('grunt-css-metrics'); // Makes sure we don't overdo css files
#!/bin/sh
#
# Pre-commit hooks
compileResult=0
# Compress stuff before committing
SRC_PATTERN="(\.css|\.scss|\.svg)"
git diff --cached --name-only | if egrep "$SRC_PATTERN"
then
echo "----> Found CSS changes, updating the compressed versions"
node_modules/.bin/grunt
@meza
meza / READEM.md
Last active August 29, 2015 14:06
Ubuntu configuration for PAcker

Place the preseed.cfg into a directory named http, so your file structure would look like this:

/

  • http
    • preseed.cgf
  • box.json
@meza
meza / TimeValidator.php
Created October 24, 2011 09:10
TDD vs. Regular Expressions - coding kata
<?php
class TimeValidator
{
public function isValid($time_specification)
{
return 1 == preg_match($this->buildRegExp(), $time_specification);
}
private function buildRegExp()
@meza
meza / globalState.java
Created May 7, 2012 13:16
global state antipattern
class Book {
private String title;
private String author;
private int price;
public String getTitle() {
return title;
}
@meza
meza / globalState2.java
Created May 7, 2012 13:19
Simplified global state
class Book {
public String title;
public String author;
public int price;
}
class Book {
private String title;
private String author;
private int price;
public Book(String title, String author, int price) {
this.title = title;
this.author = author;
this.price = price;
@meza
meza / globalState3.java
Created May 7, 2012 13:27
Book consumer
class BookConsumer {
public void printTheTitleOfABook(Book book) {
if(!book.getTitle().isEmpty()) {
System.out.println(book.getTitle());
}
}
}
@meza
meza / GreetPrinter.java
Created June 22, 2012 13:53
User class
public class GreetPrinter {
public void static main(String[] args) {
User user = new User();
if (args.length > 1) {
user.setEmail(args[0]);
}
Greeter greeter = new Greeter();
String msg = greeter.greetMessage(user);
if (msg != null) {
System.out.println(msg);