Skip to content

Instantly share code, notes, and snippets.

View karlosmid's full-sized avatar

Karlo Smid karlosmid

View GitHub Profile
@karlosmid
karlosmid / linkToGitHubWorkfolw
Created September 1, 2011 08:55
GitHub workflow
http://scottchacon.com/2011/08/31/github-flow.html
@karlosmid
karlosmid / application.yml
Created September 1, 2013 11:53
example of application.yml that hold rails env variables
# Add account credentials and API keys here.
# See http://railsapps.github.io/rails-environment-variables.html
# This file should be listed in .gitignore to keep your settings secret!
# Each entry sets a local environment variable and overrides ENV variables in the Unix shell.
# For example, setting:
# GMAIL_USERNAME: Your_Gmail_Username
# makes 'Your_Gmail_Username' available as ENV["GMAIL_USERNAME"]
# Add application configuration variables here, as shown below.
#
GMAIL_USERNAME: Your_Username
@karlosmid
karlosmid / email_exchange.rb
Created February 8, 2014 14:48
Connect to Microsoft Exchange specific folder using viewpoint gem. You can use owsap proxy if needed.
require 'viewpoint'
class EmailExchange
attr_accessor :folder_name
def initialize username, password, ews_endpoint, exchange_folder_name, proxy
if not (proxy.nil? or proxy.empty?)
Viewpoint::EWS::EWS.set_trust_ca './owasp_zap_root_ca.pem'
end
Viewpoint::EWS::EWS.endpoint = ews_endpoint
Viewpoint::EWS::EWS.set_auth username,password
@karlosmid
karlosmid / gist:a0d4923cd0cb34cbd795
Last active August 29, 2015 14:03
Tentamen git workflow

Note: please use git manual to get to know what each git command is actually doing. Divide feature on which you are working in short working deliverables. That means when you are done with your implementation and unit testing, you can merge to master branch and delete your small feature branch.

Clone repository (repository will be called repo furthermore in this wiki.)

mkdir ~/repos
cd repos
git clone git_repository
cd git_repository

@karlosmid
karlosmid / email_pop3.rb
Last active August 29, 2015 14:05
Check email using pop3 protocol.
require 'net/pop'
include Helpers
class EmailPop
attr_accessor :pop
def initialize
end
def create
self.pop = Net::POP3.new app['pop3.server'], app['pop3.port']
self.pop.enable_ssl
@karlosmid
karlosmid / us_week_number.rb
Last active August 29, 2015 14:08
US week number implementation in IronRuby
def us_week_number us_date
date_time_formatinfo_in_dot_net = System::Globalization::DateTimeFormatInfo.new
date_time_formatinfo_in_dot_net.CalendarWeekRule = System::Globalization::CalendarWeekRule.FirstFullWeek
my_calendar = date_time_formatinfo_in_dot_net.Calendar
us_date_dot_net_instance = System::DateTime.parse(us_date.strftime('%Y/%m/%d'))
my_calendar.GetWeekOfYear(us_date_dot_net_instance,date_time_formatinfo_in_dot_net.CalendarWeekRule,date_time_formatinfo_in_dot_net.FirstDayOfWeek)
end
@karlosmid
karlosmid / us_week_number_spec.rb
Last active August 29, 2015 14:08
specification file for us week number
describe "us week number" do
it { expect(us_week_number(Date.parse('20110101'))).to eq 52 }
it { expect(us_week_number(Date.parse('20100101'))).to eq 52 }
it { expect(us_week_number(Date.parse('20091231'))).to eq 52 }
it { expect(us_week_number(Date.parse('20110102'))).to eq 1 }
it { expect(us_week_number(Date.parse('20110102'))).not_to eq Date.parse('20110102').cweek }
end
Failure/Error: from_date = Date.strptime(row['RollingPeriodStart'].to_s.split(' ')[0],'%m/%d/%Y')
TypeError:
can't dup NilClass
# C:/IronRuby1.1/Lib/ruby/1.9.1/date/format.rb:575:in `dup'
# C:/IronRuby1.1/Lib/ruby/1.9.1/date/format.rb:575:in `_strptime'
# C:/IronRuby1.1/Lib/ruby/1.9.1/date.rb:1045:in `strptime'
@karlosmid
karlosmid / wrong_recordset_logic.rb
Created January 18, 2015 20:29
wrong recordset logic
actual.each_with_index { |record,index|
expect(expected[index]).to eq(record)
}
@karlosmid
karlosmid / ok_recordset_logic.rb
Created January 18, 2015 20:32
proper recordset logic
expected.each_with_index { |record,index|
expect(record).to eq(actual[index])
}