Skip to content

Instantly share code, notes, and snippets.

View screeny05's full-sized avatar

Sebastian Langer screeny05

View GitHub Profile
@screeny05
screeny05 / wichteln-server.js
Created December 1, 2017 10:45
Express App zum Wichtel-Ziehen
const express = require('express');
const names = [
'arved',
'ahmad',
'sebastian',
'marcel'
];
const randomIndexFromArray = array => {
const parsePagination = s =>
s
.split(',')
.map(s => {
if(s.match(/^\d+$/)){
return parseInt(s);
}
if(s.match(/^\d+-\d+$/)){
s = s.split('-');
return Array(s[1] - s[0] + 1)
// jquery.d.ts
interface JQuery {
toggleClass(name: string, add: boolean): JQuery;
}
interface JQueryStatic {
(...any): JQuery;
fn: JQuery;
}
declare const $: JQueryStatic;
type Color = string;
class Player {
constructor(public name: string, public color: Color){ }
}
type Field = Player|null;
class GameField {
private fields: Field[][];
abstract class State<T> {
abstract id: T;
isCurrent: boolean = false;
listeners: { [key: string]: Function } = {};
fsm!: StateMachine<T>;
on(event: string, cb: Function): void {
this.listeners[event] = cb;
}
trigger(event: string, data?: any): void {
if (!this.listeners.hasOwnProperty(event)) {
<?php
use Shopware\Bundle\StoreFrontBundle\Service\Core\ContextService;
use Shopware\Bundle\StoreFrontBundle\Gateway\DBAL\MediaGateway;
use Shopware\Components\Compatibility\LegacyStructConverter;
use Enlight_Template_Default;
use InvalidArgumentException;
/**
* @author Sebastian Langer <[email protected]>
<?php
/**
* @author Sebastian Langer <[email protected]>
* @license MIT
*/
use Shopware\Bundle\StoreFrontBundle\Service\Core\ContextService;
use Shopware\Bundle\StoreFrontBundle\Gateway\DBAL\MediaGateway;
use Shopware\Components\Compatibility\LegacyStructConverter;
var historyBackWithFallback = function(url){
var originalHref = window.location.href;
var timeoutId = setTimeout(function(){
if(window.location.href !== originalHref){
return;
}
window.location = 'https://google.de';
}, 1500);
type Extensible<T> = T & { [P in keyof any]: any[P] };
interface IFoo {
value: string;
}
declare const foo: IFoo;
foo.value;
foo.noError;
@screeny05
screeny05 / ffxml-mv.js
Created August 6, 2018 11:24
Rename webfonts from fontforge according to their ps-name
const xml2js = require('xml2js');
const fs = require('fs');
const path = require('path');
const fontsXmlPath = process.argv[2];
const fontsFolderPath = path.resolve(fontsXmlPath, '..', 'Fonts');
const tryRename = (filename, psName) => {
try {
fs.renameSync(path.resolve(fontsFolderPath, filename), path.resolve(fontsFolderPath, psName + path.extname(filename)));