Skip to content

Instantly share code, notes, and snippets.

@ricdeez
ricdeez / pad.py
Created December 7, 2016 08:13
Padding pipe delimited text for inclusion in an ascii file nicelly formatted
import pprint
def pad_left(n, width, pad=" "):
return ((pad * width) + str(n))[-width:]
data = """
SERVER|IP_ADDR|LOCATION|PCN
NH-SRV01|10.97.9.30|SUB704|HUB
NH-SRV05|10.97.9.34||HUB
NH-SRV07|10.97.9.40|SUB501|HUB
@ricdeez
ricdeez / gist:fff680ba40ae21693d2f4b2cfbf519dc
Created October 11, 2016 03:18
Center Widget in tkinter
http://effbot.org/tkinterbook/place.htm
Public Sub DoIt()
Dim rge As Excel.Range
Dim my_row As Long
Set rge = Application.Selection
rge.Copy
my_row = rge.Row
@ricdeez
ricdeez / AddsIDtoTableInSelection.vba
Created September 20, 2015 21:02
Adds IDs to MS Word Table in Selection
Public Sub test()
Dim tbl As Word.Table
Dim c As Long
Dim n As Long
Set tbl = Word.Selection.Tables(1)
c = 0
For n = 1 To tbl.Rows.Count
@ricdeez
ricdeez / ruby_MSschedule_generator
Created August 4, 2014 09:54
Generate MSProject Schedule from YAML
#!/usr/bin/ruby
%w( yaml pp win32ole ).each { |dep| require dep }
class WIN32OLE
def self.get_project
begin
connect('MSProject.Application')
rescue WIN32OLERuntimeError => e
new('MSProject.Application')
end
@ricdeez
ricdeez / excel_cell_joiner.vb
Created February 19, 2014 09:33
Excel Join Cells
# encoding: UTF-8
%w(pp date).each { |dep| require dep }
def weird_date_todate(weird_date)
Date.new(weird_date.split(/\./)[2],weird_date.split(/\./)[1],weird_date.split(/\./)[0])
end
puts weird_date_todate('14.10.2013')
# data = DATA
@ricdeez
ricdeez / TimesheetDBEOWUpdater.rb
Created February 5, 2014 06:02
Update Access database date/time field to show date at the end of the week
%w(win32ole date time).each { |dep| require dep }
def week_ending(tm)
# The <?Date> object passed in to week_ending is actually an instance of the Time class
new_tm = tm
offset = case new_tm.strftime('%a')
when "Mon"
6
when "Tue"
5
@ricdeez
ricdeez / list_in_words.rb
Created January 29, 2013 06:58
Ruby: List in Words
print "#{doc}: "
print "#{data.size > 1 ? data[0..-2].join(", ") : ""}#{data.size > 1 ? " and " : "" }#{data[-1].join("")}" if data.size > 0
print "None" if data.size == 0
@ricdeez
ricdeez / databaseimport.rb
Created January 18, 2013 09:25
Ruby Import data to Access from Excel
%w(pp win32ole).each { |dep| require dep }
db = 'C:\Users\rdapaz\Documents\Statement of Compliance.accdb'
cs = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=#{db};"
rs = WIN32OLE.new('ADODB.Recordset')
conn = WIN32OLE.new('ADODB.Connection')
conn.Open(cs)
rs.Open("[SoC]", conn, 1, 3)
conn.Execute("DELETE * FROM SoC")