Skip to content

Instantly share code, notes, and snippets.

View roelofjan-elsinga's full-sized avatar
Building fast applications

Roelof Jan Elsinga roelofjan-elsinga

Building fast applications
View GitHub Profile
@roelofjan-elsinga
roelofjan-elsinga / schema.xml
Last active August 6, 2018 07:06
A custom field type in Solr
<!--- Other content --->
<fieldType name="case_insensitive_string" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
<filter class="solr.TrimFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
@roelofjan-elsinga
roelofjan-elsinga / dynamic.routes.ts
Last active December 9, 2019 14:23
Dynamic routes for Angular
import {NgModule} from '@angular/core';
import {HomeComponent} from './home/home.component';
import {AboutUsComponent} from './about-us/about-us.component';
import {ContactComponent} from './contact/contact.component';
export class DependencyInjectionClass {
constructor(private _service: FictionalService) {}
resolve(route, state) {
//Get some fictional data with the id that's in the URL
@roelofjan-elsinga
roelofjan-elsinga / static.routes.ts
Last active December 9, 2019 14:23
Angular routing module
import {NgModule} from '@angular/core';
import {HomeComponent} from './home/home.component';
import {AboutUsComponent} from './about-us/about-us.component';
import {ContactComponent} from './contact/contact.component';
import {UIRouterUpgradeModule} from "@uirouter/angular-hybrid";
export const StaticPagesRoutes = {
states: [
{
name: 'home',
@roelofjan-elsinga
roelofjan-elsinga / app.module.ts
Created July 22, 2018 07:08
UI router angular hybrid in the app.module
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {UpgradeModule} from '@angular/upgrade/static';
import {AppComponent} from './app.component';
import {UIRouterUpgradeModule} from "@uirouter/angular-hybrid";
@NgModule({
declarations: [
AppComponent
],
@roelofjan-elsinga
roelofjan-elsinga / any.component.ts
Created July 3, 2018 19:49
Subscribing to an action in Angular 6
import {Component, OnInit} from '@angular/core';
import {NgRedux, select} from "@angular-redux/store";
import {IAppState} from "./path/to/state";
@Component({
selector: 'app-any',
templateUrl: './any.component.html',
styleUrls: ['./any.component.scss']
})
export class AnyComponent implements OnInit {
@roelofjan-elsinga
roelofjan-elsinga / angularjs.ts
Created July 3, 2018 19:35
Dispatch an action with AngularJS in Redux
import * as angular from 'angular';
import ngRedux from 'ng-redux';
import {ADD_LANGUAGE} from "../../../app/redux/actions";
angular.module("any.module", [ngRedux])
.run(['$ngRedux', $ngRedux => {
let language = {
shortcode: 'en',
@roelofjan-elsinga
roelofjan-elsinga / state.ts
Created July 3, 2018 19:26
Example IAppState
import {ILanguage} from "./languages";
export interface IAppState {
languages: ILanguage[];
}
@roelofjan-elsinga
roelofjan-elsinga / initial-state.ts
Created July 3, 2018 19:23
The example initial state in Redux
import {IAppState} from "../interfaces/state";
export const INITIAL_STATE: IAppState = {
languages: []
};
@roelofjan-elsinga
roelofjan-elsinga / index.ts
Created July 3, 2018 19:19
Example store in Redux
import {createStore} from 'redux';
import {rootReducer} from "./reducers";
import {INITIAL_STATE} from "./reducers/initial-state";
export const store = createStore(rootReducer, INITIAL_STATE);
@roelofjan-elsinga
roelofjan-elsinga / languages.ts
Created July 3, 2018 19:06
Example languages reducer in Redux
import {ADD_LANGUAGE} from "../actions";
import {INITIAL_STATE} from "./initial-state";
import {ILanguage} from "../interfaces/languages";
export function languages(state = INITIAL_STATE.languages, action):ILanguage[] {
switch (action.type) {
case ADD_LANGUAGE:
return state.concat(Object.assign({}, action.language));
}