Skip to content

Instantly share code, notes, and snippets.

@58bits
58bits / truncate.js
Created June 3, 2015 17:48
Truncate String Helper for Handlebars and Node.js
'use strict';
var Handlebars = require('handlebars');
module.exports = function truncate(str, len, words) {
var safe = Handlebars.Utils.escapeExpression(str);
var tooLong = safe.length > len;
var s_ = tooLong ? safe.substr(0, len) : safe;
if (words && tooLong) {
var index = s_.lastIndexOf(' ');
if (index !== -1) {
s_ = s_.substr(0, index);
@58bits
58bits / api plugin index.js
Created August 21, 2014 17:02
hapi plugin logging strategy
'use strict';
var _ = require('lodash');
var Routes = require('./routes');
var logger = {
maxLogSize: 1024 * 1024, //1MB
subscribers: {
'console': ['ops', 'log', 'request', 'error'],
'api/storage/v1/logs/api-access': ['request'],
'api/storage/v1/logs/api-log': { tags: ['api'], events: ['log'] }
local Time12a="\$(date +%H:%M)"
local PathShort=":\w"
local Username="\u"
local Separator="@"
local Hostname="\H"
# These are the color definitions used by gitprompt.sh
GIT_PROMPT_PREFIX="[" # start of the git info string
GIT_PROMPT_SUFFIX="]" # the end of the git info string
GIT_PROMPT_SEPARATOR="|" # separates each item
@58bits
58bits / SassMeister-input-HTML.html
Created June 13, 2014 02:42
Generated by SassMeister.com.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Front-end Demo Project</title>
<link rel="stylesheet" href="stylesheets/application.css">
<script type="text/javascript" src="scripts/app.js"></script>
</head>
@58bits
58bits / app.scss
Created June 12, 2014 22:23
Singullarity Layout
// Import
@import "main";
// Singularity 1.2 Syntax
@include sgs-change('debug', true);
@include sgs-change('mobile first', true);
@include sgs-change('output', 'isolation');
@include sgs-change('include clearfix', true);
@58bits
58bits / gist:5d451dbd045e084e7a27
Created June 12, 2014 12:38
Four Column Footer
footer {
background: yellow;
section {background: pink; padding: 4px;}
@include grid-span(2, 1);
@include layout($gutter: .1) {
.section1 { @include float-span(1, 1);}
.section2 { @include float-span(1, 2);}
.section3 { @include float-span(1, 1);}
.section4 { @include float-span(1, 2);}
}
@58bits
58bits / Mulvana.scpt
Created July 2, 2012 22:21
Start Session
set session to load script (POSIX file "/Users/tony/Library/Application Support/iTerm/Scripts/Session.scpt")
set session's server to "middleman"
set session's server_url to "http://0.0.0.0:4567/"
set session's server_path to "/Users/tony/Clients/Mulvana/Solutions/Middleman/mulvana"
set session's build_path to "/Users/tony/Clients/Mulvana/Solutions/Middleman/mulvana"
set session's source_path to "/Users/tony/Clients/Mulvana/Solutions/Middleman/mulvana/source"
set session's editor to "/usr/local/bin/mvim"
session's start_session()
@58bits
58bits / Session.scpt
Created July 2, 2012 22:19
Session Script
property server : missing value
property server_url : missing value
property server_path : missing value
property build_path : missing value
property source_path : missing value
property editor : missing value
on start_session()
tell application "iTerm"
class Fun
@@a = 1
@b = 1
class << self
attr_accessor :hides
end
class Document
@@default_font = :times
end
class Presentation < Document
@@default_font = :nimbus
end
class Resume < Document
@@default_font = :arial