Skip to content

Instantly share code, notes, and snippets.

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

Christiaan Scheermeijer ChristiaanScheermeijer

🏠
Working from home
View GitHub Profile
@ChristiaanScheermeijer
ChristiaanScheermeijer / App.tsx
Created May 23, 2023 19:50
Simple TypeScript DI with React
import React from 'react';
import { ServiceContainer } from './ServiceContainer';
import ContainerProvider from './ContainerProvider';
import { Test } from './Test';
import App from './App';
const container = new ServiceContainer();
// register all service classes in the container
container.register(Test);
@ChristiaanScheermeijer
ChristiaanScheermeijer / LiveData.sagas.js
Created March 9, 2018 15:45
Redux Saga with WebSocket
import { eventChannel, END } from 'redux-saga';
import { call, put, take, fork, cancel, cancelled } from 'redux-saga/effects';
import * as LiveDataActions from '../../redux/LiveData/LiveData.actions';
import * as LiveDataTypes from '../../redux/LiveData/LiveData.types';
// Use this to actually throw exceptions, allows for easier debugging.
const dispatch = put.resolve;
function createWebSocketConnection() {
return new Promise((resolve, reject) => {
@ChristiaanScheermeijer
ChristiaanScheermeijer / cordova_appcenter.rb
Created February 16, 2018 15:32
Use Cordova iOS project in MS App Center without opening Xcode
#!/usr/bin/env ruby
require 'xcodeproj'
# This script allows you to build debug and/or appstore builds via MS App Center.
# Using a CI/CD the Cordova application gets build. The iOS project is then
# committed to a separate repository which is connected to MS App Center.
# However, without opening the iOS project in Xcode first and setting up the
# build settings and sharing the scheme, MS App Center can't build the app.
#
# This script creates two schemes. One for debug and one for release. In
@ChristiaanScheermeijer
ChristiaanScheermeijer / LiveReloadPluginScrollTop.js
Created July 13, 2017 09:55
Remember scroll top position while reloading
(function () {
function scrollTopPlugin () {
this.identifier = 'scroll-top';
this.version = '1.0';
this.reload = function () {
try {
window.localStorage.setItem(this.identifier, (document.scrollingElement || document.body).scrollTop);
}catch(e) {
@ChristiaanScheermeijer
ChristiaanScheermeijer / srtToVtt.js
Created June 15, 2017 10:31
SRT to WebVTT in Javascript
(function () {
window.srtToVtt = function (url, cb) {
var xhr = new XMLHttpRequest();
xhr.onload = function () {
var vtt = 'WEBVTT FILE\r\n\r\n';
var blob;
var url;
@ChristiaanScheermeijer
ChristiaanScheermeijer / jasmineAjaxMock.js
Created May 18, 2015 14:59
Simple Jasmine Ajax Mock
'use strict';
var routes = [];
/**
* Simple jQuery ajax mock for jasmine
*
* @example
*
* ## Create a mocked route
@ChristiaanScheermeijer
ChristiaanScheermeijer / dynamicControllerDirective.js
Last active August 29, 2015 14:13
Dynamic controller directive
'use strict';
var DynamicControllerDirective = function ($parse, $compile, $templateRequest, $exceptionHandler) {
return {
restrict: 'A',
link: function (scope, element, attr) {
$templateRequest(attr.dynamicControllerTemplate).then(function (template) {
var templateElement = angular.element(template);
if (templateElement.length !== 1) {
@ChristiaanScheermeijer
ChristiaanScheermeijer / browserstack-credentials.json
Last active September 7, 2018 19:29
Protractor configuration file using BrowserStack and multiple capabilities
{
"username": "your browserstack username",
"key": "your browserstack key"
}