Skip to content

Instantly share code, notes, and snippets.

View orlando's full-sized avatar
🦅

Orlando Del Aguila orlando

🦅
View GitHub Profile
@orlando
orlando / htmlValidator.js
Last active December 21, 2015 04:39
poor's man javascript html validator
// Poor's man html Validator.
// https://gist.github.com/orlando/6251395
function validateHtml (htmlString) {
var htmlString, divElm, docFrag, docFragHtml;
htmlString = htmlString.replace(/ +/g, " ").toLowerCase();
htmlString = htmlString.replace(/\s*\/\s*>/g, ">");
divElm = document.createElement('div');
docFrag = document.createDocumentFragment();
docFrag.appendChild(divElm);
docFrag.querySelector('div').innerHTML = htmlString;
var teamboxChatSound = function teamboxChatSound () {
var ping, chatBody, observer, base64string, hidden, visibilityChange;
base64String = "data:audio/wav;base64,UklGRoAaAABXQVZFZm10IBAAAAABAAEAESsAABErAAABAAgAZGF0YVwaAAB9fICEg355en2ChYF8e35/fX59foKDfHd6gIODgHp4fX99fYCAgIF/f4F9dHSAkpiFZlNjj7OlcEpYjrKWXlODt6xmMkqa1rZeKk2l2adNMG7FzXkvQJjbul8mT7LcoUYmbs3NfDE7mdquTyVfwduSNyl/1cdsKEuw2pM2LYXdyWQeP6jmrEEhb9TRZhtEruyuOxlmzeKCIzOW4bpKHV7C444pKobdyl0bSq7koDYrftLIYR9LrOGkOiNvy9Z7JDmc3KlBInHR03EaOKXkrj8ZbNHUdx80oeS2TRVaxtqKLTCV2rRWIFzD2I0xK4vcxWUfTLbcmzophdnGayRIr92kRihvys5/NkGZ0KhXMWa6yYY+PYnKs208V6O/lVhEdK6xhVdVgqSXdFtqj52Ka1xzkpuKbV90jJWKbmV3i5WEamd8lp1/X196nqJ8XWSHqJdpVWuZsI5bTHKpsYBRVoq0nGJJaae7iExGfry3cT9TmMWcUj1stcSBQUOEyLVkN1amzZRJO3TAv3Q6RZTSqFY0X7XMhEFBhMq0ZzpTo8uVTz1yvb91OkmVzapWMV+wyotBPH/Gu2YyUp/PnUU2cr3IeDNFkNKyUSxfs9SJNTqAyb1gL1elz5ZBOXW4vnI8VpG+n1NHd6i0d0JckbOaWFCAoqRwRWudrJFUToWoo3dMapyljF5VhKWffFdmkaGTbl1+mpeAZ3GRmYhzbIOXj4BxdYuPgXh4iZOBc3SClY13cHaIlIR1c4CUkHdqc46ch2tkepibgWZjgZyWeGBuj5yLaV9+m5
require 'active_record'
require 'database_cleaner'
connection_info = YAML.load_file("config/database.yml")["test"]
ActiveRecord::Base.establish_connection(connection_info)
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
var message = new MailMessage();
message.To.Add("user@example.com");
message.To.Add("user2@example.com");
message.From = new MailAddress("test@example.com");
message.Subject = "Test";
message.Body = "Test";
var client = new SmtpClient("localhost", 25);
auth = function(params) {
}
module.exports = auth
@orlando
orlando / activeadmin-cancan.rb
Created November 25, 2012 01:54
Deep integration of CanCan into ActiveAdmin
# blog post:
# Before using this initializer, you must set up Cancan. First, add the gem to your Gemfile:
#
# gem 'cancan'
#
# Next, generate and edit an Ability class:
#
# rails generate cancan:ability
#
@orlando
orlando / gist:1989583
Created March 6, 2012 22:55
active admin handle many assets
f.inputs "Product images" do
f.has_many :assets do |p|
p.input :asset, :as => :file, :label => "Image",:hint => p.object.asset.nil? ? p.template.content_tag(:span, "No Image Yet") : p.template.image_tag(p.object.asset.url(:thumb))
p.input :_destroy, :as=>:boolean, :required => false, :label => 'Remove image'
end
end
f.inputs "Product details" do
f.input :category, :label => "Category", :hint => "Select one category"
f.input :height
@orlando
orlando / gist:1558317
Created January 4, 2012 03:19
cheap oauth implementation
module Session
def self.generate_timestamp
Time.now.strftime("%s")
end
def self.generate_nonce
rand(36**16).to_s(36)
end
@orlando
orlando / cheap_downloader.rb
Created January 3, 2012 16:39
destroyallsoftware cheap screencast downloader
#!/usr/bin/ruby
require 'rss'
#this assumes you have a cookies.txt with destroyallsoftware.com cookies... later ill add a signin method..
class Link
attr_accessor :link,:title,:date
def initialize(link,title,date)
@link = link
@orlando
orlando / google_map.rb
Created December 25, 2011 02:52
google map
# File forked from github.com/kete/kete.. not my work
# what this does:
# * prepares google map accordingly for request type
# (form for baskets_controller#choose_type with empty map, display for index_page_controller#index,
# all other controllers#show, new, etc.)
# * adds view helpers for loading api js lib and initializing google map js and escaping js (i18n_js(key))
# * adds helpers for ExtendedFieldsHelper editor (including geocoding address form) and display
# * validates extended field ftype for map or map with address
module GoogleMap