Skip to content

Instantly share code, notes, and snippets.

View rodrei's full-sized avatar

Rodrigo Pavano rodrei

  • Mendoza, Argentina
View GitHub Profile
@rodrei
rodrei / rubyntlm_with_net_http.rb
Created June 14, 2012 20:11
Example: NTLM Authentication with NetHTTP
uri = URI('https://host.com/ews/exchange.asmx')
user = ''
passwd = ''
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
request = Net::HTTP::Get.new(uri.request_uri)
t1 = Net::NTLM::Message::Type1.new()
request['Authorization'] = 'NTLM ' + t1.encode64
response = http.request(request)

System

OSX El Capitan 10.11.2

Using Homebrew LLVM v3.5.1 (formula homebrew/versions/llvm35)

tail configure.log

[2015-12-27 17:41:30] Checking for header 'openssl/ssl.h':
@rodrei
rodrei / active_record_example.rb
Created April 10, 2013 13:43
ActiveRecord example
require "rubygems"
require "active_record"
#Change this to reflect your database settings
ActiveRecord::Base.establish_connection (
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password => "password",
:database => "some_database")
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%n:%~$(git_prompt_info)%{$fg_bold[green]%}%# %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@rodrei
rodrei / subscriptions.rb
Created November 8, 2012 20:34
Subscriptions auditory
begin
free = []
non_free = []
subs_nil = []
User.all.each do |u|
if u.subscription.nil?
subs_nil << u
elsif u.subscription.plan.name == "free"
free << u
@rodrei
rodrei / github_export.rb
Created November 5, 2012 16:09
Github Issues export to Assembla CSV
require 'github_api'
components = %w{ tag1 tag2 tag3 tag4 }
users = {
'github-username' => 'new-system-username'
}
assembla_issues = []
client = Github.new login: 'user', password: 'password'
@rodrei
rodrei / gist:3706509
Created September 12, 2012 13:12
Migration
Call.where(:state.in => [:to_bill, :free]).all.each do |c|
c.billing_state = c.state
c.state = :scheduled
c.save!
end
Call.where(:billing_state => nil).each do |c|
c.update_attributes!(:billing_state => "unprocessed")
end
uri = URI('https://host.com/ews/exchange.asmx')
user = ''
passwd = ''
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
request = Net::HTTP::Get.new(uri.request_uri)
t1 = Net::NTLM::Message::Type1.new()
request['Authorization'] = 'NTLM ' + t1.encode64
response = http.request(request)
@rodrei
rodrei / exchange_usage.rb
Created May 24, 2012 20:56
Exchange basic usage
credentials = Autodiscover::Credentials.new('<e-mail address>', '<password>')
client = Autodiscover::Client.new
services = client.get_services(credentials)
ews_url = services.ews_url
Viewpoint::EWS::EWS.endpoint = ews_url
Viewpoint::EWS::EWS.set_auth 'username','password'
#believe this fetches the primary calendar. Still need to figure out how to get the list of all calendars.
calendar = Viewpoint::EWS::Folder.get_folder(:calendar)