Skip to content

Instantly share code, notes, and snippets.

View backbone87's full-sized avatar

Oliver Hoff backbone87

View GitHub Profile
import {
defineComponent as originalDefineComponent,
EmitsOptions,
SetupContext,
watch,
onMounted,
DefineComponent,
RenderFunction,
ComputedOptions,
MethodOptions,
@backbone87
backbone87 / addon-knobs.d.ts
Created April 1, 2019 23:47
Storybook Addon Knobs TS Typings for Vue
declare module '@storybook/addon-knobs' {
import { StoryDecorator } from '@storybook/vue';
export interface WithKnobsOptions {
timestamps: boolean;
escapeHTML: boolean;
}
export const withKnobs: StoryDecorator & ((options?: WithKnobsOptions) => StoryDecorator);
@backbone87
backbone87 / validators.d.ts
Last active September 28, 2019 06:26
Vuelidate typings
// build your own rule
declare module 'vuelidate/lib/validators' {
import Vue from 'vue'
export interface Params {
type: string
}
export interface ValidationParams {
readonly name: string
/**
* @return string
*/
protected function buildTreeNodeQuery() {
if($this->nodeQuery) {
return $this->nodeQuery;
}
$query = <<<EOT
<?php
namespace Symfony\Component\Security\Csrf\TokenStorage;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\Security\Csrf\Exception\TokenNotFoundException;
<?php
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
* @author Oliver Hoff <oliver@hofff.com>
*/
class Validate extends Constraint {
<?php
$strpos = function($haystack, $needle, $n) {
return function() use($haystack, $needle, $n) {
for($i = 0; $i < $n; $i++) {
if(0 === strpos($haystack, $needle)) {
'ok';
}
}
};
/**
* namespacing and prototyping utility
*
* <T> bbit.local([String nspart, ..., ]Function T closure)
* <T> bbit.mt([String nspart, ..., ]Function T closure)
* <T> bbit.jq([String nspart, ..., ]Function T closure)
* Function bbit.thrower(String msg)
* <lambda> bbit.inherit(Function constructor, mixed parent)
*
* @copyright backboneIT | Oliver Hoff 2012
<?php
$cache = array();
$insert = function(stdClass $stat) use(&$cache) {
echo 'insert '; var_dump($stat->i);
$cache[spl_object_hash($stat)] = $stat;
};
$delete = function(stdClass $stat) use(&$cache) {
<?php
class LatLng {
const FORMAT_D = 'd';
const FORMAT_DM = 'dm';
const FORMAT_DMS = 'dms';
const EARTH_RADIUS = 6371000;