Skip to content

Instantly share code, notes, and snippets.

View hypesystem's full-sized avatar

Niels Abildgaard hypesystem

View GitHub Profile
@hypesystem
hypesystem / keybase.md
Last active February 17, 2017 21:19
keybase.md

Keybase proof

I hereby claim:

  • I am hypesystem on github.
  • I am hypesystem (https://keybase.io/hypesystem) on keybase.
  • I have a public key ASAAUdHwkLmLQJRdaklSiNeae5ujL4exU0j6HXhApB6yiQo

To claim this, I am signing this object:

@hypesystem
hypesystem / about.md
Last active August 29, 2015 14:24
module.parent refers to the first requirer only!

Module.parent is useless

module.parent in a node app refers to the parent module of the current module. This is useful for getting paths (for example) relative to the parent, for example used internally in fileGetter:

// Should get localPath in ./, not localPath in ./lib/some-folder
var fileGetter = require("./lib/some-folder/file-getter.js");
var text = fileGetter("./localPath.dat");
@hypesystem
hypesystem / design.json
Created June 19, 2015 14:06
CouchDB (Hardcoded) Multi-dimensional Query (by using List)
{
_id: "_design/user_actions",
_rev: "some-revision",
views: {
what_ever: {
map: function(doc) {
// ...
}
}
},
@hypesystem
hypesystem / main.js
Last active August 29, 2015 14:22
Insignificant Order Deep-Equals for Arrays and Objects in Javascript
function insignificantOrderDeepContains(haystack, needle) {
var matched = false;
haystack.forEach(function(straw) {
if(matched) return;
if(insignificantOrderDeepEquals(straw, needle)) {
matched = true;
}
});
return matched;
}
@hypesystem
hypesystem / api.php
Created March 9, 2015 14:32
Static, dynamic and browser-rendered pages
<?php
header("Content-Type: application/json");
echo json_encode(array(
"name" => "Wilson",
"gender" => "Ball",
"age" => "13"
));
?>
@hypesystem
hypesystem / private-scoping.js
Last active August 29, 2015 14:06
Private scope in node.js / dirty, dirty trick to get private methods
var PublicClass = function() {
this.state = "something";
}
PublicClass.prototype.publicMethod = function() {
privateFunction.call(this); //<-- this is a dirty, dirty trick, running *privateFunction* as a private method
};
function privateFunction() {
console.log(this.state); //<-- in order to make *this* accessible, we need to use the trick above
# Original Rails controller and action
class EmployeesController < ApplicationController
def create
@employee = Employee.new(employee_params)
if @employee.save
redirect_to @employee, notice: "Employee #{@employee.name} created"
else
render :new
end
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// Generic implementation of Martin Fowler's Enterprise Pattern ``Range'':
/// http://martinfowler.com/eaaDev/Range.html
///
@hypesystem
hypesystem / JobApplicant.cs
Last active August 29, 2015 13:57
3 Job Description - refactored
using System.Collections.Generic;
using System.Linq;
///<summary>
///Original: http://3dk.easycruit.com/vacancy/1161591/3032?iso=dk
///Their own repost: https://3dk.easycruit.com/vacancy/1385970/3032?iso=dk
///</summary>
namespace JobAd
{