Skip to content

Instantly share code, notes, and snippets.

View MaksJS's full-sized avatar
🏠
Working from home

Maxence De Rous MaksJS

🏠
Working from home
View GitHub Profile
@codemis
codemis / gist:8225337
Last active November 9, 2021 12:13
A Git pre-commit hook for validating code follows PHP's Fig Coding Standard. The script requires PEAR's Code Sniffer library. Change the variables to fit your project code structure. Just drop this file in your .git/hooks/ directory. This script is a modified file created by Soenke Ruempler.
#!/bin/bash
# PHP CodeSniffer pre-commit hook for git
#
# @author Soenke Ruempler <soenke@ruempler.eu>
# @author Sebastian Kaspari <s.kaspari@googlemail.com>
#
# see the README
PHPCS_BIN=/usr/local/bin/phpcs
PHPCS_CODING_STANDARD=PSR2
@zushane
zushane / pre-commit
Last active April 15, 2019 21:39
A git pre-commit hook to run phpunit tests, written in bash. Features pretty colours, and slightly individualized output.
#!/bin/bash
# Locate our phpunit.
phpunit=`which phpunit`
# Any extra arguments to phpunit should go here.
phpunit_args=""
# Define a location to save the output.
outputlog="/tmp/phpunit_output_`date +%s`.log"
@thomseddon
thomseddon / gist:3511330
Last active March 8, 2023 03:39
AngularJS byte format filter
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
@lancejpollard
lancejpollard / class.coffee
Created October 23, 2011 05:25
ruby methods for coffeescript
moduleKeywords = ['included', 'extended', 'prototype']
class Class
# Rename an instance method
#
# ``` coffeescript
# class User
# @alias "methods", "instance_methods"
#
# ```
@thejh
thejh / getUserExample.coffee
Created July 18, 2011 12:13
getUser example for method overloading example
getUser = (*) ->
(name) when typeof name is 'string' ->
User.lookup 'name', name
(id) when typeof id is 'number' ->
User.lookup 'id', id
->
throw new Error "invalid arguments"
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/