Skip to content

Instantly share code, notes, and snippets.

@skeep
skeep / validator.js
Last active December 10, 2015 12:18
var validator = (function () {
function trim(str) {
return str.replace(/^\s+|\s+$/g, '');
}
function isEmail(field) {
if (field) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(field)) {
return false;
var cat = function(obj){
//this is where I copy all the attributes of the passed object to the constructure
for (attr in obj){
this[attr] = obj[attr];
}
//publice method
this.talk = function(){
console.log('meeow!!!');
};
};
var cardJSON = {
text:'this is text',
color:'red'
};
var Card = function(obj){
var that = this;
var props = Object.getOwnPropertyNames(obj);
props.forEach(function(prop){
var propDescriptor = Object.getOwnPropertyDescriptor(obj, prop);
@skeep
skeep / gist:4762019
Last active December 12, 2015 10:49
var cardJSON1 = {
text:'this is text',
color:'red',
position:{
x:200,
y:200
}
};
var cardJSON2 = {
var fs = require('fs');
fs.createReadStream('test.log').pipe(fs.createWriteStream('newLog.log'));
@skeep
skeep / A-Pen-by-Suman-Paul.markdown
Created September 19, 2013 20:31
A Pen by Suman Paul.
@skeep
skeep / .jsbeautifyrc
Created January 9, 2014 10:02
je beautify config
{
"indent_size": 2,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": true,
"brace_style": "collapse",
"keep_array_indentation": false,
@skeep
skeep / .jshintrc
Created January 9, 2014 10:02
JS Hint config
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": false,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
//Object Properties
Object.length; //returns 1
Object.prototype; //returns {}
var user = {
firstName: 'Suman',
lastName: 'Paul',
age: 30
};
Object.keys(user);
//returns ["firstName", "lastName", "age"]