Skip to content

Instantly share code, notes, and snippets.

View atelic's full-sized avatar

Eric Barbour atelic

View GitHub Profile
require 'sinatra'
require "sinatra/namespace"
require 'mongoid'
# DB Setup
Mongoid.load! "mongoid.config"
# Models
class Book
include Mongoid::Document
diff --git a/.gitignore b/.gitignore
index a9e5112..fcc5a99 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,7 +54,6 @@ website/static/vendor/bower_components/
node_modules
# Allow robots.txt to be deployment-specific
website/static/robots.local.txt
-/website/static/git_logs.txt
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
@atelic
atelic / .zshrc
Last active April 13, 2016 15:41
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
@atelic
atelic / asdf
Created February 10, 2016 15:11
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
import re
import unicodedata
def slugify(value):
"""
Convert spaces to hyphens., remove characters that aren't alphanumerics, underscores, or hyphens.
Convert to lowercase. Also strip leading and trailing whitespace.
From Django's filter: https://github.com/django/django/blob/60586dd7379b295b72d8af4e03423c286913b5e8/django/utils/text.py#L415
"""
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub('[^\w\s-]', '', value).strip().lower()
var koBootboxTemplate = function(title, template, viewModel, buttons) {
bootbox.dialog({
title: title,
message: function() {
ko.renderTemplate(template, viewModel, {}, this, 'replaceNode');
},
buttons: buttons
});
};
// Bind Bootstrap Progress
ko.bindingHandlers.progress = {
init: function (element, valueAccessor) {
var $element = $(element);
var bar = $('<div/>', {
'class': 'progress-bar',
'role': 'progressbar',
'aria-valuemin': 0,
'aria-valuemax': 100,
@atelic
atelic / mocha.el
Last active October 23, 2015 17:16
Get mocha test keywords to show in Emacs imenu
(defun js2-imenu-make-index ()
(save-excursion
(imenu--generic-function '(("describe" "\\s-*describe\\s-*([\"']\\(.+\\)[\"']\\s-*,.*" 1)
("it" "\\s-*it\\s-*([\"']\\(.+\\)[\"']\\s-*,.*" 1)
("before" "\\s-*before\\s-*([\"']\\(.+\\)[\"']\\s-*,.*" 1)
("after" "\\s-*after\\s-*([\"']\\(.+\\)[\"']\\s-*,.*" 1)
;;add more keyword for mocha here
("Function" "function[ \t]+\\([a-zA-Z0-9_$.]+\\)[ \t]*(" 1)
("Function" "^[ \t]*\\([a-zA-Z0-9_$.]+\\)[ \t]*=[ \t]*function[ \t]*(" 1)))))