Uno scrittoio digitale …

2 agosto 2014

Screen

Archiviato in: linux — Tag:, — admin @ 16:37

do you remember …

Key Action Notes
Ctrl+a c new window  
Ctrl+a n next window I bind F12 to this
Ctrl+a p previous window I bind F11 to this
Ctrl+a “ select window from list I have window list in the status line
Ctrl+a Ctrl+a previous window viewed  
     
Ctrl+a S split terminal horizontally into regions Ctrl+a c to create new window there
Ctrl+a | split terminal vertically into regions Requires screen >= 4.1
Ctrl+a :resize resize region  
Ctrl+a :fit fit screen size to new terminal size Ctrl+a F is the same. Do after resizing xterm
Ctrl+a :remove remove region Ctrl+a X is the same
Ctrl+a tab Move to next region  
     
Ctrl+a d detach screen from terminal Start screen with -r option to reattach
Ctrl+a A set window title  
Ctrl+a x lock session Enter user password to unlock
Ctrl+a [ enter scrollback/copy mode Enter to start and end copy region. Ctrl+a ] to leave this mode
Ctrl+a ] paste buffer Supports pasting between windows
Ctrl+a > write paste buffer to file useful for copying between screens
Ctrl+a < read paste buffer from file useful for pasting between screens
     
Ctrl+a ? show key bindings/command names Note unbound commands only in man page
Ctrl+a : goto screen command prompt up shows last command entered

Reptyr

Archiviato in: linux, ubuntu — Tag:, — admin @ 13:07

Source code e doc disponibili su reptyr.
Lo scopo è permettere il riaggancio ad un processo avviato da un altro terminale.
Utile in quelle situazioni dove mi dimentico di avviare screen prima di avviare uno script … e poi voglio vedere il risultato da casa.

Reptyr usa ptrace per fare le sue magie.
Su Ubuntu la configurazione di ptrace è leggermente restrittiva:
è necessario modificare da root il file /etc/sysctl.d/10-ptrace.conf inserendo “kernel.yama.ptrace_scope = 0″
oppure per una modifica che sia solo temporanea basterà:
# echo 0 > /proc/sys/kernel/yama/ptrace_scope

27 luglio 2014

Cross-site request forgery

Archiviato in: sapere è potere, web — admin @ 11:39

XRSF

26 luglio 2014

Ruby and Rails

Archiviato in: Senza categoria — Tag:, — admin @ 08:15

Inizio a capirci qualcosa ed ho deciso di annotare qualche link veramente importante:

readruby.io
guides.rubyonrails.org
rspec.info
pryrepl.org

24 maggio 2014

gsh (run the same command on many linux server)

Archiviato in: linux — admin @ 09:44

go

31 marzo 2014

Eclipse Inside Proxy

Archiviato in: code, java — admin @ 21:37

Cosa è … e come si usa si trova QUI

2 febbraio 2014

Conversione file .nef in .jpg

Archiviato in: sapere è potere — Tag:, , — admin @ 13:56

semplice:

sudo apt-get install netpbm dcraw
for filename in *.nef ; do dcraw -c -w $filename | pnmtojpeg > $filename.jpg ; done
find . -name “*.nef” -exec rm -rf {} \;
rename ’s/\.nef.jpg$/.jpg/’ *.jpg

30 gennaio 2014

Java thread dump

Archiviato in: java, sapere è potere — admin @ 23:08

un paio di link da spulciare sul treno …

http://architects.dzone.com/articles/how-analyze-java-thread-dumps
mat
jhat
http://docs.oracle.com/javase/6/docs/technotes/tools/share/jmap.html

L’ultimo citato (jhat) è abbastanza instabile su grossi file … ma fà cmq il suo sporco lavoro
Il top è assolutamente mat (un tool stand-alone costruito sul framework di Eclipse)
La Oracle sponsorizza jmap … ma non ho avuto ancora il tempo di provarlo
Non dimentichiamo in ogni caso VisualVM … l’ho usato parecchio, ma le informazioni sono un pò nascoste

22 settembre 2013

java.util.concurrent.*

Archiviato in: java — admin @ 18:03

ho raccolto un pò di informazioni in un unico pdf (non esaustivo)

8 settembre 2013

Disabilitare Bios EFI on Asus K55V

Archiviato in: ubuntu — admin @ 11:12

Esc per accedere al Bios

Scheda Boot
> disabilitare il fast boot
> abilitare il csm
> disabilitare il security boot

30 agosto 2013

Zero-downtime Deployment (and Rollback) in Tomcat

Archiviato in: java, web — admin @ 23:03

deployare due o più versioni della stessa webapp ? … oh yeah (è possibile)
qua

17 luglio 2013

Web Resource Optimizer for Java

Archiviato in: java — Tag:, , , — admin @ 22:27

wro4j

ThreadLocal

Archiviato in: java, oracle — Tag:, , , — admin @ 22:22

The javadoc says this:

“Each thread holds an implicit reference to its copy of a thread-local variable as long as the thread is alive and the ThreadLocal instance is accessible; after a thread goes away, all of its copies of thread-local instances are subject to garbage collection (unless other references to these copies exist).

If your application or (if you are talking about request threads) container uses a thread pool that means that threads don’t die. If necessary, you would need to deal with the thread locals yourself. The only clean way to do this is to call the ThreadLocal.remove() method.

There are two reasons you might want to clean up thread locals for threads in a thread pool:

to prevent memory (or hypothetically resource) leaks, or
to prevent accidental leakage of information from one request to another via thread locals.

Thread local memory leaks should not normally be a major issue with bounded thread pools since any thread locals are likely to get overwritten eventually; i.e. when the thread is reused. However, if you make the mistake of creating a new ThreadLocal instances over and over again (instead of using a static variable to hold a singleton instance), the thread local values won’t get overwritten, and will accumulate in each thread’s threadlocals map. This could result in a serious leak.

private void cleanThreadLocals() {
        try {
            // Get a reference to the thread locals table of the current thread
            Thread thread = Thread.currentThread();
            Field threadLocalsField = Thread.class.getDeclaredField("threadLocals");
            threadLocalsField.setAccessible(true);
            Object threadLocalTable = threadLocalsField.get(thread);

            // Get a reference to the array holding the thread local variables inside the
            // ThreadLocalMap of the current thread
            Class threadLocalMapClass = Class.forName("java.lang.ThreadLocal$ThreadLocalMap");
            Field tableField = threadLocalMapClass.getDeclaredField("table");
            tableField.setAccessible(true);
            Object table = tableField.get(threadLocalTable);

            // The key to the ThreadLocalMap is a WeakReference object. The referent field of this object
            // is a reference to the actual ThreadLocal variable
            Field referentField = Reference.class.getDeclaredField("referent");
            referentField.setAccessible(true);

            for (int i=0; i < Array.getLength(table); i++) {
                // Each entry in the table array of ThreadLocalMap is an Entry object
                // representing the thread local reference and its value
                Object entry = Array.get(table, i);
                if (entry != null) {
                    // Get a reference to the thread local object and remove it from the table
                    ThreadLocal threadLocal = (ThreadLocal)referentField.get(entry);
                    threadLocal.remove();
                }
            }
        } catch(Exception e) {
            // We will tolerate an exception here and just log it
            throw new IllegalStateException(e);
        }
    }

A good place to do such cleanup is ServletRequestListener.requestDestroyed().

11 luglio 2013

codepen

Archiviato in: code, sapere è potere — admin @ 22:57

html … css … js framework … on codepen

Download Virtual Machine for IE Testing

Archiviato in: web — admin @ 22:54

testing webapp on IE … download vm machine from here

download-vms

3 giugno 2013

Da tenere sott’occhio

Archiviato in: code — admin @ 22:22

mapstruct
dagger

enjoy

18 maggio 2013

Embedded Linux System

Archiviato in: linux — Tag:, — admin @ 16:36

use Buildroot for exploit it

24 aprile 2013

Guidami quanto costa ?

Archiviato in: Senza categoria — admin @ 22:40

Prima app per android rilasciata con successo. E ci sono pure già due bug !!? (grazie ad Antonio e Giada)
Vabbè poteva andar peggio … come sempre i sorgenti sono reperibili su github … qua.

12

24 marzo 2013

JD Decompiler for Eclipse 4.2 Juno

Archiviato in: java, sapere è potere — admin @ 12:48

1) download zip da qa
2) Eclipse > Help > Install new software > Add > Archive … selezionando il file zip scaricato al passo precedente
3) Eclipse > Window > Preferences > General > Editors > File Associations … selezionando ‘Class File Editor’ sia per ‘.class’ che per ‘.class without source’
4) restart eclipse

4 marzo 2013

Il codice muta ed io lo eSeguo

Archiviato in: code, java — Tag:, — admin @ 22:53

pitest && stackoverflow.

Articoli precedenti »

Funziona con WordPress