Skip to content

Instantly share code, notes, and snippets.

View mmriis's full-sized avatar

Morten Møller Riis mmriis

  • FTZ A/S
  • Odense, Denmark
View GitHub Profile
au BufNewFile,BufRead *.yml,*.yaml call s:DetectAnsibleVault()
fun! s:DetectAnsibleVault()
let n=1
while n<10 && n < line("$")
if getline(n) =~ 'ANSIBLE_VAULT'
set filetype=ansible-vault
endif
let n = n + 1
endwhile
@mmriis
mmriis / .vimrc
Created December 22, 2016 08:59
execute pathogen#infect()
set number
syntax on
set tabstop=4
set shiftwidth=4
set expandtab
set list
set listchars=tab:\ \ ,extends:»,precedes:«,trail:▒,nbsp:·
set statusline+=%F
@mmriis
mmriis / time.rb
Created August 29, 2012 10:27
Random point in time between two dates
class Time
def self.random(t1, t2)
int = t2.to_i - t1.to_i
at(t1.to_i + rand(int+1))
end
end
Time.random Time.now, Time.parse("2012/12/31")
=> Tue Nov 06 10:25:17 +0100 2012
@mmriis
mmriis / cvr_information.rb
Created March 8, 2012 12:53
A class that screenscrapes cvr.dk to return company info from either vat_id or name
class CvrInformation
require 'open-uri'
require 'nokogiri'
class CompanyNotFoundInCvr < Exception ; end
class << self
def get_company_from_vat_number(cvr)
@mmriis
mmriis / auth.pl
Created November 30, 2011 11:31
IMAP/POP3 proxy authentication script for nginx. See http://www.whatastruggle.com/nginx-as-an-imappop3-proxy-part-2.
#!/usr/bin/perl
use Digest::HMAC_MD5 qw/ hmac_md5_hex /;
use DBI;
use URI::Escape;
use CGI;
print "Content-type: text/html\n";
my $q = CGI->new;
@mmriis
mmriis / gist:1286783
Created October 14, 2011 10:35
CVR.dk
http://cvr.dk/Site/Forms/PublicService/DisplayCompany.aspx?cvrnr=30505166
def extract_name(doc)
(doc/"div.titletext").inner_html.strip
end
def extract_address(doc)
(doc/"tr:contains('Adresse')/td.fieldvalue").inner_html =~ /^(.+)<br\W+\d{4}\W+(.+)$/
$~[1].strip.gsub("<br />", ", ")
end