Skip to content

Instantly share code, notes, and snippets.

View jillesme's full-sized avatar
™️

Jilles Soeters jillesme

™️
View GitHub Profile
@jillesme
jillesme / .vimrc
Last active August 29, 2015 14:06
source ~/.vundle
" -- DEFAULTS --
" UTF-8 encoding
set encoding=utf-8
cd ~/Sites
" Set leader key to ,
let mapleader=","
" Don't close buffers, hide them
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'SirVer/ultisnips'
Plugin 'godlygeek/tabular'
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
@jillesme
jillesme / genius.js
Created September 14, 2014 21:47
If function demystified.
switch (condition) {
case true:
// Yes
break;
case false:
// No
break;
default:
// Maybe
}
@jillesme
jillesme / timeparser.js
Created October 14, 2014 21:39
Parses seconds to a nice displayed time :)
function parseTime (initialTime) {
var time = parseInt(initialTime);
var result = '';
if (time <= 59) {
result = time > 9 ? '00:' + time : '00:0' + time;
} else if (time > 59 && time <= 3599) {
var minutes = 0;
while (time > 59) {
time -= 60;
minutes += 1;
source ~/.vundle
" -- DEFAULTS --
" UTF-8 encoding
set encoding=utf-8
" Default dir is sites
cd ~/Appsbroker
def kebab_to_camel(string):
splitted = string.split('-')
result = [part.title() for part in splitted[1:]]
result.insert(0, splitted[0].lower())
return ''.join(result)
@jillesme
jillesme / egghead-total-duration.js
Last active February 19, 2016 19:52
Egghead total duration of a course..
(function (s) {
return [~~(s / 3600), ~~((s % 3600) / 60), s % 60].map(v => v < 10 ? '0' + v : v).join(':');
})([].slice.call(document.querySelectorAll('.duration'))
.filter((e, i, a) => ++i <= (a.length / 3))
.map(h => {
var t = h.textContent.match(/[0-9]{1,2}:[0-9]{1,2}/);
var p = t[0].split(':').map(Number);
return (p[0] * 60) + p[1]
}).reduce((p, c) => p + c, 0));
@jillesme
jillesme / app.js
Created November 11, 2016 06:36
Little refactor
function handlePossibleError(err) {
if (!err) return;
console.log('------- ERROR --------');
console.error(err);
console.log('----------------------');
}
function insertIntoDatabase(db, data) {
var tweets = db.collection('tweets');
var reg = /(https:\/\/.+)/g;
@jillesme
jillesme / .tmux.conf
Created October 16, 2015 09:50
Jilles' tmux configuration
# allow pbcopy | pbpase on OSX
set-option -g default-command "reattach-to-user-namespace -l zsh"
# set colours
set -g default-terminal "screen-256color"
# use ctrl+a rather than ctrl+b (capslock == ctrl)
unbind C-b
set-option -g prefix C-a
bind C-a send-prefix