Skip to content

Instantly share code, notes, and snippets.

View dayvsonlima's full-sized avatar

Dayvson Lima dayvsonlima

View GitHub Profile
@dayvsonlima
dayvsonlima / number_to_currency.js
Created December 6, 2013 13:29
number_to_currency em javascript
Helper = {
config: {
locale: "pt-BR"
},
init: function(){
},
pt-BR:
simple_form:
"yes": 'Sim'
"no": 'Não'
required:
text: 'obrigatório'
mark: '*'
# You can uncomment the line below if you need to overwrite the whole required html.
# When using html, text and mark won't be used.
# html: '<abbr title="required">*</abbr>'
@dayvsonlima
dayvsonlima / replace_all.js
Created January 26, 2014 23:19
replace_all
function replaceAll(find, replace, str) {
return str.replace(new RegExp(find, 'g'), replace);
}
var HashHack = {
PREFIX: '#hhMessage=',
postMessage: function(el, sMessage) {
if ('string' === typeof el) {
el = document.getElementById(el);
}
var sUrl = el.src.replace(/#.*/, '');
el.src = sUrl + HashHack.PREFIX + encodeURIComponent(sMessage);
var HashHack = {
PREFIX: '#hhMessage=',
aCallbacks: [],
sLastHash: '',
handleInterval: function() {
var sHash = window.location.hash,
sDecodedHash, sMessage, i;
if (sHash !== HashHack.sLastHash) {
@dayvsonlima
dayvsonlima / diretivas recursivas em angular - nested directives
Last active August 29, 2015 14:17
diretivas recursivas em angular - nested directives
var myModule = angular.module('myModule', []);
myModule.directive('foo', function(RecursionHelper){
return {
restrict: "EAC",
replace: true,
template: '<strong>ok<div bar></div></strong>',
compile: function(element) {
// Use the compile function from the RecursionHelper,
// And return the linking function(s) which it returns
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function NORMDIST(x, mean, sd, cumulative) {
// Check parameters
if (isNaN(x) || isNaN(mean) || isNaN(sd)) return '#VALUE!';
if (sd <= 0) return '#NUM!';
// Return normal distribution computed by jStat [http://jstat.org]
return (cumulative) ? jStat.normal.cdf(x, mean, sd) : jStat.normal.pdf(x, mean, sd);
}
@dayvsonlima
dayvsonlima / bootstrap rails scaffold bootstrap project
Last active August 29, 2015 14:17
bootstrap rails scaffold bootstrap project
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
@dayvsonlima
dayvsonlima / xml to json
Created March 24, 2015 12:00
Convert xml to json format
// Changes XML to JSON
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) { // element
// do attributes
if (xml.attributes.length > 0) {
obj["@attributes"] = {};