Skip to content

Instantly share code, notes, and snippets.

View ericelliott's full-sized avatar
💭
https://leanpub.com/composingsoftware

Eric Elliott ericelliott

💭
https://leanpub.com/composingsoftware
View GitHub Profile
/**
* Module Pattern Assignment Example
* @author Eric Hamilton
*/
// Assign the return result of an anonymous self executing function to a public variable
var encapsulatedNamespace = (function () {
var privateVar = "Secret stuff",
privateFunction = function () {
var result;
// do something with privateVar
/* Object.create() vs new Speed Test
* @author Eric Hamilton
*
* Result: For a few thousand objects, it
* doesn't matter which way you go.
* For hundreds of thousands of objects,
* you might want to use new instead of
* Object.create().
*
* Tested on node v0.2.0
var myModule = (function () {
var myModule = {
"prop1" : "some value",
"prop2" : "some other value"
};
myModule.someMethod = function () {
// Do stuff with props.
};
/* Works in browsers or in CommonJS environment.
* If you don't have either, just create an exports global before
* this loads and call it a day.
*/
(function (root) {
var myModule = {
"prop1" : "some value",
"prop2" : "some other value"
};
node> "\\\\"
'\\\'
node> "1\/2\\3\\4\\5\\6\\"
'1/2\\3\\4\\5\\6\'
node> "1\/2\\3\\4\\5\\6"
'1/2\\3\\4\\5\\6'
:~/tmp# cat testme.js
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.h5validate.js"></script>
<script>
$(document).ready(function () {
$('form').h5Validate();
});
</script>
<input id="name" name="name" type="text" placeholder="Bob" title="Your name is required." required />
<input id="name" name="name" type="text" placeholder="mm/dd/yyyy" title="mm/dd/yyyy" pattern="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" />
<head>
<style>
.black {
background-color:#111111;
color:silver;
}
</style>
</head>
<body>
<form id="black">
We couldn’t find that file to show.