Listing posts

Displaying posts 11 - 15 of 234 in total
Extract files from HAR
mouse 97 · person cloud · link
Last update
2020-05-23
2020
05-23
«HAR = HTTP Archive»
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby
$VERBOSE = nil
%w{json base64}.each{|l| require l}

def die(msg, code=1); puts msg; exit code; end

die "File [#{ARGV[0] || '--'}] not found!" unless File.exist?(ARGV[0].to_s)

har = JSON.parse File.read ARGV[0] rescue nil
die "Not a JSON file!" unless har.is_a?(Hash)

har['log']['entries'].each do |e|
  begin
    url   = e['request']['url']
    fname = URI.parse(url).path[1..-1].tr('/', '_')

    content = e['response']['content']
    data = content['text']
    data = Base64.decode64 data if content['encoding'] == 'base64'

    File.open(fname, 'wb'){|f| f.write data }
  rescue
    puts "ERR: #{url}\n#{$!}\n\n"
  end
end

See also: har-extractor


~~~ * ~~~

Systemd spindown disks before shutdown
mouse 77 · person cloud · link
Last update
2020-05-23
2020
05-23
« — »
  • /lib/systemd/system/spindown-disks.service
1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description=HDD spindown service
DefaultDependencies=no
After=umount.target
Before=shutdown.target reboot.target halt.target

[Service]
ExecStart=/opt/bin/spindown-disks.sh
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=shutdown.target
1
2
3
systemctl daemon-reload
systemctl enable  spindown-disks.service
systemctl restart spindown-disks.service
  • /opt/bin/spindown-disks.sh
1
2
3
#!/bin/sh
for i in /dev/sd?; do /sbin/hdparm -Y $i; done
/bin/sleep 5

See also: my systemd-units repo

Source: raspberrypi.org forum USB HDD poweroff (HDD abruptly stop spinning when running the shutdown command)


~~~ * ~~~

patchelf | modifying ELF executables and libraries
mouse 44 · person cloud · link
Last update
2020-05-02
2020
05-02
«modify linux executable interpreter, library path, requirements»
1
2
3
4
5
6
apt install patchelf

patchelf \
  --set-interpreter /lib/ld-linux-x86-64.so.2 \
  --set-rpath       /opt/app/mylibs \
  ./elf-name

Source: github


~~~ * ~~~

Show active SSH tunnels and ports
mouse 707 · person cloud · link
Last update
2020-05-02
2020
05-02
« — »
1
sudo lsof -i -n -P | egrep sshd

Source: Superuser
See also: SSH tunnel howto and hints


~~~ * ~~~

DLNA interactions/tools
Last update
2020-04-26
2020
04-26
« — »

ref

tools

ruby easy_upnp gem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'easy_upnp'

searcher = EasyUpnp::SsdpSearcher.new
devices = searcher.search 'ssdp:all'

device = devices.first
device.all_services

device.description

# client
service = device.service 'urn:schemas-upnp-org:service:ContentDirectory:1', validate_arguments: true
service.service_methods

service.GetSystemUpdateID

service.method_args :Browse
ris = service.Browse ObjectID: '0', BrowseFlag: 'BrowseDirectChildren'
ris2 = Nokogiri::XML.parse ris[:Result]
ris2.css('container').map{|e| e['id'] }

# client from static config
service2 = EasyUpnp::DeviceControlPoint.from_params service.to_params
service.GetSystemUpdateID