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.
@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:

/**
@sh0bh1t
sh0bh1t / javascript-coding-style.md
Created August 11, 2016 07:48
JavaScript coding style

tl;dr

Your JS code should look like this:

/**
 * Recursive function to compute Fibonacci numbers
 *
 * @param {number} n
 * @return {number}
 */
@sh0bh1t
sh0bh1t / JS-error-tracking-with-GA.js
Last active September 10, 2015 12:31
Track JavaScript errors using Universal Analytics from Google.
/**
* Track JS error details in Universal Analytics
*/
function trackJavaScriptError(e) {
var errMsg = e.message;
var errSrc = e.filename + ': ' + e.lineno;
ga('send', 'event', 'JavaScript Error', errMsg, errSrc, { 'nonInteraction': 1 });
}
@sh0bh1t
sh0bh1t / error.js
Last active September 10, 2015 12:31 — forked from nbubna/error.js
A convenient global error handler
(function(scope, console, CustomEvent) {
var error = scope.error = function() {
var output = []
for (var i=0; i<arguments.length; i++) {
var arg = arguments[i];
if (typeof arg === "object" && arg.length) {
output.push.apply(output, Array.prototype.slice.call(arg));
} else {
output.push(arg);
@sh0bh1t
sh0bh1t / gist:102c8db089602cf9b023
Last active September 10, 2015 12:31
Javascript error handling without window.onerror
(function () {
var origCall = Function.prototype.call, myCaller;
var arraySlice = Array.prototype.slice;
var errRegex = /at(.*?)\((.*?):([0-9]{1,}):([0-9]{1,})\)/i;
var errReg = {
ff: /(.*?)\@(.*?)\:[0-9]{1,}/i
};
// IE 11 useragent: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; rv:11.0) like Gecko
if( !navigator.userAgent.match(/Trident/) && navigator.userAgent.match(/FireFox/) ){