Skip to content

Instantly share code, notes, and snippets.

import * as hashIt from 'hash-it';
import * as hashSum from 'hash-sum';
import {forEach, times} from 'lodash';
import * as objectHash from 'object-hash';
import {CompiledJsonSchemas} from 'salsa/schemas';
import {performance} from 'salsa/utils/performance';
describe('hash', () => {
export function scrollToCenter(target: HTMLElement, container: HTMLElement): void {
// Vertically center element in container
container.scrollTop = verticalOffset(target, container) - (container.offsetHeight - target.offsetHeight) / 2;
}
function verticalOffset(target: HTMLElement, container: HTMLElement): number {
const commonAncestor = commonContainer(target, container);
const parent: HTMLElement = target.offsetParent as any;
if(parent === commonAncestor) {
return target.offsetTop;
@KurtPreston
KurtPreston / index.js
Created August 14, 2017 20:17
requirebin sketch
const zenscroll = require('zenscroll');
const top = document.getElementsByClassName('top')[0];
const scroller = zenscroll.createScroller(top, 200);
window.jumpToA = () => {
const divA = document.getElementsByClassName('a')[0];
scroller.center(divA);
};
@KurtPreston
KurtPreston / tslint_syntastic_type_check.vim
Last active April 18, 2017 14:42
VIM configuration for adding syntastic type checking rules to tslint
function SetTslintOptions()
if exists(':TsuStartServer')
" If tsuquyomi is installed, ask for the config file name
let tsconfig = tsuquyomi#tsClient#tsProjectInfo(@%, 0)['configFileName']
" TODO: pull the version number out of syntastic.
let tslint_version = system('tslint --version')[0]
if tslint_version >= 5
" tslint v5 requires tsconfig file specified for some rules
CC = /usr/bin/clang
LD = ld
LDSHARED = /usr/bin/clang -dynamiclib
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe
XCFLAGS = -include ruby/config.h -include ruby/missing.h -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -I. -I.ext/include/x86_64-darwin11.4.2 -I./include -I.
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -install_name /Users/kurt/.rvm/rubies/ruby-2.0.0
[master] kurt@~: rvm install 2.0.0 --debug
ruby-2.0.0-p451 - install
ruby-2.0.0-p451 - #already removed src
ruby-2.0.0-p451 - #already removed rubies
Searching for binary rubies, this might take some time.
Remote file does not exist https://rvm.io/binaries/osx/10.7/i386/ruby-2.0.0-p451.tar.bz2
Remote file does not exist http://jruby.org.s3.amazonaws.com/downloads/ruby-2.0.0-p451.tar.bz2
Remote file does not exist http://binaries.rubini.us/osx/10.7/i386/ruby-2.0.0-p451.tar.bz2
rvm_remote_server_url3 not found
No remote file name found
#!/usr/bin/env ruby
## WP2TUMBLR: WordPress 2 Tumblr Importing tool
##
## Usage: wp2tumblr [OPTION] WORDPRESS_XML_FILE
##
## Import the WORDPRESS_XML_FILE to a Tumblr blog.
## Provide `--group` option to publish to a group.
## This could take a long time...
##
## To install, download the script and chmod to 755.