Skip to content

Instantly share code, notes, and snippets.

@lwakefield
lwakefield / init.vim
Created December 11, 2019 12:36
init.vim
call plug#begin('~/.vim/plugged')
" auto complete
Plug 'neoclide/coc.nvim', {'branch': 'release'} # auto-complete
" fuzzy file opener
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" horizontal alignment
Plug 'junegunn/vim-easy-align'
" syntax highlighting for everything
Plug 'sheerun/vim-polyglot'
%AnonEnv1 = type {
i32,
i32
}
%AnonFn1 = type {
i32*,
i32*
}
class Node
end
class FooNode < Node
end
class BarNode < Node
end
class Parser
@lwakefield
lwakefield / init.vim
Last active August 27, 2018 18:05
init.vim
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-sleuth'
Plug 'ludovicchabant/vim-gutentags'
@lwakefield
lwakefield / tabcomplete.vim
Last active January 23, 2018 21:12
tabcomplete
inoremap <expr> <tab> pumvisible() ? '<c-n>' : '<tab>'
inoremap <expr> <s-tab> pumvisible() ? '<c-p>' : '<tab>'
augroup autocomplete
autocmd!
autocmd TextChangedI * call TypeComplete()
augroup end
fun! TypeComplete()
if getline('.')[col('.') - 2] =~ '\K' && getline('.')[col('.') - 1] !~ '\K'
call feedkeys("\<c-n>")
end
@lwakefield
lwakefield / deepget.js
Created September 14, 2016 20:33
deepget.js
function get (obj, key, fallback=undefined) {
const keyPath = key.split('.')
try {
return keyPath.reduce((obj, key) => {
if (!(key in obj)) throw new TypeError()
return obj[key]
}, obj)
} catch (e) {
return fallback
}
<input type="file">
<script>
var el = document.querySelector('input[type="file"]');
el.addEventListener('change', function(event) {
let files = e.target.files;
for (let i = 0; i < files.length; i++) {
let file = files[i];
var xhr = new XMLHttpRequest();
// set the url to wherever you meteor app is running
<input type="file">
<script>
var el = document.querySelector('input[type="file"]');
el.addEventListener('change', function(event) {
let files = e.target.files;
for (let i = 0; i < files.length; i++) {
let file = files[i];
var xhr = new XMLHttpRequest();
import { Meteor } from 'meteor/meteor';
WebApp.connectHandlers.use('/file', (req, res) => {
res.setHeader("Access-Control-Allow-Methods", "PUT");
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
if (req.method === 'OPTIONS') {
res.writeHead(200);
res.end();
import { Meteor } from 'meteor/meteor';
WebApp.connectHandlers.use('/file', (req, res) => {
// We only care about PUT methods
res.setHeader("Access-Control-Allow-Methods", "PUT");
// I am running meteor as a backend, see https://iamlawrence.me/agnostic-meteor
// Therefore we need to enable CORS
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "Content-Type");