Skip to content

Instantly share code, notes, and snippets.

View 19WAS85's full-sized avatar

Wagner Andrade 19WAS85

  • Porto Alegre, RS, Brazil
View GitHub Profile
@19WAS85
19WAS85 / array-test.js
Last active August 29, 2015 14:19
Proof of concept: abbreviating mocha tests with specify
var should = require('chai').should();
var specify = require('./specify').create(it);
// ------------------------
// ARRAY TEST TRADITIONAL
// ------------------------
describe('Array (traditional)', function(){
var array = [1, 2, 3];
require 'net/http'
require 'net/https'
@user = 'user@email.com'
@pass = 'password'
@google = Net::HTTP.new 'www.google.com', 443
@google.use_ssl = true
@google.verify_mode = OpenSSL::SSL::VERIFY_NONE
auth = @google.get("/accounts/ClientLogin?Email=#{@user}&Passwd=#{@pass}&service=orkut").body.split("\n")[2].gsub('Auth', 'auth')
require 'rubygems'
require 'sinatra'
get '/' do '<h1>Olá!</h1>' end
get '/usuarios' do '<h2>Usuários</h2><p>Aparecerá uma lista aqui.</p>' end
get '/usuarios/:nome' do "<p>Olá #{params[:nome]}!</p>" end
@19WAS85
19WAS85 / gist:13174
Created September 26, 2008 18:40
undefined
def benchmark(benchmark_name)
return unless block_given?
initial = Time.now
yield
final = Time.now.to_f - initial.to_f
puts "Benchmark #{benchmark_name}: [#{final}] seconds."
end
benchmark 'Sleep Test' do
sleep 0.318
public static object GetPropertyValue(this object obj, string propertyName)
{
try
{
return obj.GetType().GetProperty(propertyName).GetValue(obj, null);
}
catch
{
return null;
}
require 'hpricot'
require 'open-uri'
html = '<html><head><title>Agora no Globo.com</title>'
html += '<META http-equiv="Content-Type" content="text/html;charset=UTF-8"></head>'
html += '<body><h1>Agora</h1><h2>no Globo.com</h2>'
doc = Hpricot open('http://www.globo.com')
doc.search 'img' do |img|
// #1
$(document).ready(function() {
// #2
$('input[type=text]').each(function() {
// #3
var input = $(this)
var label = input.attr('title')
var foreColor = '#AAA'
#
# Wind Wordpress Importer
#
# To install this plugin do you need copy the file to Wind plugins directory.
# An admin widget will be crated to import WordPress eXtended RSS file.
#
# This plugin use hurricane gem [http://github.com/danieltamiosso/hurricane],
# [gem install hurricane] to install it.
#
@19WAS85
19WAS85 / Default.aspx
Created December 13, 2011 12:19
Javascript hack to fix invisible (Visible="false") AjaxControlToolkit TabPanels.
<asp:TabPanel runat="server" ID="secondTab" HeaderText="2nd" Visible="false">
@19WAS85
19WAS85 / AlteraRemoveArtigo.cs
Created December 22, 2011 17:18
Passo a passo básico do Entity Framework Code First.
// Alterar.
using (var dataContext = new DatabaseContext())
{
var artigo = dataContext.Artigos.Find(1);
artigo.Title = "EF";
dataContext.SaveChanges();
}
// Remover.
using (var dataContext = new DatabaseContext())