Fedintegrazie

Ho appicciato il coso per seguire il blog da cose che usano activitypub (vedi mastodon &Co).

Link a lato.

Silence that switch

Some time ago I found a somewhat old Netgear Switch.

01_netgear_before

Nice!

  • 24 ports
  • 10/100/1000
  • Managed
  • Double SFP!

Well, the first port is broken :)
And it’s too loud! In our lab we have already a file server and an UPS, powered 24/7.

This is the fan that make so much noise:

02_internal1a

We need a solution to reduce the racket:

  • Reduce the RPM? No, someone told me that there won’t be enough air intake to cool down the heat sinks: those can be very hot!
  • Find another fan, same sizes but more quiet? I’ve could buy one, but we have plenty:

04_ventolame

  • Remove the original fan and apply some new tech :P
03_internal2

Fan, go home. You’re noisy.

 

05_twinfan

Old twin fans, I choose you!

 

06_concept1

This would be a nice mod

The old fan power source is about 5V, but I’ve chosen to not care much as long as the new fans move air.
Pros already love me!

Let’s begin with some tough work.

1. New holes on top

07_hardwork1

08_hardwork2

Metal is hard!

09_hardwork3

10_hardwork4

Done!

 

2. Mounting new fans and cabling

11_cables1

12_cables2

13_cables3

 

3. Results:

14_final1

Farewell nice logo!

15_final2

16_remains

 

Fooling rbash

$ echo $SHELL
/bin/rbash
$ /bin/ls
/bin/bash: line 2: /bin/ls: restricted: cannot specify `/' in command names
$ awk 'BEGIN{system("/bin/bash")}'
$ /bin/ls
foo bar misc
$ uname -rm
2.6.18-308.16.1.el5 i686
$ bash --version
GNU bash, version 3.2.25(1)-release (i386-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
$ awk --version
GNU Awk 3.1.5
Copyright (C) 1989, 1991-2005 Free Software Foundation.
$ exit
$ 

Emberjs on Debian

First, install nodejs and npm from repository.
Then:

sudo update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100
mkdir -p ~/.new-dir
npm config set prefix /path/to/.new-dir
npm install -g ember-cli
PATH="$PATH:/path/to/.new-dir/bin"

Export PATH variable in your bashrc to avoid retyping.
Test with:

ember -v

Best feature ever

dict_bestfeature

Best feature ever? Double dictionary check!
Now guess the program.

Stop piping like a Hippo

Oooooh:

$ cat list | grep some | awk '{print $1}'

Oh my god, 3 processes, we’re all gonna get a SIGKILL!
Then:

grep 'some' list | awk '{print $1}'

What? Not yet..

awk '/some/{print $1}' list

\é/

And I count my lines with:

grep -c 'some' list

instead of wced-greped-cated

A deeper `ls -l’

How nice:

$ alias dls='tree -phugsCD --du'

Add ‘-f’ for more fun!

(Other useful options: ‘-a’, ‘-x’, ‘-L <level>’, ‘- -sort=size’)

La vignetta senza confini

La vignetta[1] è assurda e troooppo grande per girarla tutta…
Forse l’artista pensava fosse cosa divertente!
A me non piace quando mi nascondono le cose. Così mi son messo e ho cercato di capire come funzionava il tutto.
Possibile ci sia un’immagine di fantastilioni di px tutta intera?
Come funziona il motorino per farmene vedere solo un pezzo? (bastardo)
Ma soprattutto, come faccio ad avere Il Tutto™ ?

La cosa è gestita in JavaScript + altro, credo, non ho studiato quindi non ci capisco quasi nulla: ci son due scriptini, ma io voglio la vignettona!

Entrando in dev-mode di Firefox o anche da page-info noto che tutta la vignetta è spezzata in tante sub-vignette (da 2048x2048px !!).
La cosa fantastica è che hanno nome-file con un senso, cioè il nome di ogni sub-vignetta è effettivamente una coordinata NSWE.
Urge disegnino.

Quindi conoscendo il valore degli estremi posso… *_*
Bash è mia amica:

#!/bin/bash

for ns in n s ; do
    for ew in e w ; do
        for ver in {1..20} ; do
            for hor in {1..50} ; do
                image="${ver}${ns}${hor}${ew}.png"
                if [[ ! -e "$image" ]] ; then 
                    #ranz=$[RANDOM/1000]
                    ranz=$(shuf -i 1-12 -n 1)
                    wget -q --user-agent="Mozilla/5.0 Firefox/10.0.1" http://imgs.xkcd.com/clickdrag/${image}
                    if [[ "$?" -eq "0" ]] ; then
                        echo -ne "${image}\tDONE!\t"
                    else
                        if [[ "$image" == *n*.png ]] ; then
                            cp white.png ${image}
                        else
                            cp black.png ${image}
                        fi
                        echo -ne "${image}\tCreated..."
                    fi
                    echo -e "\t(wait ${ranz}s)"
                    sleep ${ranz}
                else
                    echo -e "${image}\tAlready here..."
                fi
            done
        done
    done
done

  1. Sì, è brutto.
  2. Ho usato come limiti ’50’ in orizzonatale e ’20’ in verticale tanto per essere sicuro di prendere la grande fetta, i valori massimi che ho trovato sono ’48’ e ’18’, non so come fare per sapere i reali confini.
  3. $[RANDOM/1000] mi dava valori per la pausa tra una presa e l’altra troppo alti (fino a 32 sec). Recentemente ho trovato un Coreutils Cheat Sheet (catonmat.net), quindi scopro ‘shuf’.
  4. L’user agent è solo per bellezza, xkcd.com non fa controlli del genere a quanto pare (non nell’immediato).
  5. La condizionale per il ‘già qui’ è lì solo perché ho fatto molte prove.
  6. Il furbacchione non ha effettivamente messo quei tasselli tutti bianchi o tutti neri (qualcuno anzi sì). Quindi li creo io! (in base alla posizione N/S)
  7. Non si usa `ls’ a questo modo!

Adesso che ho tutti i tasselli della vignetta, devo semplicemente unirli per… erh… Uso ‘convert’ con spezie.
Creo tutte le strisce orizzontali:

for i in {1..20} ; do
  convert $( ls ${i}n*e.png | sort -V ) +append ${i}n_eF.png
  convert $( ls ${i}n*w.png | sort -Vr ) +append ${i}n_wF.png
  convert $( ls ${i}s*e.png | sort -V ) +append ${i}s_eF.png
  convert $( ls ${i}s*w.png | sort -Vr ) +append ${i}s_wF.png
done

Quindi le unisco in verticale e creo i quattro riquadri:

convert $( ls *n_eF.png | sort -Vr ) -append NE.png
convert $( ls *n_wF.png | sort -Vr ) -append NW.png
convert $( ls *s_eF.png | sort -V ) -append SE.png
convert $( ls *s_wF.png | sort -V ) -append SW.png

Unisco il tutto:

convert NW.png NE.png +append N.png
convert SW.png SE.png +append S.png
convert N.png S.png -append xkcd_1110.png

Mamma guarda ho fulminato il computer!

[1]XKCD #1110