Skip to content

Instantly share code, notes, and snippets.

View dayvsonlima's full-sized avatar

Dayvson Lima dayvsonlima

View GitHub Profile
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"] = {};
# -*- coding: utf-8 -*-
require 'rubygems'
require 'RMagick'
filename = ARGV.first
unless filename
warn "usage: #{$0} <ANIMATION GIF FILE>"
exit 1
end
@dayvsonlima
dayvsonlima / render_view_in_model.rb
Created June 19, 2015 05:23
Renderiza uma view do rails dentro de qualquer model
ApplicationController.new.render_to_string(
:template => "v1/timers/index",
:layout => false,
:locals => { :@timers => Timer.all }
)
function rvm_install(){
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable --ruby
echo "source /home/$USER/.rvm/scripts/rvm" >> ~/.bash_profile
echo "source /home/$USER/.rvm/scripts/rvm" >> ~/.zshrc
}