bmc-tools 0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/bin-other/autobackup +70 -0
  3. data/bin-other/autobackup.inc +157 -0
  4. data/bin-other/bob/ExtractPagesFromPDF +0 -0
  5. data/bin-other/bob/backupsync +46 -0
  6. data/bin-other/bob/cachesync +58 -0
  7. data/bin-other/bob/deb +55 -0
  8. data/bin-other/bob/debmirror +2551 -0
  9. data/bin-other/bob/debmirror.marlin +2551 -0
  10. data/bin-other/bob/exif_rotate.sh +34 -0
  11. data/bin-other/bob/exif_rotate_dates.sh +35 -0
  12. data/bin-other/bob/git-big-objects +85 -0
  13. data/bin-other/bob/git-commit-details +22 -0
  14. data/bin-other/bob/git-commit-sizes +16 -0
  15. data/bin-other/bob/git-show-biggest.sh +33 -0
  16. data/bin-other/bob/git_remove_history.sh +24 -0
  17. data/bin-other/bob/git_staged_status.sh +29 -0
  18. data/bin-other/bob/identify_extra_raws +137 -0
  19. data/bin-other/bob/wallpaper_restore.sh +1 -0
  20. data/bin-other/bob/watch_olsr.sh +1 -0
  21. data/bin-other/bob/watch_rbpm_node_status +1 -0
  22. data/bin-other/bob/watermark_bmphoto_large.sh +32 -0
  23. data/bin-other/bob/watermark_bmphoto_small.sh +32 -0
  24. data/bin-other/bubbles/deb +42 -0
  25. data/bin-other/bubbles/firewall.sh +134 -0
  26. data/bin-other/bubbles/kernel-mirror.sh +15 -0
  27. data/bin-other/deb +42 -0
  28. data/bin-other/exif_dates.sh +35 -0
  29. data/bin-other/git-large-files +62 -0
  30. data/bin-other/git_add_upto.sh +54 -0
  31. data/bin-other/git_find_big.sh +33 -0
  32. data/bin-other/git_staged_status.sh +29 -0
  33. data/bin-other/image_resize +43 -0
  34. data/bin-other/kernel-mirror.sh +15 -0
  35. data/bin-other/marlin/deb +42 -0
  36. data/bin-other/marlin/firewall.sh +134 -0
  37. data/bin-other/mysql2svn.sh +36 -0
  38. data/bin-other/syno-cleanup.sh +31 -0
  39. data/bin/dockerize +35 -23
  40. data/bin/image_exif +30 -0
  41. data/bin/image_process +156 -0
  42. data/bin/image_process_wname +138 -0
  43. data/bin/tgv_to_pdf +206 -0
  44. data/bmc-tools.gemspec +1 -1
  45. data/lib/cli.rb +8 -0
  46. data/lib/constants.rb +1 -0
  47. data/lib/docker.rb +15 -0
  48. data/lib/git.rb +21 -0
  49. data/lib/runner.rb +19 -0
  50. metadata +52 -2
@@ -0,0 +1,34 @@
1
+ #!/bin/bash
2
+ total=$#
3
+ current=0
4
+ percent=0
5
+
6
+ (
7
+ while [[ -n "$1" ]]; do
8
+ # update progress bar
9
+ percent=`expr 100 \* $current / $total`
10
+ echo "$percent" ;
11
+ echo "# Processing ($current/$total): $1 "
12
+ #sleep 1
13
+
14
+ # process current file, if a file and not a dir
15
+ if [[ -f "$1" ]]; then
16
+ jhead -autorot "$1"
17
+ if [ "$?" = -1 ] ; then
18
+ zenity --error --text="Processing failed"
19
+ fi
20
+ fi
21
+
22
+ # go to next file
23
+ shift
24
+ $((current+=1))
25
+ done
26
+
27
+ echo "# DONE - $total files processed.";
28
+
29
+ ) |
30
+ zenity --progress \
31
+ --title="Auto-rotating images" \
32
+ --text="Processing files ..." \
33
+ --percentage=0 --auto-kill
34
+
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+ total=$#
3
+ current=0
4
+ percent=0
5
+
6
+ (
7
+ while [[ -n "$1" ]]; do
8
+ # update progress bar
9
+ percent=`expr 100 \* $current / $total`
10
+ echo "$percent" ;
11
+ echo "# Processing ($current/$total): $1 "
12
+ #sleep 1
13
+
14
+ # process current file, if a file and not a dir
15
+ if [[ -f "$1" ]]; then
16
+ jhead -autorot -ft "$1"
17
+ if [ "$?" = -1 ] ; then
18
+ zenity --error --text="Processing failed"
19
+ fi
20
+ fi
21
+
22
+ # go to next file
23
+ shift
24
+ $((current+=1))
25
+ done
26
+
27
+ echo "# DONE - $total files processed.";
28
+
29
+ ) |
30
+ zenity --progress \
31
+ --title="Auto-rotate and date update from EXIF" \
32
+ --text="Processing files ..." \
33
+ --percentage=0 --auto-kill
34
+
35
+
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module GitBigObjects
4
+ class Blob
5
+ include Comparable
6
+
7
+ REVISIONS = Hash[
8
+ `git rev-list --all --objects`.lines.map { |line| line.scan(/\S+/) }
9
+ ]
10
+
11
+ STORAGE_UNITS = [:B, :K, :M, :G, :T].freeze
12
+ STORAGE_BASE = 1024 # not 1024
13
+
14
+ attr_reader :sha, :size, :size_in_pack_file
15
+
16
+ def initialize(options = {})
17
+ @sha = options[:sha]
18
+ @size = options[:size].to_i
19
+ @size_in_pack_file = options[:size_in_pack_file].to_i
20
+ end
21
+
22
+ def <=>(other)
23
+ other.size <=> size
24
+ end
25
+
26
+ def name
27
+ @name ||= REVISIONS[sha]
28
+ end
29
+
30
+ # Parts borrow from ActionPack (http://j.mp/K6lT6W)
31
+ def human_readable_size
32
+ if size < STORAGE_BASE
33
+ "#{size}B"
34
+ else
35
+ max_exp = STORAGE_UNITS.size - 1
36
+ exponent = (Math.log(size) / Math.log(STORAGE_BASE)).to_i # Convert to base
37
+ exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit
38
+ number = size.to_f / (STORAGE_BASE ** exponent)
39
+
40
+ unit = STORAGE_UNITS[exponent]
41
+
42
+ "#{'%.02f' % number}#{unit}"
43
+ end
44
+ end
45
+
46
+ def short_sha
47
+ sha[0, 8]
48
+ end
49
+
50
+ def inspect
51
+ %(#<Blob #{short_sha} size:#{size}>)
52
+ end
53
+
54
+ def to_s
55
+ "#{human_readable_size}\t\t#{name} (#{short_sha})"
56
+ end
57
+ end
58
+
59
+ class Report < Struct.new(:argv)
60
+ PACKS = `git verify-pack -v .git/objects/pack/pack-*.idx`.lines
61
+
62
+ def to_s
63
+ PACKS.map { |line| blob_from_line(line) }.compact.sort.first(limit).join("\n")
64
+ end
65
+
66
+ private
67
+
68
+ def limit
69
+ if arg = argv.first
70
+ arg.to_i
71
+ else
72
+ 10
73
+ end
74
+ end
75
+
76
+ def blob_from_line(line)
77
+ sha, type, size, size_in_pack_file, offset_in_packfile = line.scan(/\S+/)
78
+ if type == 'blob'
79
+ Blob.new(sha: sha, size: size, size_in_pack_file: size_in_pack_file)
80
+ end
81
+ end
82
+ end
83
+ end
84
+
85
+ puts GitBigObjects::Report.new(ARGV)
@@ -0,0 +1,22 @@
1
+ #!/bin/sh
2
+
3
+ if [ $# -ne 1 ]; then
4
+ echo "Rationale : Get the total size of all files added by the specified commit."
5
+ echo "Usage : $(basename $0) <commit>"
6
+ exit 1
7
+ fi
8
+
9
+ blob_sizes=$(git diff-tree -r -c -M -C --no-commit-id $1 | grep " A " | cut -d " " -f 4 | git cat-file --batch-check | cut -d " " -f 3)
10
+ total_size=0
11
+
12
+ for size in $blob_sizes; do
13
+ let total_size+=size
14
+ done
15
+
16
+ if [ $total_size -gt 0 ]; then
17
+ total_size_kib=$(echo $total_size | awk '{printf "%.2f",$1/1024}')
18
+ total_size_mib=$(echo $total_size_kib | awk '{printf "%.2f",$1/1024}')
19
+ echo "The commit adds files totalling in $total_size bytes ($total_size_kib KiB, $total_size_mib MiB)."
20
+ else
21
+ echo "The commit does not add any files."
22
+ fi
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/perl
2
+ foreach my $rev (`git rev-list --all --pretty=oneline`) {
3
+ my $tot = 0;
4
+ ($sha = $rev) =~ s/\s.*$//;
5
+ foreach my $blob (`git diff-tree -r -c -M -C --no-commit-id $sha`) {
6
+ $blob = (split /\s/, $blob)[3];
7
+ next if $blob == "0000000000000000000000000000000000000000"; # Deleted
8
+ my $size = `echo $blob | git cat-file --batch-check`;
9
+ $size = (split /\s/, $size)[2];
10
+ $tot += int($size);
11
+ }
12
+ my $revn = substr($rev, 0, 40);
13
+ if ($tot > 1000000) {
14
+ print "$tot $revn " . `git show --pretty="format:" --name-only $revn | wc -l` ;
15
+ }
16
+ }
@@ -0,0 +1,33 @@
1
+ #!/bin/bash
2
+ #set -x
3
+
4
+ # Shows you the largest objects in your repo's pack file.
5
+ # Written for osx.
6
+ #
7
+ # @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
8
+ # @author Antony Stubbs
9
+
10
+ # set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
11
+ IFS=$'\n';
12
+
13
+ # list all objects including their size, sort by size, take top 10
14
+ objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head`
15
+
16
+ echo "All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file."
17
+
18
+ output="size,pack,SHA,location"
19
+ for y in $objects
20
+ do
21
+ # extract the size in bytes
22
+ size=$((`echo $y | cut -f 5 -d ' '`/1024))
23
+ # extract the compressed size in bytes
24
+ compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024))
25
+ # extract the SHA
26
+ sha=`echo $y | cut -f 1 -d ' '`
27
+ # find the objects location in the repository tree
28
+ other=`git rev-list --all --objects | grep $sha`
29
+ #lineBreak=`echo -e "\n"`
30
+ output="${output}\n${size},${compressedSize},${other}"
31
+ done
32
+
33
+ echo -e $output | column -t -s ', '
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+ set -o errexit
3
+
4
+ # Author: David Underhill
5
+ # Script to permanently delete files/folders from your git repository. To use
6
+ # it, cd to your repository's root and then run the script with a list of paths
7
+ # you want to delete, e.g., git-delete-history path1 path2
8
+
9
+ if [ $# -eq 0 ]; then
10
+ exit 0
11
+ fi
12
+
13
+ # make sure we're at the root of git repo
14
+ if [ ! -d .git ]; then
15
+ echo "Error: must run this script from the root of a git repository"
16
+ exit 1
17
+ fi
18
+
19
+ # remove all paths passed as arguments from the history of the repo
20
+ files=$@
21
+ git filter-branch –prune-empty --index-filter "git rm -rf --cached --ignore-unmatch $files" HEAD
22
+
23
+ # remove the temporary history git-filter-branch otherwise leaves behind for a long time
24
+ rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+ SAVEIFS=$IFS
3
+ IFS=$(echo -en "\n\b")
4
+
5
+ # Get total size of staged files
6
+ total=0
7
+ count=0
8
+ for filename in $(git diff --staged --name-only --relative)
9
+ do
10
+ filesize=$(stat -f "%z" "$filename")
11
+ total=$(($total + $filesize))
12
+ count=$(($count + 1))
13
+ done
14
+ echo "staged ..... $(($total /1024)) KB, $count file(s)"
15
+
16
+ # Get total size of staged files
17
+ total=0
18
+ count=0
19
+ for filename in $(git ls-files -o)
20
+ do
21
+ filesize=$(stat -f "%z" "$filename")
22
+ count=$(($count + 1))
23
+ total=$(($total + $filesize))
24
+ done
25
+ echo "unstaged ... $(($total /1024)) KB, $count file(s)"
26
+
27
+ # End
28
+ IFS=$SAVEIFS
29
+
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Init
4
+ require 'fileutils'
5
+ require 'pathname'
6
+ require 'optparse'
7
+ #include FileUtils
8
+ paramj = paramr = nil
9
+
10
+
11
+ # Option parser
12
+ options = {}
13
+ OptionParser.new do |o|
14
+ o.on('-j jpeg path') { |p| paramj = p }
15
+ o.on('-r raw path') { |p| paramr = p }
16
+ o.on('-h') { puts o; exit }
17
+ o.parse!
18
+ end
19
+
20
+ # Params
21
+ if paramj.nil? || paramr.nil?
22
+ puts "quitting: please specify paths"
23
+ exit
24
+ end
25
+ path_jpeg = Pathname.new(paramj).realpath
26
+ path_raw = Pathname.new(paramr).realpath
27
+
28
+ unless Dir.exists? path_jpeg
29
+ puts "quitting: jpeg_path does not exist"
30
+ exit
31
+ end
32
+ unless Dir.exists? path_raw
33
+ puts "quitting: raws_path does not exist"
34
+ exit
35
+ end
36
+
37
+ # Methods
38
+ def ls_in path
39
+ list = {}
40
+ Dir["#{path}/*"].each do |file|
41
+ next if File.directory? file
42
+ key = File.basename(file, File.extname(file))
43
+ list[key] = file
44
+ end
45
+ return list
46
+ end
47
+
48
+ # Core
49
+
50
+ # Collect JPEG filenames stripping extension
51
+ jpegs = ls_in path_jpeg
52
+ puts "JPEG: #{jpegs.size} files in: #{path_jpeg}"
53
+
54
+ raws = ls_in path_raw
55
+ puts "RAWS: #{raws.size} files in: #{path_raw}"
56
+
57
+ puts
58
+
59
+ # Do differences
60
+ missing_raws = jpegs.keys - raws.keys
61
+ if missing_raws.empty?
62
+ puts "> no missing file in RAW"
63
+ else
64
+ puts "> missing files in RAW :"
65
+ puts missing_raws.join(', ')
66
+ end
67
+
68
+ missing_jpegs = raws.keys - jpegs.keys
69
+ if missing_jpegs.empty?
70
+ puts "> no missing files in JPEG"
71
+ else
72
+ puts "> missing files in JPEG :"
73
+ puts missing_jpegs.join(', ')
74
+
75
+ path_trash = "#{path_raw}/trash"
76
+ puts "moving extra RAWS to TRASH"
77
+ puts "> mkdir #{path_trash}"
78
+ FileUtils.mkdir(path_trash)
79
+ missing_jpegs.each do |key|
80
+ filename = raws[key]
81
+ puts "> mv #{key}: #{filename}"
82
+ FileUtils.mv(filename, path_trash)
83
+ end
84
+ end
85
+
86
+ #FileUtils.mkdir(path_trash)
87
+
88
+
89
+ #result = `which #{name}`
90
+ #%x{ }
91
+
92
+ # result = system 'cp', '/full/path/to/my_file', '/target/directory'
93
+ # if result.nil?
94
+ # puts "Error was #{$?}"
95
+ # elsif result
96
+ # puts "You made it!"
97
+ # end
98
+
99
+ # Dir['*.rb'] #basic globs
100
+ # Dir['**/*.rb'] #** == any depth of directory, including current dir.
101
+ # #=> array of relative names
102
+ #
103
+ # File.expand_path('~/file.txt') #=> "/User/mat/file.txt"
104
+ # File.dirname('dir/file.txt') #=> 'dir'
105
+ # File.basename('dir/file.txt') #=> 'file.txt'
106
+ # File.join('a', 'bunch', 'of', 'strings') #=> 'a/bunch/of/strings'
107
+ #
108
+ #
109
+ # cd(dir, options)
110
+ # cd(dir, options) {|dir| .... }
111
+ # pwd()
112
+ # mkdir(dir, options)
113
+ # mkdir(list, options)
114
+ # mkdir_p(dir, options)
115
+ # mkdir_p(list, options)
116
+ # rmdir(dir, options)
117
+ # rmdir(list, options)
118
+ # ln(old, new, options)
119
+ # ln(list, destdir, options)
120
+ # ln_s(old, new, options)
121
+ # ln_s(list, destdir, options)
122
+ # ln_sf(src, dest, options)
123
+ # cp(src, dest, options)
124
+ # cp(list, dir, options)
125
+ # cp_r(src, dest, options)
126
+ # cp_r(list, dir, options)
127
+ # mv(src, dest, options)
128
+ # mv(list, dir, options)
129
+ # rm(list, options)
130
+ # rm_r(list, options)
131
+ # rm_rf(list, options)
132
+ # install(src, dest, mode = <src's>, options)
133
+ # chmod(mode, list, options)
134
+ # chmod_R(mode, list, options)
135
+ # chown(user, group, list, options)
136
+ # chown_R(user, group, list, options)
137
+ # touch(list, options)
@@ -0,0 +1 @@
1
+ osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Users/bruno/Documents/DOCS/wallpapers/01370_planetnewyork_2560x1600.jpg"'
@@ -0,0 +1 @@
1
+ watch -n 0 olsr-topology-view.pl --server 127.0.0.1 --style 1 --resolv --bgcolor \#888888
@@ -0,0 +1 @@
1
+ curl http://localhost:2003/monitor | python -mjson.tool
@@ -0,0 +1,32 @@
1
+ #!/bin/bash
2
+ #
3
+ # watermark.sh
4
+ # $Id: watermark,v 1.1 2004/10/03 10:52:21 ullgren Exp $
5
+ #
6
+ # Add a defined watermark to a series of pictures
7
+ #
8
+
9
+ # Absolute Location of the Watermark file
10
+ WM="/home/bruno/watermark-bmphoto-large.png"
11
+
12
+ if [ ! -n "$1" ]
13
+ then
14
+ zenity --error --text "Please select pics to be watermarked!"
15
+ exit $E_BADARGS
16
+ fi
17
+
18
+ typeset -i CNT=1
19
+ typeset -i CUR=0
20
+
21
+ (
22
+ for pic in "$@"
23
+ do
24
+ echo "#Watermarking $pic"
25
+
26
+ composite -dissolve 40% -gravity SouthEast -geometry +0+60 "$WM" "$pic" "$pic"
27
+
28
+ CUR=$CNT*100/$#
29
+ echo $CUR
30
+ CNT=$CNT+1
31
+ done
32
+ ) | zenity --progress --auto-close --percentage=0