Listing posts

Displaying posts 211 - 215 of 328 in total
Split audio files by CUE sheet
Last update
2018-12-12
2018
12-12
«Split CUE+APE/MP3/WAV/...»
1
2
3
4
5
6
7
8
9
apt-get install shntool       # shnsplit command
apt-get install lame          # MP3 encoding
apt-get install monkeys-audio # APE codecs

# you can pass your own custom command after "cust ext=xxx"
shnsplit \
  -o "cust ext=mp3 lame -m s -h -b 256 - %f" \
  -t "%n - %t" \
  -f in.cue in.ape

Note: On the raspberry/raspbian you can download the latest armhf packages from the deb-multimedia repository and install them:

1
2
3
wget https://www.deb-multimedia.org/pool/main/m/monkeys-audio/libmac2_4.11-u4-b5-s7-dmo3_armhf.deb
wget https://www.deb-multimedia.org/pool/main/m/monkeys-audio/monkeys-audio_4.11-u4-b5-s7-dmo1_armhf.deb
dpkg -i libmac*.deb monkeys-audio*.deb

Source: CUE splitting @ archlinux wiki


~~~ * ~~~

Linux live backup attachment
mouse 1953 · person cloud · link
Last update
2018-12-10
2018
12-10
«tar, netcat, ssh»

You can basically do a live backup of the current running Linux system with tar (see also the attachment):

1
2
3
4
5
6
7
8
9
10
11
sudo tar -czvpf bkup.tgz \\
  --exclude=/home/*      \\
  --exclude=/media/*     \\
  --exclude=/mnt/*/*     \\
  --exclude=/dev/*       \\
  --exclude=/proc/*      \\
  --exclude=/sys/*       \\
  --exclude=/tmp/*       \\
  --exclude=/run/*       \\
  --exclude=/var/log/*   \\
  /

and remember to backup /home by other means.


You can also make a backup through the network:

  • via netcat:
1
2
nc -l -p 6000 > /home/backup.tgz # on remote system
tar ... | nc -w 3 remote_ip 6000 # on local system
  • via ssh:
1
2
3
4
# backup local system on remote one:
tar ... | ssh remote_ip "cat - > /home/backup.tgz"
# backup remote system on local one:
ssh local_ip "tar -f - ..." > /home/backup.tgz

Source: linuxclues


~~~ * ~~~

Strudel con patate, salsiccia e stracchino attachment
mouse 1557 · person cloud · link
Last update
2018-12-07
2018
12-07
« — »
Cover original

Ingredienti:

  • 1x salsiccia
  • 75gr stracchino
  • 100gr mozzarella in panetto
  • 200gr patate lesse
  • 1x pasta sfoglia quadrata
  • 1x tuorlo d'uovo
  • sale e pepe qb

Procedimento:

  1. Schiacciare le patate con sale e pepe e formare un rettangolo sul centro della pasta sfoglia.

  2. Tagliare a dadini/fette la mozzarella e accatastare sul rettangolo.

  3. Schiacciare le salsicce, impastarle con lo stracchino e accatastare sul rettangolo.

  4. Tagliare la pasta sfoglia come in figura:

    e chiudere le strisce intrecciandole.

  5. Spennellare la cima col tuorlo.

  6. Infornare per 25 minuti a 180 gradi.


Fonte: Al.ta.Cucina video su FB


~~~ * ~~~

VNC remote desktop
mouse 4357 · person cloud · link
Last update
2018-12-04
2018
12-04
« — »

Install TigerVNC server (a fork of TightVNC 4 optimized for 3D and video):

1
2
3
4
5
6
7
8
9
10
11
12
apt install tigervnc-standalone-server tigervnc-viewer tigervnc-xorg-extension

# sets a password for current user
tigervncpasswd

# choose your window manager
echo '#!/bin/bash -l' >  .vnc/xstartup
echo 'startxfce4'     >> .vnc/xstartup

# launch server (detached from an eventual login manager)
env -u SESSION_MANAGER -u DBUS_SESSION_BUS_ADDRESS \
  nohup tigervncserver :10 -geometry 1920x1080

Connect to it via the standard viewer:

1
2
xtigervncviewer localhost:10     # choose either display #10
xtigervncviewer localhost::5910  # or the port 5910

or better use Remmina client because it has many useful features:

  • full keyboard grab with escape key
  • scaling (very useful on HiDPI/retina screens)
  • remote resize (only on TigerVNC servers)
  • zoom
  • toggle fullscreen/windowed mode
  • servers/connection list
  • screenshooter

and the latest packaged version is available for stable debian and raspbian.

You can also share your main display :0 via the efficient tigervnc-xorg-extension, put this in /etc/X11/xorg.conf.d/vnc.conf or merge it in your /etc/X11/xorg.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Section "Module"
  Load "vnc"
EndSection

Section "Screen"
  Identifier "my_monitor"

  # use this in a secure environment...
  Option "SecurityTypes"       "None"
  # ...or these if you need authentication
  #Option "SecurityTypes"      "VncAuth"
  #Option "UserPasswdVerifier" "VncAuth"
  #Option "PasswordFile" "/root/.vnc/passwd"
EndSection

Source: xorg vnc module howto, where to put xorg config files


~~~ * ~~~

Postpone commands when Internet is back online
mouse 2122 · person cloud · link
Last update
2018-11-22
2018
11-22
«save commands to disk and run them when the connection is back»

If you need to run a command like wget or mail now but your internet connection is down then you can use this script to save your command to disk and run it when the connection is up again:

1
2
3
wait4inet cmd wget ... # save a command for online execution
wait4inet check        # runs saved commands only if we are online
wait4inet check-loop   # runs every minute any saved command only if we are online

you can add it to your crontab too:

1
2
#  m   h   dom   mon   dow   command
 */5   *     *     *     *   /path/to/wait4inet check > /dev/null 2>&1

Here is the wait4inet script:

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env ruby

Signal.trap('INT') { exit } # graceful exit

module Wait4Inet
  require 'shellwords'
  require 'yaml'

  JOB_DIR = "/tmp/#{File.basename __FILE__}.jobs"
  MAX_RETRIES = 3

  def self.run(args)
    action = args.shift

    # extract action arguments
    data = case action
      when 'check'  # read and execute now every job file
        process_files
        exit

      when 'check-loop'
        interval = args[0].to_i == 0 ? 60 : args[0].to_i
        loop { process_files; sleep interval }
        exit

      when 'cmd'
        { args: args }

      else
        puts "USAGE: #{File.basename __FILE__} <action> [params]"
        puts "  * cmd   <command> [command params]"
        puts "  * check           # runs queued actions"
        puts "  * check-loop [S]  # run \"check\" action every S seconds"
        exit
    end

    save_job action, data
  end # self.run ---------------------------------------------------------------

  def self.process_files
    return unless online? 

    Dir.chdir('/tmp') # safe working directory

    Dir["#{JOB_DIR}/*.w4i"].sort.each do |job_file|
      next if File.exist?("#{job_file}.lock")
      File.open("#{job_file}.lock", 'w').close # touch

      data = YAML::load_file job_file rescue {}

      next unless data[:action] && data[:ts] # sanity check

      puts "\n===== #{File.basename job_file}: #{data}"
      next unless data[:retries].to_i < MAX_RETRIES

      case data[:action]
        when 'cmd'
          system %Q| #{data[:args].map(&:shellescape).join ' '}|
          update_job job_file, data, $?
      end

      File.unlink "#{job_file}.lock"

      sleep 1
    end # each job_file
  end # self.process_files -----------------------------------------------------

  def self.save_job(action, data)
    Dir.mkdir(JOB_DIR) unless File.exist?(JOB_DIR)
    File.chmod(0777, JOB_DIR) if File.owned?(JOB_DIR)

    # write job file with timestamp
    ts    = Time.now
    data  = data.merge action: action, ts: ts
    fname = "#{JOB_DIR}/#{ts.strftime '%F_%T_%3N'}.w4i"
    File.open(fname, 'w'){|f| f.write data.to_yaml }
  end # self.save_job ----------------------------------------------------------

  def self.update_job(job_file, data, exit_code, exit_code_ok = 0)
    if exit_code.to_i == exit_code_ok.to_i
      File.unlink job_file
    else
      data[:retries  ] = data[:retries].to_i + 1
      data[:exit_code] = exit_code.to_i
      File.open(job_file, 'w'){|f| f.write data.to_yaml }
      File.rename(job_file, "#{job_file}.failed") if data[:retries].to_i == MAX_RETRIES
    end
  end # self.update_job --------------------------------------------------------

  def self.online?
    `wget -q --spider -T 3 http://google.com`
    $?.to_i == 0
  end # self.online? -----------------------------------------------------------
end # module Wait4Inet ---------------------------------------------------------

Wait4Inet.run ARGV

The script uses lock files in order to prevent multiple concurrent execution of the same command, so you can safely run long tasks and multiple instances.