Skip to content

Instantly share code, notes, and snippets.

View maximilianschmitt's full-sized avatar

Max Schmitt maximilianschmitt

View GitHub Profile
@maximilianschmitt
maximilianschmitt / rewrite.js
Created November 6, 2023 16:52
Rewrite absolute TypeScript paths to relative ones
View rewrite.js
const fs = require("fs");
const path = require("path");
const srcDir = path.join(__dirname, "src");
// Define the absolute paths to replace and their corresponding relative paths
const patterns = {
"@pages/": "./src/pages/",
"@lib/": "./src/",
"@components/": "./src/components/",
@maximilianschmitt
maximilianschmitt / server.js
Last active November 25, 2017 15:14
Redirects on the server with react-router, express and iniquest
View server.js
app.use(function(req, res, next) {
const router = Router.create({
routes,
location: req.path
});
router.run(function(Handler, state) {
router.transitionTo = function() {
const redirectUrl = router.makeHref.apply(router, arguments);
return Promise.reject({ reason: 'redirect', redirectUrl });
@maximilianschmitt
maximilianschmitt / gulpfile.js
Created April 27, 2015 18:24
Using watchify with gulp
View gulpfile.js
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var notifier = require('stream-notifier');
var watchify = require('watchify');
gulp.task('browserify', function() {
var bundler = browserify('./src/main')
@maximilianschmitt
maximilianschmitt / readme.md
Last active August 29, 2015 14:19
Compiling your ES6 command line apps to work with node.js
View readme.md
@maximilianschmitt
maximilianschmitt / readme.md
Last active August 29, 2015 14:19
How to add an Istanbul code coverage badge to your GitHub repository
View readme.md
@maximilianschmitt
maximilianschmitt / readme.md
Last active August 29, 2015 14:19
Making your io.js command line apps compatible with node.js
View readme.md
@maximilianschmitt
maximilianschmitt / mock-socket.js
Last active August 29, 2015 14:10
socket.io Mock
View mock-socket.js
'use strict';
var EventEmitter = require('events').EventEmitter;
var mockSocket = function() {
return {
toServer: new EventEmitter(),
toClient: new EventEmitter(),
disconnect: function() {
this.toServer.emit('disconnect');
@maximilianschmitt
maximilianschmitt / jobs.js
Created September 3, 2014 23:47
Automated MySQL backups to S3 with node.js
View jobs.js
'use strict';
var mysqlBackup = require('./mysql-backup');
var schedule = require('node-schedule');
schedule.scheduleJob({ hour: 22, minute: 0 }, mysqlBackup);