Skip to content

Instantly share code, notes, and snippets.

View samjsharpe's full-sized avatar

Sam J Sharpe samjsharpe

View GitHub Profile
@samjsharpe
samjsharpe / extract.py
Created February 11, 2023 22:11
extract images from IRG file
from re import A
from PIL import Image, ImageDraw
width = 180
height = 240
diff_start=0x80
first_array_start = diff_start
first_array_end = diff_start + width * height - 1
second_array_start = diff_start + width * height
[sam@server ~]$ whois -s -h whois.iana.org service.gov.uk | grep refer:
refer: whois.nic.uk
[sam@server ~]$ whois -s -h whois.nic.uk service.gov.uk | grep refer: # note there is no referral answer
[sam@server ~]$ whois -s -h whois.nic.uk service.gov.uk | head # in fact it's showing gov.uk, not service.gov.uk
[Querying whois.nic.uk]
[whois.nic.uk]
Domain name:
gov.uk
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "puppetlabs/centos-7.0-64-nocm"
config.vm.provider :rackspace do |rs, override|
rs.username = ENV['OS_USERNAME']
rs.api_key = ENV['OS_PASSWORD']
rs.rackspace_region = ENV['OS_REGION_NAME']
@samjsharpe
samjsharpe / script to clean data
Created June 18, 2015 21:26
Clean up government domain list
curl -s https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/362257/List_of_gov_uk_domain_names_as_at_1_October_2014.csv | \
cut -d, -f1 | \
while read line; do
whois -h whois.ja.net $line > tempfile;
OWNER=`egrep -A1 "(Domain Owner|Registered For)" tempfile | awk 'NR==2 {for (i=1; i<=NF; i++) printf("%s%s", $(i), i<NF ? OFS : "\n");}'`;
POSTCODE=`/opt/boxen/homebrew/opt/gnu-sed/libexec/gnubin/sed -rn 's/.*(([A-Z]{1,2}[0-9]{1,2}|[A-Z]{1,2}[0-9][A-Z]) [0-9][A-Z]{2}).*/\1/p' tempfile` ;
grep -q "No such domain" tempfile || print $line,$OWNER,$POSTCODE;
done
[/Users/sam]$ dig @8.8.8.8 lon.samsharpe.net
; <<>> DiG 9.8.3-P1 <<>> @8.8.8.8 lon.samsharpe.net
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 33571
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
context "running launch commands" do
before(:all) do
@test_data = define_test_data
@config_yaml = ErbHelper.convert_erb_template_to_yaml(@test_data, File.join(File.dirname(__FILE__), 'data/happy_path.yaml.erb'))
@api_interface = Vcloud::Core::ApiInterface.new
end
context "which exit with success" do
Vcloud::Launcher::Launch.new(@config_yaml, { "continue-on-error" => false, "post-launch-cmd" => 'data/true_cmd'}).run
@vapp_query_result = @api_interface.get_vapp_by_name_and_vdc_name(@test_data[:vapp_name], @test_data[:vdc_name])
git diff
[gds/boxes:packer●]$ /opt/boxen/homebrew/bin/packer build -only=precise64_vmware_fusion templates.json
precise64_vmware_fusion output will be in this color.
==> precise64_vmware_fusion: Downloading or copying ISO
precise64_vmware_fusion: Downloading or copying: http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso
==> precise64_vmware_fusion: Creating virtual machine disk
==> precise64_vmware_fusion: Building and writing VMX file
==> precise64_vmware_fusion: Starting HTTP server on port 8546
==> precise64_vmware_fusion: Starting virtual machine...
$ /opt/boxen/homebrew/bin/packer build -only=precise64_vmware_fusion templates.json
precise64_vmware_fusion output will be in this color.
==> precise64_vmware_fusion: Downloading or copying ISO
precise64_vmware_fusion: Downloading or copying: http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso
precise64_vmware_fusion: Download progress: 4%
precise64_vmware_fusion: Download progress: 9%
precise64_vmware_fusion: Download progress: 14%
precise64_vmware_fusion: Download progress: 19%
precise64_vmware_fusion: Download progress: 24%
350,507d349
< window.templates["search/_results_block"]=new Hogan.Template(function(e
< t
< n){var r=this;return r.b(n=n||"")
< r.s(r.f("filter_fields"
< e
< t
< 1)
< e
< t
@samjsharpe
samjsharpe / gist:562e142d50cbf456a1e7
Created July 3, 2014 11:15
rspec-fails-on-puppet-syntax
/opt/rubies/1.9.3-p545/bin/ruby -S rspec ./spec/puppet-syntax/hiera_spec.rb ./spec/puppet-syntax/manifests_spec.rb ./spec/puppet-syntax/tasks/puppet-syntax_spec.rb ./spec/puppet-syntax/templates_spec.rb ./spec/puppet-syntax_spec.rb
PuppetSyntax::Hiera
should expect an array of files
should return nothing from valid YAML
should return an error from invalid YAML
PuppetSyntax::Manifests
should expect an array of files
should return nothing from a valid file