Skip to content

Instantly share code, notes, and snippets.

View HerringtonDarkholme's full-sized avatar

Herrington Darkholme HerringtonDarkholme

View GitHub Profile
@HerringtonDarkholme
HerringtonDarkholme / ctrlp.vim
Last active July 6, 2019 17:48
give syntax highlight for ctrlp vim-devicon
"I borrowed this crazy code from vim-tomorrow-theme colorschemes
" Returns an approximate grey index for the given grey level
fun! s:grey_number(x)
if &t_Co == 88
if a:x < 23
return 0
elseif a:x < 69
return 1
elseif a:x < 103
@HerringtonDarkholme
HerringtonDarkholme / vue.vim
Last active October 3, 2016 16:42
vue syntax highlighting
" Vim syntax file
" Language: Vue.js
" Maintainer: Eduardo San Martin Morote
if exists("b:current_syntax")
finish
endif
if !exists("s:syntaxes")
" Search available syntax files.
@HerringtonDarkholme
HerringtonDarkholme / facai.vue
Created September 26, 2016 16:30
high order component template in Vue2.0
<template>
<p>
<haha>
<v-template inline-template>
<span>{{$ctx.name}}说: 闷声发大财 +{{$ctx.i}}s<br/></span>
</v-template>
</haha>
</p>
</template>
@HerringtonDarkholme
HerringtonDarkholme / nested-for.ts
Created September 25, 2016 08:35
Nested For implementation in Angular2
import {
Component, NgModule, TemplateRef,
Directive, Input, ViewContainerRef,
Compiler, OnChanges, ComponentFactory
} from '@angular/core'
import { CommonModule } from '@angular/common'
@Component({
template: `
@HerringtonDarkholme
HerringtonDarkholme / mytyping.py
Created August 14, 2016 07:24
literal style type annotation experiment in Python3
from typing import Union, TypeVar, _type_check, TypingMeta
import builtins
class MyTypingMeta(type):
def __or__(self, tpe):
return Union[self, tpe]
class MyTypeVar(TypeVar, metaclass=TypingMeta, _root=True):
def __pos__(self):
self.__covariant__ = True
@HerringtonDarkholme
HerringtonDarkholme / test.js
Created May 24, 2016 16:28
babel5 breaks when promise is included
// webpack.config.js
module.exports = {
entry: {
'test': './test',
},
output: {
filename: 'output.js',
},
module: {
loaders: [
@HerringtonDarkholme
HerringtonDarkholme / index.ts
Last active March 22, 2019 17:17
typesafe DI in TypeScript
/// <reference path='./typings/tsd.d.ts' />
import 'reflect-metadata'
type _ = {}
type ClassN<N, T> = { new (...a: N[]): T }
type FN8<A, B, C, D, E, F, G, H, R> = (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H) => R
type CLS8<A, B, C, D, E, F, G, H, R> = { new (a?: A, b?: B, c?: C, d?: D, e?: E, f?: F, g?: G, h?: H): R}
<!--
postMessage(navigator.appName);
/*
-->
<!doctype html>
<title>navigator.appName</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
@HerringtonDarkholme
HerringtonDarkholme / typescript_neomake.vim
Last active February 3, 2016 09:57
Read tsconfig dynamically
let s:enabled_options = [
\ 'target', 'emitDecoratorMetadata', 'experimentalDecorators', 'module',
\ 'noImplicitAny', 'rootDir', 'noEmit', 'allowSyntheticDefaultImports',
\ 'noImplicitReturn', 'allowUnreachableCode', 'allowUnusedLabels'
]
function! neomake#makers#ft#typescript#tsc()
let l:tsconfig = findfile('tsconfig.json', '.;')
if len(l:tsconfig)
let true = 1
@HerringtonDarkholme
HerringtonDarkholme / typescript.ctags
Created October 10, 2015 08:37
An updated ctags file for typescript
--langdef=typescript
--langmap=typescript:.ts
--regex-typescript=/^[ \t]*(export)?[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\2/c,classes/
--regex-typescript=/^[ \t]*(export)?[ \t]*abstract class[ \t]+([a-zA-Z0-9_]+)/\2/a,abstract classes/
--regex-typescript=/^[ \t]*(export)?[ \t]*module[ \t]+([a-zA-Z0-9_]+)/\2/n,modules/
--regex-typescript=/^[ \t]*(export)?[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\2/t,types/
--regex-typescript=/^[ \t]*(export)?[ \t]*namespace[ \t]+([a-zA-Z0-9_]+)/\2/n,modules/
--regex-typescript=/^[ \t]*(export)?[ \t]*function[ \t]+([a-zA-Z0-9_]+)/\2/f,functions/
--regex-typescript=/^[ \t]*export[ \t]+var[ \t]+([a-zA-Z0-9_]+)/\1/v,variables/
--regex-typescript=/^[ \t]*var[ \t]+([a-zA-Z0-9_]+)[ \t]*=[ \t]*function[ \t]*\(\)/\1/l,varlambdas/