Skip to content

Instantly share code, notes, and snippets.

@happymcplaksin
happymcplaksin / register-yaketystats-service.rb
Created September 4, 2013 01:49
Register the YaketyStats service on Windows
equire "win32/service"
include Win32
begin
Service.new(
:service_name => 'yaketystats',
:host => 'localhost',
:service_type => Service::WIN32_OWN_PROCESS,
:description => 'YaketyStats client for Windows',
:start_type => Service::AUTO_START,
@happymcplaksin
happymcplaksin / gist:4073601
Last active January 3, 2024 09:08
Find VMware objects via rbvmomi
# Return all objects which match one of the types. types can be a
# string or an array
#
# For example:
# find_all(vim,'VirtualMachine')
def find_all(vim,types,startobj=vim.rootFolder)
# Allow types to be a string or an array.
types = [types].flatten
return vim.serviceContent.viewManager.CreateContainerView({:container => startobj, :type => types, :recursive => true}).view
end
start_logging(){
# Michael is so smart
PIPE=/tmp/CornCobPipe.$$
mknod $PIPE p # Create named pipe to talk to logchild
trap 'rm -rf $PIPE' exit # Remove pipe on exit
:>>$LOG # Create the log if it doesn't exist
tee -a $LOG <$PIPE & # And our child is born
exec >>$PIPE 2>&1 # All output goes to std{err,out} & log
# Michael is no longer smart
}
if STDOUT.isatty
if ENV['PAGER'] == nil
ENV['PAGER'] = 'less'
end
exec( $0 + %Q{ %s 2>&1| #{ENV['PAGER']}} % ARGV.join(' '))
end
# vim: set sw=4 sts=4 et tw=0 :
# Local monkeypatching to string.
class String
# get/kill first word
def firstword
self.sub(/^\s*([\S]+).*/,'\1').strip
end
def rmfirstword
`Here is some code yabba!`
*italics!*
# Header, bud! #
[usg web site](http://www.usg.edu/)
## Header2 ##
yab
<%= log %> {
<% options.each do |opt| -%> <%= opt %>
<% end -%>
<% if postrotate != "NONE" -%> postrotate
<%= postrotate %>
endscript
<% end -%>
}
def self.ptitv(p,t,i,ts,v)
YS.out({'p' => p, 't' => t, 'i' => i, 'ts' => ts, 'v' => v})
end
diff --git a/lib/tdcache.rb b/lib/tdcache.rb
index a2a295e..767e007 100644
--- a/lib/tdcache.rb
+++ b/lib/tdcache.rb
@@ -37,6 +37,15 @@ module TDcache
run_or_not(file){|file,cachefile| TDcache.file(file,cachefile) }
end
+ def self.give_url(url)
+ run_or_not(url){|url,cachefile| TDcache.url(url,cachefile) }