Skip to content

Instantly share code, notes, and snippets.

Avatar
💜
Testing statuses

Mikael Brevik mikaelbr

💜
Testing statuses
View GitHub Profile
@mikaelbr
mikaelbr / 0_reuse_code.js
Created Feb 10, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mikaelbr
mikaelbr / InitializaCustomRepository.cs
Created Mar 11, 2014
Override repositories in EpiServer
View InitializaCustomRepository.cs
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
namespace Business.Initialization
{
[InitializableModule]
[ModuleDependency(typeof(ServiceContainerInitialization))]
public class InitializaCustomRepository : IConfigurableModule
{
@mikaelbr
mikaelbr / gulp-filesfound.js
Created May 14, 2014
Example of gulp plugin for logging files found (untested and hammered down in few seconds)
View gulp-filesfound.js
var through = require("through2");
var gutil = require("gulp-util");
// gulp-filesfound
module.exports = function(verbose) {
verbose = !!verbose;
var found = [];
return through.obj(function (file, enc, next) {
found.push(file);
@mikaelbr
mikaelbr / viewswitch.html
Last active Aug 29, 2015
Conceptual view switching - Avoiding imperative code in beautiful declarative markup.
View viewswitch.html
<section>
<hgroup>
<h1>Hello</h1>
<h2>World!</h2>
</hgroup>
<nav>
<ul>
<li>Foo</li>
<li>bar</li>
<li>baz</li>
@mikaelbr
mikaelbr / structure.js
Last active Aug 29, 2015
A propotion for data management in a React.js context and a single top immutable state handler
View structure.js
var Immutable = require('immutable');
var EventEmitter = require('events').EventEmitter;
var fs = require('fs');
var sourceData = {};
try {
sourceData = JSON.parse(fs.readFileSync(__dirname + '/../../sourceData.json', 'utf8'));
} catch (ex) {
console.warn('Could not find source data file:', ex);
View quiescent-for-js.js
var React = require('react');
var EventEmitter = require('events').EventEmitter;
function component (mixins, render) {
if (typeof mixins === 'function') {
render = mixins;
mixins = [];
}
if (!Array.isArray(mixins)) {
@mikaelbr
mikaelbr / list.js
Last active Aug 29, 2015
Using Immutable for top-down rendering
View list.js
var Immutable = require('immutable'),
React = require('react'),
component = require('omniscient');
var data = Immutable.fromJS({
title: 'My list',
items: [ 'one', 'two', 'three' ]
});
var EditMixin = {
View domain-close.js
var data = Immutable.fromJS({
title: 'My page',
posts: [
{ id: 1, title: 'Title 1', tags: ['a', 'b', 'c', 'd', 'e', 'f'] },
{ id: 2, title: 'Title 2', tags: ['a', 'b', 'c', 'd', 'e', 'f'] },
{ id: 3, title: 'Title 3', tags: ['a', 'b', 'c', 'd', 'e', 'f'] },
{ id: 4, title: 'Title 4', tags: ['a', 'b', 'c', 'd', 'e', 'f'] }
]
});
@mikaelbr
mikaelbr / client.js
Last active Aug 29, 2015
Duplex stream chat through TCP
View client.js
var net = require('net');
var port = 8001;
var socket = new net.Socket();
socket.connect(port, function () {
console.log("Connected to", port);
});
process.stdin.pipe(socket).pipe(process.stdout);
@mikaelbr
mikaelbr / component.js
Created Oct 24, 2014
Example shouldComponentUpdate
View component.js
var component = require('omniscient');
var React = require('react');
var someOtherMixins = require('./someMixins');
var setup = {
componentDidMount: function () {
// Some setup.
event.on('data', console.log.bind(console)));
}