sakuric 2.0.1
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.
- data/CHANGELOG +13 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +60 -0
- data/HISTORY.yml +13 -0
- data/INSTALL +5 -0
- data/LICENSE +1 -0
- data/Makefile +19 -0
- data/Manifest +405 -0
- data/README.md +72 -0
- data/Rakefile +4 -0
- data/TODO +3 -0
- data/VERSION +1 -0
- data/bashrc +30 -0
- data/bashrc.d/00-functions.include +7 -0
- data/bashrc.d/01-sakura_checks.include +15 -0
- data/bashrc.d/02-uname.include +11 -0
- data/bashrc.d/80-ruby.include +4 -0
- data/bashrc.d/99-dirs.include +11 -0
- data/bashrc.d/aliases.include +20 -0
- data/bashrc.d/common.include +7 -0
- data/bashrc.d/local.d/README +1 -0
- data/bashrc.d/local.d/nothing.include +0 -0
- data/bashrc.d/uname.d/Darwin +6 -0
- data/bashrc.d/uname.d/Linux +0 -0
- data/bashrc.local.sample +11 -0
- data/bin/10 +7 -0
- data/bin/10times +7 -0
- data/bin/1every +22 -0
- data/bin/1everyN +22 -0
- data/bin/1suN +22 -0
- data/bin/2 +5 -0
- data/bin/act +24 -0
- data/bin/amarelo +2 -0
- data/bin/arancio +4 -0
- data/bin/arcobaleno +10 -0
- data/bin/bianco +3 -0
- data/bin/black +2 -0
- data/bin/brew-install +3 -0
- data/bin/cache +50 -0
- data/bin/cache3 +50 -0
- data/bin/cheorae +4 -0
- data/bin/colorastdouterr +37 -0
- data/bin/cp2desktop +3 -0
- data/bin/create-git-repo.sh +24 -0
- data/bin/csoe +37 -0
- data/bin/data +3 -0
- data/bin/derive +90 -0
- data/bin/dimmi +31 -0
- data/bin/dimmiora +4 -0
- data/bin/doppioni +48 -0
- data/bin/du- +9 -0
- data/bin/duplicates +48 -0
- data/bin/echodo +7 -0
- data/bin/ensure_line_present +82 -0
- data/bin/epoch2date +5 -0
- data/bin/fanout +100 -0
- data/bin/find-broken-symlink +26 -0
- data/bin/find-duplicates +48 -0
- data/bin/find-special-chars-within-filenames +12 -0
- data/bin/fix-terminal +5 -0
- data/bin/gce-create-centos-instance +5 -0
- data/bin/gce-create-custom-image +8 -0
- data/bin/gce-curl-get-instances-for-project +7 -0
- data/bin/gce-get-token +3 -0
- data/bin/gce-getproject-metadata +35 -0
- data/bin/gce-public-ip +4 -0
- data/bin/gcutil-fetch +36 -0
- data/bin/giallo +2 -0
- data/bin/git-clone-in-non-empty-dir +21 -0
- data/bin/git-ignore +3 -0
- data/bin/git-repos +98 -0
- data/bin/git-repos.py +99 -0
- data/bin/gitinfo +2 -0
- data/bin/google-spreadsheet-cat +40 -0
- data/bin/google_ips +5 -0
- data/bin/gray +3 -0
- data/bin/green +2 -0
- data/bin/grigio +3 -0
- data/bin/gsutil-debug-bucket +12 -0
- data/bin/gsutil-get-oauth2-token +4 -0
- data/bin/gugol-image +74 -0
- data/bin/hamachi-ubuntu-install +17 -0
- data/bin/head-1^-1 +5 -0
- data/bin/ifdownup +13 -0
- data/bin/immature/ok2 +25 -0
- data/bin/immature/twice-still-broken +9 -0
- data/bin/install-gic-repo +13 -0
- data/bin/install-sakura-on-debian-latest +6 -0
- data/bin/iphoto_big_files.sh +37 -0
- data/bin/itunes +140 -0
- data/bin/jason-xpath.rb +54 -0
- data/bin/jsawk +1128 -0
- data/bin/json-xpath.rb +54 -0
- data/bin/keepup +13 -0
- data/bin/lsof-top10 +3 -0
- data/bin/minicook +218 -0
- data/bin/mv2. +2 -0
- data/bin/mv2desktop +2 -0
- data/bin/mv2dropbox +2 -0
- data/bin/mv2here +2 -0
- data/bin/mvto +39 -0
- data/bin/nero +2 -0
- data/bin/never_as_root +18 -0
- data/bin/not +16 -0
- data/bin/ok +42 -0
- data/bin/orange +4 -0
- data/bin/pink +2 -0
- data/bin/polygen-dell +7 -0
- data/bin/polygen-heanet +6 -0
- data/bin/polygen-labs +4 -0
- data/bin/print_key_val +4 -0
- data/bin/rainbow +10 -0
- data/bin/recipe +19 -0
- data/bin/red +2 -0
- data/bin/remember-command +140 -0
- data/bin/remember-command.rb +140 -0
- data/bin/richelp +99 -0
- data/bin/ricorda-comando +140 -0
- data/bin/rosa +2 -0
- data/bin/rosso +2 -0
- data/bin/run-parts.sh +50 -0
- data/bin/sakura-check-version +48 -0
- data/bin/sakura-init.DRAFT +5 -0
- data/bin/sakura-version +2 -0
- data/bin/sano +5 -0
- data/bin/sbianca +3 -0
- data/bin/sblua +2 -0
- data/bin/setterm-reset +5 -0
- data/bin/sgialla +2 -0
- data/bin/sgrigia +2 -0
- data/bin/split +37 -0
- data/bin/split.rb +37 -0
- data/bin/srosa +1 -0
- data/bin/srossa +2 -0
- data/bin/strip-white-spaces +2 -0
- data/bin/stty-sane +5 -0
- data/bin/sudo^-1 +18 -0
- data/bin/sverda +6 -0
- data/bin/swift-saio-install.sh +336 -0
- data/bin/synergyc +0 -0
- data/bin/synergys +0 -0
- data/bin/syracuse.pl +29 -0
- data/bin/tail-n+2 +5 -0
- data/bin/tellme +31 -0
- data/bin/tellme-time +4 -0
- data/bin/timeout3 +91 -0
- data/bin/top5 +4 -0
- data/bin/trim +4 -0
- data/bin/trova-broken-symlink +26 -0
- data/bin/twice +5 -0
- data/bin/twice.rb +5 -0
- data/bin/ubuntu-install-hamachi64 +17 -0
- data/bin/ultimo +5 -0
- data/bin/upload.py +2380 -0
- data/bin/usleep +0 -0
- data/bin/varia +90 -0
- data/bin/verde +2 -0
- data/bin/vermelho +2 -0
- data/bin/vim-whereveritis +5 -0
- data/bin/viola +1 -0
- data/bin/virsh-list-all-vms.py +21 -0
- data/bin/virtualbox-manage +41 -0
- data/bin/weekend +12 -0
- data/bin/whattimeisit +4 -0
- data/bin/whereis-ip +5 -0
- data/bin/white +3 -0
- data/bin/whitefy +3 -0
- data/bin/yellow +2 -0
- data/bin/yellowfy +2 -0
- data/bin/zombies +25 -0
- data/docz/polygen/dell.grm +100 -0
- data/docz/polygen/frati.grm +85 -0
- data/docz/polygen/heanet.grm +54 -0
- data/docz/richelp/gcompute.yml +52 -0
- data/docz/richelp/gcutil.yml +52 -0
- data/docz/richelp/gmail.yml +2 -0
- data/docz/richelp/ruby.yml +81 -0
- data/docz/richelp/sakura.yml +20 -0
- data/docz/richelp/sql.yml +12 -0
- data/docz/richelp/ubuntu.yml +22 -0
- data/docz/richelp/yaml.yml +39 -0
- data/docz/richelp/yml.yml +39 -0
- data/etc/sakura/devel.yml +36 -0
- data/etc/synergy.conf.example +37 -0
- data/images/color-sample.png +0 -0
- data/images/google.jpg +0 -0
- data/images/icons/toilet.png +0 -0
- data/images/sakura.jpg +0 -0
- data/images/sakura2.jpg +0 -0
- data/init.rb +5 -0
- data/lib/classes/arrays.rb +246 -0
- data/lib/classes/debug_ric.rb +196 -0
- data/lib/classes/fake_data.rb +8 -0
- data/lib/classes/ric_debug.rb +0 -0
- data/lib/classes/ricconf.rb +110 -0
- data/lib/classes/richelp.rb +70 -0
- data/lib/classes/strings.rb +284 -0
- data/lib/facter/google_compute_engine.rb +10 -0
- data/lib/recipes/20120411-puppet-rump-palladius.recipe +2 -0
- data/lib/recipes/20120726-skype.ubuntu.recipe +16 -0
- data/lib/recipes/20130206-puppet3.ubuntu.recipe +32 -0
- data/lib/recipes/20130206-redis.linux.recipe +17 -0
- data/lib/recipes/20130208-vanilla.linux.recipe +37 -0
- data/lib/recipes/Makefile +4 -0
- data/lib/recipes/README.md +29 -0
- data/lib/recipes/scripts/redis.sh +14 -0
- data/lib/ric.rb +156 -0
- data/lib/ric_colors.rb +313 -0
- data/lib/ric_strings.rb +285 -0
- data/lib/sonice-players/itunes_mac.rb +43 -0
- data/lib/sonice-players/itunes_win.rb +47 -0
- data/lib/sonice-players/mpd.rb +45 -0
- data/lib/sonice-players/rhythmbox.rb +38 -0
- data/profile +1 -0
- data/sakuric.gemspec +40 -0
- data/sbin/install-sakura-on-debian +25 -0
- data/sbin/make-install.sh +10 -0
- data/sbin/mate-createsymlink +4 -0
- data/sounds/0.ogg +0 -0
- data/sounds/0.wav +0 -0
- data/sounds/01.ogg +0 -0
- data/sounds/02.ogg +0 -0
- data/sounds/03.ogg +0 -0
- data/sounds/08.ogg +0 -0
- data/sounds/09.ogg +0 -0
- data/sounds/1.ogg +0 -0
- data/sounds/1.wav +0 -0
- data/sounds/10.ogg +0 -0
- data/sounds/100.ogg +0 -0
- data/sounds/11.ogg +0 -0
- data/sounds/12.ogg +0 -0
- data/sounds/13.ogg +0 -0
- data/sounds/14.ogg +0 -0
- data/sounds/15.ogg +0 -0
- data/sounds/16.ogg +0 -0
- data/sounds/17.ogg +0 -0
- data/sounds/18.ogg +0 -0
- data/sounds/19.ogg +0 -0
- data/sounds/2.ogg +0 -0
- data/sounds/2.wav +0 -0
- data/sounds/20.ogg +0 -0
- data/sounds/21.ogg +0 -0
- data/sounds/22.ogg +0 -0
- data/sounds/23.ogg +0 -0
- data/sounds/24.ogg +0 -0
- data/sounds/26.ogg +0 -0
- data/sounds/3.ogg +0 -0
- data/sounds/3.wav +0 -0
- data/sounds/30.ogg +0 -0
- data/sounds/34.ogg +0 -0
- data/sounds/4.ogg +0 -0
- data/sounds/4.wav +0 -0
- data/sounds/40.ogg +0 -0
- data/sounds/42.ogg +0 -0
- data/sounds/45.ogg +0 -0
- data/sounds/47.ogg +0 -0
- data/sounds/5.ogg +0 -0
- data/sounds/5.wav +0 -0
- data/sounds/50.ogg +0 -0
- data/sounds/6.ogg +0 -0
- data/sounds/6.wav +0 -0
- data/sounds/60.ogg +0 -0
- data/sounds/7.ogg +0 -0
- data/sounds/7.wav +0 -0
- data/sounds/70.ogg +0 -0
- data/sounds/8.ogg +0 -0
- data/sounds/8.wav +0 -0
- data/sounds/80.ogg +0 -0
- data/sounds/9.ogg +0 -0
- data/sounds/9.wav +0 -0
- data/sounds/90.ogg +0 -0
- data/sounds/a.ogg +0 -0
- data/sounds/aaahhh.ogg +0 -0
- data/sounds/abologna.ogg +0 -0
- data/sounds/adargenta.ogg +0 -0
- data/sounds/alzatiecammina.ogg +0 -0
- data/sounds/apache.ogg +0 -0
- data/sounds/attenzione.ogg +0 -0
- data/sounds/awesome.m4a +0 -0
- data/sounds/bazinga.mp3 +0 -0
- data/sounds/bazinga.ogg +0 -0
- data/sounds/bela regaz.wav +0 -0
- data/sounds/benvenuti.wav +0 -0
- data/sounds/benvenuti2.wav +0 -0
- data/sounds/bergonz.ogg +0 -0
- data/sounds/boh.ogg +0 -0
- data/sounds/buahah.ogg +0 -0
- data/sounds/buonasera.ogg +0 -0
- data/sounds/buongiorno.ogg +0 -0
- data/sounds/burp.ogg +0 -0
- data/sounds/carlo.ogg +0 -0
- data/sounds/cena.ogg +0 -0
- data/sounds/che figata.m4a +0 -0
- data/sounds/che figlio di puttana.m4a +0 -0
- data/sounds/che.ogg +0 -0
- data/sounds/ciao.ogg +0 -0
- data/sounds/ciao.wav +0 -0
- data/sounds/da.ogg +0 -0
- data/sounds/davide.ogg +0 -0
- data/sounds/demone.ogg +0 -0
- data/sounds/dhcp.ogg +0 -0
- data/sounds/dinuovo.ogg +0 -0
- data/sounds/dns.ogg +0 -0
- data/sounds/dopo.ogg +0 -0
- data/sounds/e'.ogg +0 -0
- data/sounds/eattivo.ogg +0 -0
- data/sounds/ee.ogg +0 -0
- data/sounds/ehi.ogg +0 -0
- data/sounds/eoragiu.ogg +0 -0
- data/sounds/eorasu.ogg +0 -0
- data/sounds/eripartita.ogg +0 -0
- data/sounds/estato.ogg +0 -0
- data/sounds/estatoriavviato.ogg +0 -0
- data/sounds/fratro.ogg +0 -0
- data/sounds/frozenbubble.ogg +0 -0
- data/sounds/funziona.ogg +0 -0
- data/sounds/go raibh mile maith agaibh.m4a +0 -0
- data/sounds/grazie.ogg +0 -0
- data/sounds/h1.ogg +0 -0
- data/sounds/hainuovaposta.ogg +0 -0
- data/sounds/hogiamangiato.ogg +0 -0
- data/sounds/host.ogg +0 -0
- data/sounds/il.ogg +0 -0
- data/sounds/ilcomputer.ogg +0 -0
- data/sounds/ilnumerodaleiselezionatoe.ogg +0 -0
- data/sounds/ilprocesso.ogg +0 -0
- data/sounds/ilprogramma.ogg +0 -0
- data/sounds/ilservizio.ogg +0 -0
- data/sounds/imap.ogg +0 -0
- data/sounds/imieisuperpoterimidiconoche.ogg +0 -0
- data/sounds/infunzione.ogg +0 -0
- data/sounds/inpunto.ogg +0 -0
- data/sounds/ipmon.ogg +0 -0
- data/sounds/laconnessioneadinternet.ogg +0 -0
- data/sounds/lastampante.ogg +0 -0
- data/sounds/lazzaron.ogg +0 -0
- data/sounds/ldap.ogg +0 -0
- data/sounds/linterfaccia.ogg +0 -0
- data/sounds/lucilla.ogg +0 -0
- data/sounds/ma vaffanculo.m4a +0 -0
- data/sounds/majjal.wav +0 -0
- data/sounds/mamma.ogg +0 -0
- data/sounds/mauro.ogg +0 -0
- data/sounds/max.ogg +0 -0
- data/sounds/meerda.wav +0 -0
- data/sounds/meno.ogg +0 -0
- data/sounds/merda clo.wav +0 -0
- data/sounds/mezza.ogg +0 -0
- data/sounds/mila.ogg +0 -0
- data/sounds/mille.ogg +0 -0
- data/sounds/minuti.ogg +0 -0
- data/sounds/named.ogg +0 -0
- data/sounds/no.ogg +0 -0
- data/sounds/nohofame.ogg +0 -0
- data/sounds/nonfunziona.ogg +0 -0
- data/sounds/nonriescoatrovare.ogg +0 -0
- data/sounds/nonsarebbeoradilavorare.ogg +0 -0
- data/sounds/nonstalavorando.ogg +0 -0
- data/sounds/numero.wav +0 -0
- data/sounds/ooohhh.ogg +0 -0
- data/sounds/pinger.ogg +0 -0
- data/sounds/pocofa.ogg +0 -0
- data/sounds/pop3.ogg +0 -0
- data/sounds/porca puttana.m4a +0 -0
- data/sounds/porcapupazza.ogg +0 -0
- data/sounds/ppp.ogg +0 -0
- data/sounds/pranzo.ogg +0 -0
- data/sounds/prego.ogg +0 -0
- data/sounds/prima.ogg +0 -0
- data/sounds/qualcosamidice.ogg +0 -0
- data/sounds/raggiungibile.ogg +0 -0
- data/sounds/riccardo.ogg +0 -0
- data/sounds/salsa ridge.wav +0 -0
- data/sounds/scusa.ogg +0 -0
- data/sounds/seriously man.m4a +0 -0
- data/sounds/si.ogg +0 -0
- data/sounds/sito porno con sonoro.wav +0 -0
- data/sounds/socmel.wav +0 -0
- data/sounds/sono.ogg +0 -0
- data/sounds/sonoacasa.ogg +0 -0
- data/sounds/sonole.ogg +0 -0
- data/sounds/sputo.ogg +0 -0
- data/sounds/ssh.ogg +0 -0
- data/sounds/stagiocando.ogg +0 -0
- data/sounds/statospento.ogg +0 -0
- data/sounds/stopaiodipalle.ogg +0 -0
- data/sounds/thesedicks.wav +0 -0
- data/sounds/tornatosu.ogg +0 -0
- data/sounds/trapoco.ogg +0 -0
- data/sounds/trequarti.ogg +0 -0
- data/sounds/tutti.ogg +0 -0
- data/sounds/una.ogg +0 -0
- data/sounds/unquarto.ogg +0 -0
- data/sounds/virgola.ogg +0 -0
- data/sources/c/usleep.c +50 -0
- data/spec/my_first_spec.rb +6 -0
- data/tasks/sakuric-gem.rake +21 -0
- data/tasks/testing.rake +15 -0
- data/templates/bashrc.inject +10 -0
- data/templates/happy_christmas.ascii_art +5 -0
- data/test/roodi.sh +10 -0
- data/test/test_mini_failing.rb +3 -0
- data/test/test_mini_ok.rb +3 -0
- data/test/test_ruby_syntax.sh +12 -0
- data/third-party/jsawk/README.markdown +437 -0
- data/third-party/jsawk/jsawk +1128 -0
- metadata +835 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
commands:
|
|
2
|
+
adddisk: Create a new machine disk.
|
|
3
|
+
addfirewall: Create a new firewall.
|
|
4
|
+
addimage: Create a new machine image.
|
|
5
|
+
addinstance: Create a new machine instance.
|
|
6
|
+
addnetwork: Create a new network instance.
|
|
7
|
+
auth: Class for forcing client authorization.
|
|
8
|
+
deletedisk: Delete a machine disk.
|
|
9
|
+
deletefirewall: Delete a firewall.
|
|
10
|
+
deleteimage: Delete a machine image.
|
|
11
|
+
deleteinstance: Delete a machine instance.
|
|
12
|
+
deletenetwork: Delete a machine network.
|
|
13
|
+
deleteoperation: Delete an operation.
|
|
14
|
+
getdisk: Get a machine disk.
|
|
15
|
+
getfirewall: Get a firewall.
|
|
16
|
+
getimage: Get a machine image.
|
|
17
|
+
getinstance: Get a machine instance.
|
|
18
|
+
getkernel: Get a kernel.
|
|
19
|
+
getmachinetype: Get a machine type.
|
|
20
|
+
getnetwork: Get a network instance.
|
|
21
|
+
getoperation: Retrieve an operation resource.
|
|
22
|
+
getproject: Get the resource for a Google Compute project.
|
|
23
|
+
getzone: Get a zone.
|
|
24
|
+
#help: Help for all or selected command:
|
|
25
|
+
listdisks: List the machine disks for a project.
|
|
26
|
+
listfirewalls: List the firewalls for a project.
|
|
27
|
+
listimages: List the machine images for a project.
|
|
28
|
+
listinstances: List the machine instances for a project.
|
|
29
|
+
listkernels: List the machine kernels for a project.
|
|
30
|
+
listmachinetypes: List the machine types.
|
|
31
|
+
listnetworks: List the machine networks for a project.
|
|
32
|
+
listoperations: List the operations for a project.
|
|
33
|
+
listzones: List available zones.
|
|
34
|
+
pull: Pull one or more files from an instance.
|
|
35
|
+
push: Push one or more files to an instance.
|
|
36
|
+
setcommoninstancemetadata: Set the commonInstanceMetadata field for a Google
|
|
37
|
+
ssh: Ssh to an instance.
|
|
38
|
+
version: Get the current version of this command.
|
|
39
|
+
other:
|
|
40
|
+
cache project_id: gcompute getproject --project_id=<your_project_id> --cache_flag_values
|
|
41
|
+
browse gcompute code project (python): @shortcutme mate ~/Dropbox/.linux/git/gcompute-1.1.pre.20120507.1654
|
|
42
|
+
howto install: @shortcutme open https://developers.google.com/compute/docs/gcompute_setup
|
|
43
|
+
jason json response: gcompute getproject --dump_request_response # or whatever
|
|
44
|
+
install: pip install https://dl.google.com/compute/gcutil.tar.gz
|
|
45
|
+
list images: gcutil listimages --project=projects/google
|
|
46
|
+
code snippets:
|
|
47
|
+
metadata: gcutil-test11 setcommoninstancemetadata --metadata foo:bar --metadata owner:riccardo --metadata data:$(data) -f --metadata perhosturl:http://www.palladius.eu/hosts/
|
|
48
|
+
kernels: gcutil --print_json --project=google listkernels
|
|
49
|
+
API info:
|
|
50
|
+
last version: 1.2
|
|
51
|
+
last release: 20120912
|
|
52
|
+
API version: v1beta12
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
commands:
|
|
2
|
+
adddisk: Create a new machine disk.
|
|
3
|
+
addfirewall: Create a new firewall.
|
|
4
|
+
addimage: Create a new machine image.
|
|
5
|
+
addinstance: Create a new machine instance.
|
|
6
|
+
addnetwork: Create a new network instance.
|
|
7
|
+
auth: Class for forcing client authorization.
|
|
8
|
+
deletedisk: Delete a machine disk.
|
|
9
|
+
deletefirewall: Delete a firewall.
|
|
10
|
+
deleteimage: Delete a machine image.
|
|
11
|
+
deleteinstance: Delete a machine instance.
|
|
12
|
+
deletenetwork: Delete a machine network.
|
|
13
|
+
deleteoperation: Delete an operation.
|
|
14
|
+
getdisk: Get a machine disk.
|
|
15
|
+
getfirewall: Get a firewall.
|
|
16
|
+
getimage: Get a machine image.
|
|
17
|
+
getinstance: Get a machine instance.
|
|
18
|
+
getkernel: Get a kernel.
|
|
19
|
+
getmachinetype: Get a machine type.
|
|
20
|
+
getnetwork: Get a network instance.
|
|
21
|
+
getoperation: Retrieve an operation resource.
|
|
22
|
+
getproject: Get the resource for a Google Compute project.
|
|
23
|
+
getzone: Get a zone.
|
|
24
|
+
#help: Help for all or selected command:
|
|
25
|
+
listdisks: List the machine disks for a project.
|
|
26
|
+
listfirewalls: List the firewalls for a project.
|
|
27
|
+
listimages: List the machine images for a project.
|
|
28
|
+
listinstances: List the machine instances for a project.
|
|
29
|
+
listkernels: List the machine kernels for a project.
|
|
30
|
+
listmachinetypes: List the machine types.
|
|
31
|
+
listnetworks: List the machine networks for a project.
|
|
32
|
+
listoperations: List the operations for a project.
|
|
33
|
+
listzones: List available zones.
|
|
34
|
+
pull: Pull one or more files from an instance.
|
|
35
|
+
push: Push one or more files to an instance.
|
|
36
|
+
setcommoninstancemetadata: Set the commonInstanceMetadata field for a Google
|
|
37
|
+
ssh: Ssh to an instance.
|
|
38
|
+
version: Get the current version of this command.
|
|
39
|
+
other:
|
|
40
|
+
cache project_id: gcompute getproject --project_id=<your_project_id> --cache_flag_values
|
|
41
|
+
browse gcompute code project (python): @shortcutme mate ~/Dropbox/.linux/git/gcompute-1.1.pre.20120507.1654
|
|
42
|
+
howto install: @shortcutme open https://developers.google.com/compute/docs/gcompute_setup
|
|
43
|
+
jason json response: gcompute getproject --dump_request_response # or whatever
|
|
44
|
+
install: pip install https://dl.google.com/compute/gcutil.tar.gz
|
|
45
|
+
list images: gcutil listimages --project=projects/google
|
|
46
|
+
code snippets:
|
|
47
|
+
metadata: gcutil-test11 setcommoninstancemetadata --metadata foo:bar --metadata owner:riccardo --metadata data:$(data) -f --metadata perhosturl:http://www.palladius.eu/hosts/
|
|
48
|
+
kernels: gcutil --print_json --project=google listkernels
|
|
49
|
+
API info:
|
|
50
|
+
last version: 1.2
|
|
51
|
+
last release: 20120912
|
|
52
|
+
API version: v1beta12
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
_conf:
|
|
2
|
+
colors:
|
|
3
|
+
title: white
|
|
4
|
+
line_key: red
|
|
5
|
+
line_val: lred
|
|
6
|
+
sort: false
|
|
7
|
+
mantain_crlf: true
|
|
8
|
+
Strings:
|
|
9
|
+
upper/lower case: UPCASE(), downcase, Capitalize, singularize/pluralize()
|
|
10
|
+
REGEX: "reads conf file, regex+memorize: subject = (/^Subject\: (.+)$/).match(email)[1]"
|
|
11
|
+
Arrays:
|
|
12
|
+
flatten: 'flattens [ [a,b],c] into [a,b,c]'
|
|
13
|
+
compact: removes nil (not to confuse with flatten)
|
|
14
|
+
include?: '%%w[ jan feb march].include?("feb") = true'
|
|
15
|
+
File and Directories:
|
|
16
|
+
glob: Dir.glob("config.?") #=> ["config.h"]
|
|
17
|
+
rails views:
|
|
18
|
+
ComboBox on model: ' collection_select("role", "user_id", User.find(:all, :order => "username") , :id, :username , :include_blank => true ) '
|
|
19
|
+
rails generators:
|
|
20
|
+
model: script/generate model user name:string hashed_password:string salt:string
|
|
21
|
+
scaffold: script/generate scaffold user name:string hashed_password:string salt:string
|
|
22
|
+
nifty auth: script/generate nifty_authentication --help (Ryan Bates awesome gem)
|
|
23
|
+
capistrano:
|
|
24
|
+
avanti: cap deploy
|
|
25
|
+
indietro: cap deploy:rollback
|
|
26
|
+
mine: cap ric (my stuff)
|
|
27
|
+
nullity:
|
|
28
|
+
'obj.nil?': dice se é nullo
|
|
29
|
+
'obj ||= "init"': per inizializzare un oggetto, se null va a INIT se no rimane se stesso...
|
|
30
|
+
Rake:
|
|
31
|
+
'rake -T': shows all rake helps
|
|
32
|
+
"rake db:migrate RAILS_ENV=production": run migrations (migrate DB) in production
|
|
33
|
+
"rake db:migrate:all": migrates all 3 envs
|
|
34
|
+
"rake db:rollback": back ONE step
|
|
35
|
+
"rake db:migrate:redo STEP=3": rolls back 3 migrations and executes them back :)
|
|
36
|
+
'rake routes': shows RESTful routes and stuff, very cool, i.e. safewatch 'rake routes|grep -i api |grep GET'
|
|
37
|
+
gems:
|
|
38
|
+
capistrano: for easy deploy
|
|
39
|
+
navigation_helper: Gem for navigation menu, http://github.com/rpheath/navigation_helper
|
|
40
|
+
problem w infinite stack: gem install roart --no-rdoc --no-ri # without documentation can work :)
|
|
41
|
+
watir install: "http://wiki.openqa.org/display/WTR/Install+Watir#InstallWatir-Mac"
|
|
42
|
+
watir on Mac:
|
|
43
|
+
- sudo gem update --system
|
|
44
|
+
- sudo gem install firewatir
|
|
45
|
+
- sudo gem install safariwatir"
|
|
46
|
+
yaml:
|
|
47
|
+
- require 'set'
|
|
48
|
+
- require 'yaml'
|
|
49
|
+
- "puts Set.new([1,2,3,4]).to_yaml"
|
|
50
|
+
- YAML.load_file('some.yml')
|
|
51
|
+
flow control:
|
|
52
|
+
switch case: |
|
|
53
|
+
See this:
|
|
54
|
+
case myvar
|
|
55
|
+
when 1..5
|
|
56
|
+
puts "Its between 1 and 5"
|
|
57
|
+
when 6
|
|
58
|
+
puts "Its 6"
|
|
59
|
+
when String
|
|
60
|
+
puts "You passed a string"
|
|
61
|
+
else
|
|
62
|
+
puts "You gave me #{a} -- I have no idea what to do with that."
|
|
63
|
+
end
|
|
64
|
+
heroku:
|
|
65
|
+
push/deploy: git push heroku master # push/deploy
|
|
66
|
+
remote rake action: "heroku rake db:migrate # executes rake remotely.."
|
|
67
|
+
Add to repo: "git remote add heroku git@heroku.com:APPNAME.git"
|
|
68
|
+
tricks n tips:
|
|
69
|
+
# On my Mac I have a lot of libs in 777 mode!!!
|
|
70
|
+
fix permissions: "find /usr/local/lib/ruby/ -type d -print0 | xargs -0 -s 1000 sudo chmod 755 "
|
|
71
|
+
rails server more clean: "rails server | egrep --line-buffered -v '^Rendered|Load \(' "
|
|
72
|
+
trace_vars: 'trace_var( :$_, proc{|v| pgray "$_ is now #{v}" }) # super cool!'
|
|
73
|
+
bugs yaml ruby193 in psych: require 'yaml'; YAML::ENGINE.yamler = 'syck'
|
|
74
|
+
Rails:
|
|
75
|
+
pkgs to make rails work: apt-get install libsqlite3-dev
|
|
76
|
+
camel: '"active_record".camelize => "ActiveRecord"'
|
|
77
|
+
tableize: '"RawScaledScorer".tableize => "raw_scaled_scorers"'
|
|
78
|
+
rvm:
|
|
79
|
+
_cheat: http://cheat.errtheblog.com/s/rvm/
|
|
80
|
+
nice commands:
|
|
81
|
+
- rvm use --default 1.9.3
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
sakura:
|
|
2
|
+
Synopsys: This is about my Sakura project, which is a Git repo freely available on github to
|
|
3
|
+
help people like you waste their time on funny scripts :) You can also create your own YAML
|
|
4
|
+
files if you put it in $SAKURADIR/doc/richelp/. For instance you could add your friends you
|
|
5
|
+
invited to a party and keep track of invitations, presences and absences and make stats over
|
|
6
|
+
them then.
|
|
7
|
+
samples:
|
|
8
|
+
'ls | act': 'randomly scrambles the lines! Taken from cat/cat ;)'
|
|
9
|
+
'ps | rainbow': 'colors all lines differently'
|
|
10
|
+
'twice itunes -': lowers volume of iTunes... twice :)
|
|
11
|
+
'10 echo Bart Simpson likes it DRY': tells you this 10 times. Very sarcastic script!
|
|
12
|
+
'seq 100 | 1suN 7': prints every 7th element of the list
|
|
13
|
+
zombies: 'prints processes that show zombies (plus funny options to kill them)'
|
|
14
|
+
'find . -size +300M | xargs mvto /tmp/bigfiles/': moves big files to that directory
|
|
15
|
+
"alias gp='never_as_root git pull'": only if u r not root it runs!
|
|
16
|
+
dimmiora: Tells you the time with Riccardo voice in Italian. Brilliant!
|
|
17
|
+
'echo $PATH | split': Splits path on ':'. Amazing innit?
|
|
18
|
+
richelp sakura: help to this one
|
|
19
|
+
richelp ubuntu: help on how to use Ubuntu
|
|
20
|
+
duplicates: finds file in the current subtree which are identical
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
_Common SQL: &COMMON_SQL_LABEL # dev'essere prima degli altri ma funge!
|
|
3
|
+
select: "SELECT * FROM clients WHERE id = 1 OR name LIKE '%riccardo%' ;"
|
|
4
|
+
INSERT: TODO
|
|
5
|
+
UPDATE: TODO
|
|
6
|
+
DELETE: TODO
|
|
7
|
+
mysql: # &MYSQL_LABEL
|
|
8
|
+
explain: EXPLAIN SELECT * from MYSQL_SOBENME ;
|
|
9
|
+
<<: *COMMON_SQL_LABEL
|
|
10
|
+
postgres:
|
|
11
|
+
<<: *COMMON_SQL_LABEL
|
|
12
|
+
explain: "Like MySQL but this is PostGre!"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
_conf:
|
|
2
|
+
colors:
|
|
3
|
+
title: brown
|
|
4
|
+
line_key: orange
|
|
5
|
+
line_val: gold
|
|
6
|
+
sort: false
|
|
7
|
+
Packets:
|
|
8
|
+
list: dpkg -l
|
|
9
|
+
installed?: "dpkg -L request-tracker3.8"
|
|
10
|
+
purge: dpkg -P <packet_to_be_purged>
|
|
11
|
+
quale pacchetto ha questo file: dpkg -S /usr/bin/scp
|
|
12
|
+
distro:
|
|
13
|
+
get current: lsb_release -a
|
|
14
|
+
upgrade:
|
|
15
|
+
- update-manager -d (graphical)
|
|
16
|
+
- do-release-upgrade -d (textual)
|
|
17
|
+
- requires sudo apt-get install update-manager-core
|
|
18
|
+
Debian:
|
|
19
|
+
ifdownup: 'sleep 5 | ifdown eth0 && ifup eth0'
|
|
20
|
+
remove everything with Graphics: apt-get --purge remove liborbit2
|
|
21
|
+
Gnome:
|
|
22
|
+
Torvalds suggests this: sudo apt-get install gnome-tweak-tool
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
various:
|
|
2
|
+
Synopsis: |
|
|
3
|
+
This is a test YML which preserves newline as they are.
|
|
4
|
+
Please take a look at this link where I borrowed part fo that code:
|
|
5
|
+
|
|
6
|
+
http://en.wikipedia.org/wiki/YAML#Lists
|
|
7
|
+
|
|
8
|
+
and let me know what you think.
|
|
9
|
+
Riccardo
|
|
10
|
+
date: 2012-11-25
|
|
11
|
+
tables and arrays:
|
|
12
|
+
table cars:
|
|
13
|
+
- &car1
|
|
14
|
+
make: Audi
|
|
15
|
+
model: A4
|
|
16
|
+
descr: Carina
|
|
17
|
+
- &car2
|
|
18
|
+
make: VolksWagen
|
|
19
|
+
model: GTI
|
|
20
|
+
descr: Sobenme
|
|
21
|
+
- &car_hiro
|
|
22
|
+
make: Nissan
|
|
23
|
+
model: Versa
|
|
24
|
+
descr: Macchina di Hiro&Ando
|
|
25
|
+
- &car_ric
|
|
26
|
+
make: Mercedes Benz
|
|
27
|
+
model: C180
|
|
28
|
+
descr: Macchina di Riccardo
|
|
29
|
+
Family (associative array): &family_riccardo
|
|
30
|
+
- {name: Ric, dob: 1976}
|
|
31
|
+
- {&mum name: Mum, dob: 1954}
|
|
32
|
+
- {name: Ele, dob: 1975}
|
|
33
|
+
favorite_car: *car_ric
|
|
34
|
+
favorite_person: *mum
|
|
35
|
+
YAML help:
|
|
36
|
+
cheatsheet: http://yaml.org/refcard.html
|
|
37
|
+
wikipedia: http://en.wikipedia.org/wiki/YAML
|
|
38
|
+
---
|
|
39
|
+
myObject: !myClass { name: Joe, age: 15 }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
various:
|
|
2
|
+
Synopsis: |
|
|
3
|
+
This is a test YML which preserves newline as they are.
|
|
4
|
+
Please take a look at this link where I borrowed part fo that code:
|
|
5
|
+
|
|
6
|
+
http://en.wikipedia.org/wiki/YAML#Lists
|
|
7
|
+
|
|
8
|
+
and let me know what you think.
|
|
9
|
+
Riccardo
|
|
10
|
+
date: 2012-11-25
|
|
11
|
+
tables and arrays:
|
|
12
|
+
table cars:
|
|
13
|
+
- &car1
|
|
14
|
+
make: Audi
|
|
15
|
+
model: A4
|
|
16
|
+
descr: Carina
|
|
17
|
+
- &car2
|
|
18
|
+
make: VolksWagen
|
|
19
|
+
model: GTI
|
|
20
|
+
descr: Sobenme
|
|
21
|
+
- &car_hiro
|
|
22
|
+
make: Nissan
|
|
23
|
+
model: Versa
|
|
24
|
+
descr: Macchina di Hiro&Ando
|
|
25
|
+
- &car_ric
|
|
26
|
+
make: Mercedes Benz
|
|
27
|
+
model: C180
|
|
28
|
+
descr: Macchina di Riccardo
|
|
29
|
+
Family (associative array): &family_riccardo
|
|
30
|
+
- {name: Ric, dob: 1976}
|
|
31
|
+
- {&mum name: Mum, dob: 1954}
|
|
32
|
+
- {name: Ele, dob: 1975}
|
|
33
|
+
favorite_car: *car_ric
|
|
34
|
+
favorite_person: *mum
|
|
35
|
+
YAML help:
|
|
36
|
+
cheatsheet: http://yaml.org/refcard.html
|
|
37
|
+
wikipedia: http://en.wikipedia.org/wiki/YAML
|
|
38
|
+
---
|
|
39
|
+
myObject: !myClass { name: Joe, age: 15 }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
hooks:
|
|
3
|
+
after_all:
|
|
4
|
+
- echo ciao
|
|
5
|
+
before_all:
|
|
6
|
+
- echo
|
|
7
|
+
templates: # TODO link me from programs
|
|
8
|
+
rtcommon: #&rtcommon
|
|
9
|
+
- pink "This is a common task for RT"
|
|
10
|
+
# This is the REAL configuration, per label.
|
|
11
|
+
sviluppanda: # here are the real confs!
|
|
12
|
+
ric:
|
|
13
|
+
- mate ~/svn/carlesso/.bashrc ~/svn/carlesso/.bashrc.hansel ~/svn/carlesso/.bashrc.slartibartfast.heanet.ie ~/svn/carlesso/.bashrc.`hostname` ~/svn/carlesso/.profile ~/svn/carlesso/bookmarks/ ~/svn/carlesso/.profile.`hostname` ~/svn/carlesso/.bashrc_* ~/svn/carlesso/lib/ ~/svn/carlesso/hosts/ ~/svn/carlesso/bin/ ~/svn/carlesso/doc/ ~/svn/carlesso/templates/ ~/svn/carlesso/etc/
|
|
14
|
+
- "iterm-session.scpt eccentrica"
|
|
15
|
+
riclife:
|
|
16
|
+
- mate ~/riclife
|
|
17
|
+
rt: *rtcommon
|
|
18
|
+
- iterma -- 'ssh lasagna tail -f /var/log/apache2/*.log'
|
|
19
|
+
- hwiki Ticketing Install
|
|
20
|
+
- open ~/Desktop/doc1.rtf
|
|
21
|
+
- open /Users/riccardo/Desktop/doc2.rtf
|
|
22
|
+
- h -m rt
|
|
23
|
+
- open ~/Dropbox/lavoro/
|
|
24
|
+
snippets:
|
|
25
|
+
AddressBookListPeople: echo osascript -e 'tell app "Address Book" to get the name of every person' | perl -pe 's/, /\n/g'
|
|
26
|
+
swdev:
|
|
27
|
+
- mate ~/swdev/lib/ ~/swdev/bin/
|
|
28
|
+
- open /Users/riccardo/Desktop/sysadmin.rtf
|
|
29
|
+
- "iterm-session.scpt devotchka"
|
|
30
|
+
- "iterm-session.scpt eccentrica"
|
|
31
|
+
test:
|
|
32
|
+
- verde ciao test devel
|
|
33
|
+
- ls -al
|
|
34
|
+
sakura:
|
|
35
|
+
- mate ~/git/sakura
|
|
36
|
+
- echo Please extend this yml in $SAKURADIR/etc/sakura/devel.yml
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# sample synergy configuration file
|
|
2
|
+
#
|
|
3
|
+
# comments begin with the # character and continue to the end of
|
|
4
|
+
# line. comments may appear anywhere the syntax permits.
|
|
5
|
+
|
|
6
|
+
section: screens
|
|
7
|
+
# three hosts named: moe, larry, and curly
|
|
8
|
+
moe:
|
|
9
|
+
larry:
|
|
10
|
+
curly:
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
section: links
|
|
14
|
+
# larry is to the right of moe and curly is above moe
|
|
15
|
+
moe:
|
|
16
|
+
right = larry
|
|
17
|
+
up = curly
|
|
18
|
+
|
|
19
|
+
# moe is to the left of larry and curly is above larry.
|
|
20
|
+
# note that curly is above both moe and larry and moe
|
|
21
|
+
# and larry have a symmetric connection (they're in
|
|
22
|
+
# opposite directions of each other).
|
|
23
|
+
larry:
|
|
24
|
+
left = moe
|
|
25
|
+
up = curly
|
|
26
|
+
|
|
27
|
+
# larry is below curly. if you move up from moe and then
|
|
28
|
+
# down, you'll end up on larry.
|
|
29
|
+
curly:
|
|
30
|
+
down = larry
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
section: aliases
|
|
34
|
+
# curly is also known as shemp
|
|
35
|
+
curly:
|
|
36
|
+
shemp
|
|
37
|
+
end
|
|
Binary file
|
data/images/google.jpg
ADDED
|
Binary file
|
|
Binary file
|
data/images/sakura.jpg
ADDED
|
Binary file
|
data/images/sakura2.jpg
ADDED
|
Binary file
|
data/init.rb
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Fake array of integers
|
|
4
|
+
#$arr_int = [10.5, 5.4, 40.3, 58.0, 9.9, 58.0 ]
|
|
5
|
+
|
|
6
|
+
# doppioni code: http://snippets.dzone.com/posts/show/3838
|
|
7
|
+
module Enumerable
|
|
8
|
+
def dups # pulito con solo elementi ALMENO doppi.
|
|
9
|
+
inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys
|
|
10
|
+
end
|
|
11
|
+
def dups_c # tutto l'arrai con doppioni e relativa cardinalita..
|
|
12
|
+
inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1 }
|
|
13
|
+
end
|
|
14
|
+
def dups_indices
|
|
15
|
+
(0...self.size).to_a - self.uniq.map{ |x| index(x) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
########################
|
|
21
|
+
# my personal Array powerup class
|
|
22
|
+
class Array
|
|
23
|
+
|
|
24
|
+
alias :to_s_according_to_ruby :to_s
|
|
25
|
+
|
|
26
|
+
def to_s
|
|
27
|
+
"[ #{join(', ').to_s} ]"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# naive removal of ARGV options :)
|
|
31
|
+
# ARGV: "-h -dn -aaa A B C" --> "A B C"
|
|
32
|
+
def remove_options
|
|
33
|
+
select{|x| ! x.match( /^-/ ) }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# EL should be an EXACT match, NOT a regex :(
|
|
37
|
+
def from(el)
|
|
38
|
+
return [] unless self.include?(el)
|
|
39
|
+
ix1 = self.index(el)
|
|
40
|
+
ix2 = self.length
|
|
41
|
+
self[ix1..ix2]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def to(el)
|
|
45
|
+
return [] unless self.include?(el)
|
|
46
|
+
ix2 = self.index(el)
|
|
47
|
+
self[0..ix2]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def from_to(el1,el2)
|
|
51
|
+
from(el1).to(el2)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# [1,2,3].join2('- ',"\n") => "- 1\n- 2\n- 3\n"
|
|
55
|
+
def join2(initial,final)
|
|
56
|
+
initial + self.join(final+initial) + final
|
|
57
|
+
end
|
|
58
|
+
def join3(initial="'",middle="', '",final="'")
|
|
59
|
+
initial.to_s + self.join(middle.to_s) + final.to_s
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def map_to_hash
|
|
63
|
+
map { |e| yield e }.inject({}) { |carry, e| carry.merge! e }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# it would be awesome with 'method_not_existent' to mark all the plurals into a singular call of the elements :)
|
|
67
|
+
def names
|
|
68
|
+
map{|x| x.name }
|
|
69
|
+
end
|
|
70
|
+
def quote(sep=nil)
|
|
71
|
+
map{|x| x.quote(sep) }
|
|
72
|
+
end
|
|
73
|
+
def double_quote()
|
|
74
|
+
map{|x| x.quote('"') }
|
|
75
|
+
end
|
|
76
|
+
def chomp_all
|
|
77
|
+
map{|x| x.chomp }
|
|
78
|
+
end
|
|
79
|
+
def match(regex)
|
|
80
|
+
each{|x|
|
|
81
|
+
ret = x.match(regex)
|
|
82
|
+
return ret if ret
|
|
83
|
+
}
|
|
84
|
+
return nil
|
|
85
|
+
end
|
|
86
|
+
alias :matches :match
|
|
87
|
+
|
|
88
|
+
# GREP
|
|
89
|
+
alias :contains :include?
|
|
90
|
+
alias :has :include?
|
|
91
|
+
|
|
92
|
+
def head
|
|
93
|
+
self[0] # raise if empty
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def tail # TBOPT
|
|
97
|
+
cp = Array.new(self)
|
|
98
|
+
cp.shift
|
|
99
|
+
return cp
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Math
|
|
103
|
+
def sum
|
|
104
|
+
ret = 0
|
|
105
|
+
self.each{ |el|
|
|
106
|
+
ret += el.to_f
|
|
107
|
+
}
|
|
108
|
+
ret
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def average
|
|
112
|
+
sum / size
|
|
113
|
+
end
|
|
114
|
+
alias :avg :average
|
|
115
|
+
|
|
116
|
+
def scalar_product(arr2)
|
|
117
|
+
# assert size must be the same
|
|
118
|
+
throw "must be same size (self: #{size}) / arg: #{arr2.size})!!!" if( size != arr2.size )
|
|
119
|
+
ret = 0.0
|
|
120
|
+
for i in (0..size)
|
|
121
|
+
deb "DEB #{self[i]} * #{arr2[i]}"
|
|
122
|
+
ret += ( self[i].to_f * arr2[i].to_f)
|
|
123
|
+
end
|
|
124
|
+
ret
|
|
125
|
+
end
|
|
126
|
+
alias :mul :scalar_product
|
|
127
|
+
|
|
128
|
+
def weighted_average(weights)
|
|
129
|
+
scalar_product(weights) / weights.sum
|
|
130
|
+
end
|
|
131
|
+
alias :wavg :weighted_average
|
|
132
|
+
|
|
133
|
+
def prepend(str)
|
|
134
|
+
map{|x| str+x}
|
|
135
|
+
end
|
|
136
|
+
def append(str)
|
|
137
|
+
map{|x| x+str}
|
|
138
|
+
end
|
|
139
|
+
def chop_all
|
|
140
|
+
map{|x| x.chop }
|
|
141
|
+
end
|
|
142
|
+
def trim_all
|
|
143
|
+
map{|x| x.trim }
|
|
144
|
+
end
|
|
145
|
+
def quote_all
|
|
146
|
+
map{|x| x.quote }
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# options:
|
|
150
|
+
# :first_line_as_title (make it bold)
|
|
151
|
+
# smart printf of an AoA like
|
|
152
|
+
# [[ title1, title2, title3],
|
|
153
|
+
# [ arg1 arg2 arg3 ]
|
|
154
|
+
# ....
|
|
155
|
+
# printf with perfect %10d length
|
|
156
|
+
def smart_printf(opts={})
|
|
157
|
+
printf_template = ''
|
|
158
|
+
# assret its a AoA
|
|
159
|
+
width=self[0].size
|
|
160
|
+
deb width
|
|
161
|
+
for k in (0 .. width-1) # { |k|
|
|
162
|
+
max = self.map{|line| line[k].to_s.length }.max
|
|
163
|
+
deb( [k, max].join(':'))
|
|
164
|
+
printf_template += "%-#{max}s "
|
|
165
|
+
end
|
|
166
|
+
printf_template += "\n"
|
|
167
|
+
deb("printf_template: #{printf_template}")
|
|
168
|
+
self.each{ |line|
|
|
169
|
+
puts( printf_template % line ) # [0], line[1]
|
|
170
|
+
}
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
#def prepend_all(str); map{|x| x.prepend(str) }; end
|
|
174
|
+
|
|
175
|
+
alias :trim :trim_all
|
|
176
|
+
# like UNIQ - C, returns uncity with cardinality into an elegant HASH :)
|
|
177
|
+
# sort is pointless
|
|
178
|
+
def uniq_c(min_cardinality = 1) # sort=false)
|
|
179
|
+
hash=Hash.new
|
|
180
|
+
self.map{|x| hash[x] = (hash[x] + 1) rescue 1 }
|
|
181
|
+
hash.select{|k,v| v >= min_cardinality}
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def color(regex, opts = {} )
|
|
185
|
+
opts[:color] ||= :red
|
|
186
|
+
map{|line|
|
|
187
|
+
line.gsub(regex) {|match|
|
|
188
|
+
match.color(opts[:color])
|
|
189
|
+
}
|
|
190
|
+
} rescue map{|line| line.gsub(/(b)/,green('b')) }
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# [1,2,3,4,5] => [1,2,3,4]
|
|
194
|
+
def remove_last
|
|
195
|
+
return self[0.. self.size-2 ]
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def egrep_v(regex)
|
|
199
|
+
select{|line| ! line.match(regex) }
|
|
200
|
+
end
|
|
201
|
+
def egrep(regex)
|
|
202
|
+
select{|line| line.match(regex) }
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# string must NOT contain //, i.e. 'goliardia' or "zuppa|pambagnato"
|
|
206
|
+
def evidenzia(string_or_array_or_regex, opts = {} )
|
|
207
|
+
opts[:color] ||= :yellow
|
|
208
|
+
color(autoregex(string_or_array_or_regex), opts)
|
|
209
|
+
end
|
|
210
|
+
# I could put it in Enumerable...
|
|
211
|
+
|
|
212
|
+
# find duplicates
|
|
213
|
+
# if count, does what uniq -c does (returns occurrences as well)
|
|
214
|
+
def duplicates(count = false)
|
|
215
|
+
count ? dups_c : dups
|
|
216
|
+
end
|
|
217
|
+
alias :doppioni :duplicates
|
|
218
|
+
|
|
219
|
+
# copiato da srtsolution.com/public/blog/250508
|
|
220
|
+
def method_missing(method_name, *args)
|
|
221
|
+
method_name = method_name.to_s
|
|
222
|
+
deb "Array.method_missing: called '#{method_name}' (class=#{method_name.class}) with args: #{ (args * ',') }"
|
|
223
|
+
if m = method_name.match( /^(.*)_all$/)
|
|
224
|
+
descr = "Calling on this array this function: " + white(" .map{|x| x.#{m[1]}(#{args.map{|x| x.to_s.quote}.join(', ')}) }")
|
|
225
|
+
deb descr
|
|
226
|
+
deb "DEB Figoso: I call #{m[1]} on the Array son, as an object, like obj.foo(args)"
|
|
227
|
+
return self.map{|x| x.send(m[1], *args ) }
|
|
228
|
+
end
|
|
229
|
+
if method_name =~ /^map_(.*)$/
|
|
230
|
+
deb "method_name matches map_SOMETHING!"
|
|
231
|
+
return self.map{|x| x.send($1, *args ) }
|
|
232
|
+
end
|
|
233
|
+
if method_name =~ /^(.*)s$/
|
|
234
|
+
pazure "Cool! Seems like you called a plural attribute over an array. It would be *SO* cool to call map.#{$1} but I dont trust myself enough, so its better that you use: #{green "map_#{$1}"}"
|
|
235
|
+
return super #return self.map{|x| x.send($1, *args ) }
|
|
236
|
+
end
|
|
237
|
+
return true
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# finds index of regex, to be sure I stringify everything
|
|
241
|
+
def index_regex(regex)
|
|
242
|
+
first_element = self.map{|x| x.to_s}.grep(regex).first
|
|
243
|
+
return index( first_element )
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
end #/Array
|