Skip to content

Instantly share code, notes, and snippets.

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

Konstantin Tarkus koistya

🏠
Working from home
View GitHub Profile
@koistya
koistya / web.config.xml
Created November 14, 2014 13:38
ASP.NET 5 Beta 1 Default Configuration File for IIS
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta1" />
<add key="kre-package-path" value="..\approot\packages" />
<add key="kre-version" value="1.0.0-beta1" />
<add key="kre-clr" value="CoreCLR" />
<add key="kre-app-base" value="..\approot\packages\App\1.0.0\root" />
</appSettings>
@koistya
koistya / ComponentA.js
Created November 17, 2014 19:44
Creating a React component
export class ComponentA {
render() {
return <form onSubmit={this.handleSubmit}>...</form>;
},
handleSubmit(e) {
// TODO: handle submit
}
}
@koistya
koistya / ComponentA.js
Last active August 29, 2015 14:09
Which naming convention do you use when create React components?
export class ComponentA {
render() {
return <form onSubmit={this.handleSubmit}>...</form>;
},
handleSubmit(e) {
// TODO: handle submit
}
}
var { Promise } = require('es6-promise');
export class HttpClient {
get(url) {
// Return a new promise
return new Promise((resolve, reject) => {
// Do the usual XHR stuff
var request = new XMLHttpRequest();
request.open('GET', url, true);
@koistya
koistya / variables.less
Last active August 29, 2015 14:12
Media queries breakpoints
// Media queries breakpoints
// ------------------------------------------------------------------------------
// Small screen / tablet
@screen-sm-min: 768px;
// Medium screen / desktop
@screen-md-min: 992px;
// Large screen / wide desktop
@koistya
koistya / AppActions.js
Last active August 29, 2015 14:13
You might not need XXX_SUCCESS, XXX_ERROR for each of your action types in Flux / ReactJS apps.
/*
* React.js Starter Kit
* Copyright (c) 2014 Konstantin Tarkus (@koistya), KriaSoft LLC.
*/
'use strict';
var Dispatcher = require('../core/Dispatcher');
var ActionTypes = require('../constants/ActionTypes');
var SourceTypes = require('../constants/SourceTypes')
@koistya
koistya / String.prototype.js
Created February 4, 2015 11:49
String.prototype.startsWith polyfil
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function(str) {
return this.lastIndexOf(str, 0) === 0;
};
}
  • Things placed in the registry are effectively black boxes with regards to the rest of the system. This makes it harder to detect and recover from their errors, and may make the system as a whole less reliable.
  • The registry must be unique, which can make it a bottleneck for concurrent applications.
  • The registry can be a serious security vulnerability, because it allows outsiders to inject code into an application.
  • The registry hides the class' dependencies, causing run-time errors instead of compile-time errors when dependencies are missing.
  • The registry makes the code more difficult to maintain (opposed to using Dependency injection), because it becomes unclear when you would be introducing a breaking change
  • The registry makes code harder to test, since all tests need to interact with the same global service locator class to set the fake dependencies of a class under test.
@koistya
koistya / Split-URL-path.md
Last active August 29, 2015 14:16
Split URL path

Write a function which transforms a URL path like /a/b/c
into an array ['/', '/a', '/a/b', '/a/b/c']

(function split(path, array) {
  return path === '/' ? ['/'].concat(array) :
    split('/' + path.substr(1, path.lastIndexOf('/') - 1), [path].concat(array));
})('/a/b/c', []);
@koistya
koistya / .gitignore_global
Created March 27, 2015 19:34
Global .gitignore
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*