Skip to content

Instantly share code, notes, and snippets.

View Olical's full-sized avatar
🧙‍♂️
(magic)

Oliver Caldwell Olical

🧙‍♂️
(magic)
View GitHub Profile
#!/usr/bin/env bash
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
cat >>~/.vimrc <<EOL
set nocompatible
call plug#begin()
Plug 'tpope/vim-sensible'
function SomeThing {
var sortOfPrivateThroughClosure = true;
this.someVal = {};
this.doThing = function () {
// ...
};
// Then sometimes the values are ES5 getter/setter methods with side effects.
// The only way to tell is to read the source of the object you're dealing with though.
@Olical
Olical / expand.vim
Created December 10, 2014 10:08
Expand lines like bash in Vim https://asciinema.org/a/14558
" Run expand on your current line or range of lines.
" Allows you to repeat {lines,blocks} like this {1..3} times.
" Allows you to repeat lines like this 1 times.
" Allows you to repeat lines like this 2 times.
" Allows you to repeat lines like this 3 times.
" Allows you to repeat blocks like this 1 times.
" Allows you to repeat blocks like this 2 times.
" Allows you to repeat blocks like this 3 times.
@Olical
Olical / compile.js
Last active August 29, 2015 14:10
Compiles an array tree structure into React DOM. Skip JSX, but without being SUPER verbose (will turn into an actual library soon)
var React = require('react');
var _ = require('lodash');
/**
* Compiles an array into a React DOM structure recursively. All segments of the node array are optional.
*
* The array segments can be in any order apart from the node type, that always needs to be first.
*
* Actually works really well, I'd quite like to open source this with CSS selector parsing in the nodeName.
*
@Olical
Olical / factory.js
Created November 21, 2014 00:03
Screeps hervester swarm - http://screeps.com
var _ = require('lodash');
function countType(type) {
return _.size(_.filter(Game.creeps, function (creep, creepName) {
return creepName.split('_')[0] === type;
}));
}
function build(spawn, type, attrNames) {
var attrs = attrNames.map(function (name) {
@Olical
Olical / e.js
Last active August 29, 2015 13:58
Absolutely tiny emitter.
function e(m,i,t){return m.map(function(l){return l(i,m)})}
@Olical
Olical / EventEmitter.js
Created March 8, 2014 19:00
EventEmitter v4.2.7 snapshot
/*!
* EventEmitter v4.2.7 - git.io/ee
* Oliver Caldwell
* MIT license
* @preserve
*/
(function () {
'use strict';
{
"storage": {
"packages": ".bower/cache",
"registry": ".bower/registry"
},
"tmp": ".bower/tmp"
}
@Olical
Olical / add-a-language.md
Created January 19, 2014 14:31
How to add a language to the trillek UI

First copy an existing language file, such as en.js from src/assets/js/trillek/i18n/. Rename and translate as you see fit.

Then open up src/assets/js/trillek/i18n/main.js and copy an existing config line, for example: .translations('en', require('./en')). Change the language code to point at your new file.

Now open up src/assets/js/trillek/config/default.js and add your new language code and translated label to the availableLanguages object. The full name should be written in the actual language it is for, so when it shows up in the selection list the user can actually find their language.