Skip to content

Instantly share code, notes, and snippets.

View hglattergotz's full-sized avatar

Henning Glatter-Götz hglattergotz

View GitHub Profile
@hglattergotz
hglattergotz / custom_naming.xml
Last active January 24, 2024 17:04
Example of how to customize the ShortVariable rule in PHP Mess Detector
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Custom Naming Rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
Customizations for the naming rule sets. Do not include the naming ruleset in the options.
This customization pulls all naming rules in and overrides some properties.
</description>
{
"_links": {
"self": {
"href": "https://api.foxycart.com/users/1",
"title": "This User"
},
"https://api.foxycart.com/rels/attributes": {
"href": "https://api.foxycart.com/users/1/attributes",
"title": "Attributes for This User"
},

Keybase proof

I hereby claim:

  • I am hglattergotz on github.
  • I am hglattergotz (https://keybase.io/hglattergotz) on keybase.
  • I have a public key whose fingerprint is 920F 89A9 D47D F82A D46D 8C16 F640 DC21 0505 3AF4

To claim this, I am signing this object:

@hglattergotz
hglattergotz / gist:2645678
Created May 9, 2012 15:41
~/.git-prompt.conf
### GIT-PROMPT.SH CONFIG
###
### lines commented-out with single '#' are default values
### lines commented-out with double '##' are examples
###
### NOTE: this is bash syntax - no spaces around "="
###########################################################
# error_bell=off # sound terminal bell when command return code is not zero. (use setterm to set pitch and duration)
@hglattergotz
hglattergotz / exercise7p2.js
Created November 11, 2011 15:07
Homework Exercise 7 part 2
// Part 2.
// Use this new function to refactor the code example.
// Some good test numbers: 524287, 9369319, 2147483647 (all primes)
//
// In other words, if you have this code:
//
// Function.prototype.cached = function(){
// ? (what goes here?)
// }
//
@hglattergotz
hglattergotz / exercise7p1.js
Created November 11, 2011 14:54
Homework Exercise 7 part 1
// Part 1.
// Implement a function prototype extension that caches function results for
// the same input arguments of a function with one parameter.
//
// For example:
// Make sin(1) have the result of Math.sin(1), but use a cached value
// for future calls.
Function.prototype.cached = function() {
var cache = {}, extendedFunction = this;
@hglattergotz
hglattergotz / exercise1.2.js
Created November 11, 2011 01:05
Homework 1.2
function Car(make, color) {
return {
make: arguments[0],
color: arguments[1],
log : function() {
console.log("I'm a " + this.color + " " + this.make);
}
};
}
@hglattergotz
hglattergotz / exercise1.1.js
Created November 11, 2011 01:00
Homework 1.1
var car = {
make: 'Maserati',
color: 'silver'
}
function logCar() {
console.log("I'm a " + arguments[0].color + " " + arguments[0].make);
}
logCar(car);
var cdClosure = function() {
var index;
function log() {
console.log(index);
}
function iterate() {
log();
function isCreditCard( CC ) {
var sum, mul, l, digit, tproduct, i;
if (CC.length > 19)
return (false);
sum = 0; mul = 1; l = CC.length;
for (i = 0; i < l; i++) {
digit = CC.substring(l-i-1, l-i);