Skip to content

Instantly share code, notes, and snippets.

@sh0bh1t
sh0bh1t / highlight.js
Created August 30, 2016 07:22 — forked from jonraasch/highlight.js
Live on-page text highlighting
/*
highlight v3 !! Modified by Jon Raasch (http://jonraasch.com) to fix IE6 bug !!
Highlights arbitrary terms.
<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
MIT license.
/**
*
* @file tileTemplate.js
* @auther Pandao
* @version 1.5.0
* @license MIT
* @copyright 2014 Pandao
* {@link https://github.com/pandao/tileTemplate}
*/
/**
* @apiDefineStructure ${NAME}Params
* @apiParam {String} slug ${MODEL} identifier
*/
/**
* @apiDefineStructure ${NAME}Success
* @apiSuccess {String} slug ${MODEL} identifier
* @apiSuccess {Date} createdAt Date of document creation.
* @apiSuccess {Date} updatedAt Date of document last change.
*/
var util = {
getAttribute: function (dom, attr) {
if (dom.getAttribute !== undefined) {
return dom.getAttribute(attr);
} else if (dom[attr] !== undefined) {
return dom[attr];
} else {
return null;
}
},
// Trigger the initial route and enable HTML5 History API support, set the
// root folder to '/' by default. Change in app.js.
Backbone.history.start({ pushState: true, root: app.root });
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
// attribute, bypass the delegation completely.
$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
// Get the absolute anchor href.
var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
@sh0bh1t
sh0bh1t / node-folder-structure-options.md
Created August 23, 2016 20:49 — forked from lancejpollard/node-folder-structure-options.md
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin
@sh0bh1t
sh0bh1t / Base64 JS Demo
Created August 19, 2016 10:34 — forked from chrisallick/Base64 JS Demo
Base64 in JavaScript turn a json object to a base64 string. boom!
<!DOCTYPE html>
<html>
<head>
<title>Base64 Demo</title>
<meta charset="utf-8">
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' type='text/javascript'></script>
<script src='https://javascriptbase64.googlecode.com/files/base64.js' type='text/javascript'></script>
@sh0bh1t
sh0bh1t / better-nodejs-require-paths.md
Created August 17, 2016 10:54 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@sh0bh1t
sh0bh1t / jay-inheritance.js
Created August 13, 2016 20:08 — forked from parasyte/jay-inheritance.js
Jay inheritance : A *really fast* implementation of JavaScript single inheritance with mixins and a little syntactic sugar to make it go down smoothly. http://blog.kodewerx.org/2014/03/melonjs-should-be-all-about-speed.html
/*
* Copyright (c) 2014, Jay Oster
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,

Some docs I made for contributing documentation:

Using JS Doc

Any comments written with a comment block /** comment block **/ will get picked up by jsdoc. If you have comments you would like to make that don't show up in the documentation, use // comment.

Namespace docs are created by putting /** @namespace */ before the variable. Each key can be documented with a comment block that is broken down like this:

/**