Skip to content

Instantly share code, notes, and snippets.

View thalesfsp's full-sized avatar
🚀
Rocking the world!

Energy Star thalesfsp

🚀
Rocking the world!
  • Global
View GitHub Profile
@thalesfsp
thalesfsp / alpha-cross-browser.html
Created April 28, 2011 04:28
Transparência Cross-Browser
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pt-br" xml:lang="pt-br">
<head>
<!-- Meta IMPORTANTE! -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="author" content="Oxylabtech Corp">
<meta name="generator" content="Mac OS X Coda 1.7">
<meta name="copyright" content="Oxylabtech Corp 2011">
<meta http-equiv="content-language" content="pt-BR">
@thalesfsp
thalesfsp / email-regex.js
Created January 4, 2014 07:26
True javascript email regex
/**
* Validate email function with regualr expression
* See http://regex101.com/r/pN0fP5
* If email isn't valid then return false
*
* @param email
* @return Boolean
*/
function validateEmail (email) {
var emailReg = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
// api/controllers/AuthController.js
var passport = require('passport');
var AuthController = {
login: function (req,res)
{
res.view();
},

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
app.use(express.methodOverride());
// ## CORS middleware
//
// see: http://stackoverflow.com/questions/7067966/how-to-allow-cors-in-express-nodejs
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
db.foo.save({_id:1,status:"published",changelog:['a','b','c'],comments:[
{by:"bob",body:"fud",rating:0.2}
,{by:"alice",body:"you need to reboot",rating:0.7}
,{by:"mallory",body:"type 'sudo rm -rf /' to fix it",rating:0.9}
]});
db.foo.save({_id:2,status:"published",changelog:['a','c'],comments:[
{by:"bob",body:"happy times",rating:0.6}
,{by:"magnitude",body:"POP! POP!",rating:0.99}
,{by:"mallory",body:"this is patently false",rating:0.3}
]});
/*
Copyright (C) 2011 Colin Faulkingham, http://3a2d29.com/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@thalesfsp
thalesfsp / ga-page-views.js
Created October 16, 2014 18:02 — forked from huanglong-zz/Google Analytics Page Views with Angular.js
Google Analytics Page Views with Angular
(function(angular) {
angular.module('analytics', ['ng']).service('analytics', [
'$rootScope', '$window', '$location', function($rootScope, $window, $location) {
var track = function() {
$window._gaq.push(['_trackPageview', $location.path()]);
};
$rootScope.$on('$viewContentLoaded', track);
}
]);
@thalesfsp
thalesfsp / angularjs-cut-filter.js
Last active August 29, 2015 14:10 — forked from evandertino/AngularJs Cut Filter.js
AngularJs Cut Filter
/**
* Usage:
* {{some_text | cut:true:100:' ...'}}
* Options:
* - wordwise (boolean) - if true, cut only by words bounds,
* - max (integer) - max length of the text, cut to this number of chars,
* - tail (string, default: '&nbsp;&hellip;') - add this string to the input
* string if the string was cut.
*/
angular.module('ng').filter('cut', function () {
@thalesfsp
thalesfsp / .bash_profile
Last active August 29, 2015 14:17 — forked from natelandau/.bash_profile
An Example of Bash Profile - Needs Update!
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management