Skip to content

Instantly share code, notes, and snippets.

View screeny05's full-sized avatar

Sebastian Langer screeny05

View GitHub Profile
<?php
/**
* @author Sebastian Langer <sl@scn.cx>
* @license MIT
*/
use Shopware\Bundle\StoreFrontBundle\Service\Core\ContextService;
use Shopware\Bundle\StoreFrontBundle\Gateway\DBAL\MediaGateway;
use Shopware\Components\Compatibility\LegacyStructConverter;
<?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 <sl@scn.cx>
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)) {
type Color = string;
class Player {
constructor(public name: string, public color: Color){ }
}
type Field = Player|null;
class GameField {
private fields: Field[][];
// jquery.d.ts
interface JQuery {
toggleClass(name: string, add: boolean): JQuery;
}
interface JQueryStatic {
(...any): JQuery;
fn: JQuery;
}
declare const $: JQueryStatic;
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)
@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 => {
<div class="overlay">
OVERLAY
<div class="scroll--container">
<div class="scroll">
<a href="#" class="scroll--link">Link</a>
<a href="#" class="scroll--link">Link</a>
<a href="#" class="scroll--link">Link</a>
<a href="#" class="scroll--link">Link</a>
<a href="#" class="scroll--link">Link</a>
<body id="body" style="" class="">
<div class="" style=" height: 1000vh; "></div>
<div class="org" style="top: 0px; width: 750px; height: auto; display: block; opacity: 1;position: fixed; bottom: auto;right: 0; left: 0; top: 0; bottom: 0; margin: auto; background: padding-box #fff; max-height: 100%; max-width: 100%; z-index: 7000; overflow-x: hidden; overflow-y: auto;">
<div class="" style=" height: 120px; background: aqua; "></div>
<div class="" style=" background: magenta; height: 200px; "></div>
<div class="" style=" white-space: nowrap; overflow: auto; ">
<span class="" style="width: 100%;display: inline-block;background: tomato;height: 90vh;"></span>
<span class="" style="width: 100%;display: inline-block;height: 400px;background: rebeccapurple;"></span>
</div>
</div>
@screeny05
screeny05 / papershift-overtime.js
Created November 2, 2017 11:17
Papershift overtime calculator (paste in console)
(function getOvertime(){
const padLeftTwo = str => ('' + str).length === 1 ? '0' + str : str;
const now = new Date();
const today = now.getFullYear() + '' + padLeftTwo(now.getMonth() + 1) + '' + padLeftTwo(now.getDate());
const days = {};
$('#time_trackings_list .entry').each((i, el) => {
const dayKey = $(el).find('.day span').text().slice(0,8);
const dayHours = parseFloat($(el).find('.netto_time').text().replace(' h', ''));