skip to main | skip to sidebar

Sax Appeal

Musica e altro. (Musings about music and stuff.)


L'uso di questo sito
autorizza anche l'uso dei cookie
necessari al suo funzionamento.
(Altre informazioni)
Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Tuesday, October 25, 2016

Some basic IT types

A short, non-exhaustive list of basic types I met while working in IT.

The jobber, a.k.a "The reliable". Does what needs to be done, nothing more, nothing less. Seldom takes initiatives, and when he does, they're on the excruciatingly safe side. For instance, she may change a comment o clarify it. Because he does not care endless repetition of the same task, and is apparently impervious to boredom, he is often assigned to reporting, the printing subsystem, backups, and fixing the bugs nobody else has ever been able to reproduce. Infinitely useful in production. Gets scared if talked to abruptly, or too loudly.

"The visionary", a.k.a. "whizkid", "The maniac". Always getting up to speed on the latest technologies, harbors a deep disdain for anything that's been developed before than N years ago (N>0.5). Seldom seen installing software at the RC level, favors pre-alphas or nightly builds. For this reason, the machines he's been using for more than three days need to be reinstalled from scratche before they can be passed on. His projects, usually a wreck of failed dependencies from abandonware, do sometime evolve in the prototype of the next great product. Anyway, nobody can ever tell what the visionary's current project is about, because he  describes it in obscure utterances that Mr. Wolf (QV) himself takes a day to parse:

"My paradigm shifting, game changing idea is a Cordova project built with Bower and Grunt, of course I threw in Moustache for templating and Angular - Ionic, really - as a framework. It is nearly at the deploy stage, which will be in a microservices matrix on Digital Ocean created using Terraform and based on Kubernetes clustering technology". 

Should never be given checkin permission on official repositories.

Mr. Wolf a.k.a "I solve problems". An omnivorous reader, he is constantly reading up on everything, never really becoming a specialist of something. He solves problems that baffle most anyone, but he gets quickly bored and he's back on reddit or hacker news after delivering a three day "proof of concept solution" ("I'm sure the guys will figure out the details by themselves, better than I can"). Usually distant, aloof and detached, has a hard time switching contexts, and may dreamily remark "Oh, you talking to me? Would you remind repeating?" after ten minutes of being spoken to. Depending on his/her level of attention, he may answer in maddening monosyllables ("Do you know a solution for quantum gravity?" "Yes") or keep on talking for the balance of the afternoon. His code must be closely reviewed by The Jobber or by Auntie (QV) to tie up the hundreds of loose ends and missing details. On the other hand, one can converse with him about quantum physics or XV century Flemish waterpainters because "Good you mentioned it, I just read a few interesting things about this".

The Anal Retentive, a.k.a "Auntie". Fastidious in the extreme, the anal retentive is the universal source of overengineering. If a project has the dreaded "Are you sure that you are sure that you want to do this?" popup/feature, Auntie is invariably the author. Spends his/her free time dreaming up unforeseen actions users may engage in, and inventing ways to block them. His projects are the wet dream of bondage practitioners and the screaming nightmare of user support, flooded by phone calls of users unable to proceed past the welcome screen because "You do not have permission". When given a data model, Auntie releases a database in 13th normal form that nobody would be able to use, except it comes accompanied with 10,000 documented use cases. This way, when asked about the product, Auntie can roll up his eyes, sigh despiritedly, and say "It's all described in the use cases. Have'nt you read them?". A tireless worker, Auntie  is a useful, sometimes necessary presence. But he will drive you insane.

Elliott a.k.a. "The socially challenged". Has exchanged no more than four sentences with the co-workers since the day he arrived. His desk is cluttered with stacks of objects - manuals, electronic equipment, pizza cartons, cheese bagels in various stages of decay - which hide him from view. His hours are unpredictable, as proved by the fact that he answers email (if ever) at 3 AM. "I stopped using Tor long before the NSA thing, the level of privacy it offers is nothing less than laughable". His checkins are impeccable and his code brilliant, but everyone expects to see him hauled away by the Police any day.

The Ballast, a.k.a "The fish", "The idiot". Started dabbling in PHP at school, mixing html and code. Still does. If told "framework", The Ballast exhibits the blank stare of a mackerel confronted with a photo of the Large Hadron Collider. Persuaded that SQL injection is an intractable problem, was puzzled by the "Bobby Tables" cartoon and did not even smile at it. "I'd really like to read up and study, but what with all my day to day workload". This type is a catastrophe, but - being extremely cheap - it's always very well represented.

Mozart, a.k.a "The genius". Has deep knowledge of 14 programming languages and has written popular projects in all of them, as well as designing one of his own (due in the next ACM conference on languages). Mozart's github has 397 forks and 12000 yearly downloads. "Oh, no, I finished this weeks tests and checkins early Tuesday. This one is my weekend project." His resume lists stints at all the major industry outlets, and he sometimes drops lines like "...I know, this is something I must have tried to explain to Linus 100 times. At a minimum." , "Larry (Wall) and Guido (van Rossum) also chimed in, so yes,  all the old gang was there.". Never around for long.

"Been there, done that" a.k.a. "The veteran". "Yes, it is the same exact thing we used to do on the CDC Cyber 7600. Of course, today we have a different DCL and much more resources". Usually spotted among the sysadmins.

"The peripheral" a.k.a "Stressed out". Disillusioned by the core job (often because of a close cooperation with Auntie) has applied to QA or User Support, realizing too late of having fallen from the frying pan into the fire. Constantly confronted with the trivial ("Of course you have to turn the PC on") or the absurd ("I can assure you long term weather predictions were never a part of our inventory management software") he has developed brilliant evasive  tactics ("Did you upgrade the graphic card and mouse drivers, and applied all the OS updates? Get back to us when you are done" - "NOTABUG - WONTFIX"). Nevertheless, the job is taking its toll. Seen by the colleagues as a harbinger of bad news and as somebody out of the loop, is treated by them with condescending lines: "Of course a basic understanding of the technology is needed...". Usually resigns in two years.

"Bastard Operator From Hell", a.k.a "Herod". A school buddy of the founding partners, his authority is unassailable. Manages network security, resources and - often - telephony and has elected Argus Filch (the Hogswarth warden) as a role model.

"I cannot understand what use can you possibly have of print privileges."
"We were running low on space and, since you where not using it fully, I had your new 1TB disk replaced with a 500MB one. It's more reliable, and you can still use some space on the server."
"Of course we removed the network card and blocked all USB ports. The licensing machine has to be secure."
"WI-FI??????? You outta your mind kid??"

The Old Fart, a.k.a "The retiree".
    "You know, I never really got along with this OO fad."
CHAR(17) SURNAME
    GOTO LABEL019
    $ ed README
    "Was it on usenet?"
    "Mine is a lightweight site. It shines on lynx"
    "UTF?"
    "Zzzzzzzzzz...."

Posted by Sax Appeal at 5:22 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: programming

Monday, October 24, 2016

Alcuni tipi base in IT

Una lista, non esauriente, di alcuni tipi base di personalità che ho incontrato lavorando n campo informatico.

Lo sgobbone, ovvero "L'affidabile"": Fa quello che è necessario fare. Niente di più, niente di meno. Raramente prende iniziative, e quando lo fa, sono prudentissime, tipo rendere più chiaro un commento. Si aggiorna solo per quello che è necessario ai compiti che deve svolgere al momento. Poichè non gli pesa ripetere la stessa attività un numero arbitrario di volte ed è apparentemente incapace di annoiarsi, in genere gli vengono affibbiati i report, i sottosistemi di stampa, i backup e i bachi che nessun altro riesce a riprodurre. Utilissimo in produzione, basta non rivolgergli la parola troppo bruscamente o a voce troppo alta, che si spaventa.

Il visionario, ovvero "Il Ciappinaro": insegue costantemente l'ultima tecnologia, sdegna tutto quello che è stato fatto N anni fa (N>0.5). Di rado installa qualcosa che è allo stadio RC, preferisce le alpha release o i nightly build. Di conseguenza, le macchine che ha usato per più di tre giorni vanno reinstallate da zero prima di passarle ad altri. I suoi progetti naufragano miseramente in una jungla di dipendenze da abandonware oppure diventano il prototipo del prossimo prodotto di successo. Nessuno è in grado di dire esattamente su cosa stia lavorando, anche perchè descrive i suoi progetti con frasi criptiche che anche Mr. Wolf ci mette una giornata a decodificare.

"Si tratta di un progetto Phonegap che usa Bower e Grunt per il build, Moustache come sistema di template e Angular - Ionic, in realtà - per l'MVC. Presto farò un deploy di test in una matrice di microservizi su Digital Ocean usando Terraform, con una tecnolgia di clustering basata su Kubernetes.".

Da tenere alla catena, lontano dai repository ufficiali.

Mr.Wolf, ovvero "Risolvo problemi": Onnivoro, legge qualunque cosa e si aggiorna costantemente su tutto senza mai diventare specialista di quasi niente. "Risolve problemi" che lasciano perplessi tutti gli altri, ma dopo tre giorni si annoia, molla tutto e torna su redddit o hacker news.
Normalmente distratto, quando è assorto ha grandi difficoltà a cambiare contesto: capita di parlargli per dieci minuti prima che dica, con tono sognante "Ah, ma parlavi con me? Ti dispiace ripetere?". A seconda del livello di attenzione in cui si trova, può dare risposte monosillabiche alla Clouseau ("Sai se sia possibile quantizzare la gravità?" "Sì") o parlare per un pomeriggio intero.
Il codice che sviluppa dev'essere ripassato da uno sgobbone o da Zietta per mettere a posto i diecimila dettagli che mancano. In compenso ci si può parlare anche di meccanica quantistica e degli acquarellisti fiamminghi del '400, perchè "ha letto alcune cose al proposito".

anal retentive, ovvero "Zietta": Ossessivamente pignolo, è quello che introduce l'overengineering nei progetti. Se in un progetto esiste il popup "Sei sicuro di essere sicuro di voler fare X?", l'ha fatto lui. Passa il tempo libero a immaginare azioni impreviste che gli utenti potrebbero intraprendere e ad almanaccare modi per vietarle. I suoi progetti sono il sogno di un appassionato di bondage, e l'incubo dello user support che è bombardato di telefonate di utenti impastoiati nella schermata iniziale perchè "non hanno i permessi adeguati". Se gli si dà un data model, svilupperà un database in 13a forma normale, che nessuno sarebbe in grado di usare, se non fosse che ha anche simultaneamente prodotto 13,000 pagine di use cases, in modo che tutte le volte che qualcuno gli chiede qualcosa sul suo prodotto può rispondere (sospirando) "E' tutto negli use cases. Non li hai letti?". Lavoratore instancabile, è una presenza utile e perfino necessaria. Ma ti tira scemo.

Elliot, ovvero "L'asociale": da quando è stato assunto non ha scambiato più di otto parole con nessuno. La sua scrivania è costantemente coperta da alte pile di oggetti di varia natura (manuali, schede elettroniche, cartoni di pizza, panini dimenticati in vari stadi di decomposizione) che lo nascondono alla vista. Fa orari imprevedibili e risponde alle email (se risponde) alle tre di notte. Dice cose del tipo "Ho smesso di usare Tor, perchè le garanzie di privacy che offre sono risibili.". I suoi checkin sono impeccabili, il suo codice brillante, ma tutti si aspettano che prima o poi i carabinieri arrivino e lo portino via.

Il peso morto, ovvero "Il programmatroto": ha imparato a scrivere un po' di php quando studiava, mischiando html e codice. Continua a farlo. Se gli dici "framework" nei suoi occhi compare l'espressione perplessa che ha uno sgombro davanti alla fotografia del Large Hadron Collider di Ginevra. E' convinto che la SQL injection sia un problema insormontabile: quando ha visto il cartoon di Bobby Tables, non ha neanche sorriso. "Eh, mi piacerebbe aggiornarmi, ma il lavoro è sempre troppo". E' una sciagura, ma siccome è molto economico, è numericamente dominante.

Mozart, ovvero "Il genio": conosce in profondità 14 linguaggi di programmazione, e ha fatto progetti importanti e popolari con quasi tutti. Il suo github ha 12000 download e 345 fork. "Ah, no, i test e i checkin della settimana li ho finiti Martedì. Questo è il mio progetto del weekend". Ogni tanto dice cose come "...avrò cercato di spiegarlo a Linus 100 volte". Non si riesce mai a tenerlo per molto.

Been there, done that, ovvero "Il veterano": "Sì, è esattamente la stessa cosa che facevamo sempre sui Cyber CDC 7600, ma naturalmente oggi abbiamo un altro DCL e molte più risorse." Spesso avvistato tra i sysadmin.

Il periferico, ovvero "Lo stressato": deluso dallo sviluppo (spesso per il burnout derivato dalla collaborazione con Zietta) si è fatto assegnare al QA o allo User Support senza capire di essere caduto dalla padella nella brace.
Bombardato da richieste banali ("Certo che deve accendere la macchina") o assurde ("Ne sono sicuro, le previsioni meteorologiche di medio periodo non fanno parte del nostro software di magazzino"), ha sviluppato brillanti strategie evasive ("Ma prima che cominciamo, ha aggiornato il firmware, il driver della scheda grafica e quello del mouse? Ritelefoni quando l'ha fatto" - "NOTABUG. WONTFIX"). Però, lo stress si vede.
I colleghi lo considerano un messaggero di sventure e uno fuori dal giro e gli dicono cose del tipo "Certo, se non sei aggiornato o non capisci la tecnologia di base...". In genere si licenzia dopo un paio d'anni.


Bastard Operator From Hell, ovvero "Erode": Inamovibile per essere andato a scuola coi soci fondatori, è responsabile della sicurezza di rete, delle risorse e (spesso) della telefonia. Ha eletto a suo modello caratteriale Argus Filch, il guardiano di Hogswarth.

"Non capisco a cosa possono servirti i privilegi di stampa."
"Eravamo a corto di spazio e, visto che non lo usavi tutto, ho fatto sostituire il disco da 1TB della tua macchina con uno da 500MB. Fra l'altro è più affidabile, e puoi sempre usare i dischi del server."
"Certo che abbiamo tolto le schede di rete e disabilitato le porte usb. La macchina del licensing deve essere sicura, o no?"
"WI-FI????????????? Sei impazzito?"


The old fart, ovvero "Il pensionato":

    "Mah, io 'sta moda dell'Object Oriented..."
    CHAR(23) COGNOME
    GOTO LABEL019
    $ ed README
    "L' hai letto su usenet?"
    "Il mio è un sito web leggerissimo, che si vede bene anche su lynx"
    "UTF?"
    "Zzzzzzzzzz...."

Posted by Sax Appeal at 3:20 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: programming

Friday, May 13, 2016

Support Ticket #131313

Ticket #131313

Ciao Arturo,

invio in allegato alla presente la segnalazione del collega.
Ti prego di verificare e tenermi aggiornato riguardo alla risoluzione 
del problema.

Saluti e grazie
Paolo

--[Visualizza allegati email.pdf]

(Nota Bene: email con allegato PDF contenente messaggio email. Almeno non è word, Ndr)

Ogetto: Sito Web
Mittente: Troto Programma

Ciao,
Ho notato questo fine settimana, ma non so da quanto tempo c'è il problema (WAY TO GO! Ndr), che il sito non visualizza correttamente la parte destra della home.

Puntando su un problema di compatibiltà/contenuti inseriti,ho colto l'occasione di aggiornare (naturalmente sul sito di produzione, Ndr) 22 plugin e tutto l'ambiente di Wordpress (Già che c'eri potevi aggiornare anche il firmware ed il cabinet, Ndr).

Purtroppo il problema non si è risolto (Mission Accomplished, Ndr), ma nel frattempo ne è apparso un altro (Cioè: "ho creato un altro problema, più grave, e ora il sito è completamente rotto". Strano. Ndr) Sarebbe necessario comunicare a $DittaCheCollaboraConVoi la seguente esigenza:

"Occorre aggiornare la versione di PHP dall'attuale a 5.6.x"

Grazie,
Troto

P.S. Se a $DittaCheCollaboraConVoi servono maggiori dettagli sono a disposizione. (No grazie, se stai fermo è già un aiuto prezioso. Ndr)

-----

Heavy drinking intensifies.

Posted by Sax Appeal at 10:59 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: programming, user support

Friday, April 8, 2016

Simpler? No, just dumber. On language.

So Morten Just wrote a text editor/word processor that requires its owner to use words taken from the 1000 most commonly used English words, based on the Einstein-attributed quote

"If you can’t explain it to a six-year-old, you don’t understand it yourself"

(By the way, do you spot the misunderstanding of the quote? It states that you must be able to explain it to a six year old, not that you should always express yourself that way)

And Morten was surprised by the negative reactions of some of the public, as he explains in this post.

I just had to take exception, and did it in the reply that follows.

No, sorry, I cannot agree. I do concur that one should express his ideas in the simplest possible way —  but not any simpler, lest the ideas get distorted.

Besides, I think simplicity is a feat one should achieve because he thinks about it — not because it’s been given a crippled tool that forces its owner to do strange stuff. In a way, that (leaving stuff out of a tool because you don’t believe in, or know about, it) is a typical approach of some brand of software design — the email application that assumes that your username will always be equal to your email address, last sighted on windows, is an example.

Not to mention the many fields of endeavour where the original Einstein’s quote is, quite simply, bullshit. Art prose. Poetry. “Serendipity”. Formulating  the sentence “Swift is a Multi-paradigm (Protocol-oriented, object-oriented, functional, imperative, block structured) programming language” without bizarrely contorted and extended paraphrases (which I should be probably expressing as “weirdly restating its meaning using other words in much longer sentences” — see?). This happens because unusual words (especially when domain specific) synthesize required prior knowledge that would make expression unbearably long winded without making it any simpler, or clearer. Einstein himself wrote “covariant bidimensional tensor” when needed — how does that come out under the 1000 words rule?

Also, I find the idea that simple words enable clear expression incredibly naive — germane to the idea that good coding style is a feature of the programming language, rather than the programmer’s. Confused thought breeds confused and confusing expression, vocabulary breadth notwithstanding. (See Gargantua and Pantagruel for amusing examples)

Does all this amount to make your editor a tool apt to “dumbing down” (rather than simplifyng) communication? Yes, I am afraid it does.

And one last point. English (my second language) has accepted into its fold words that come from many other tongues: latin, french, german, indian, native american. The subset of english words that are familiar to— and therefore immediatley usable by — an Italian is widely different from the one a German — or a Jamaican —  would recognise. I have the idea that this alluring diversity within linguistic unity fares rather poorly under 1,000 words rule.

And I really loved what Brian Luff said (same thread):

"... although Orwell may have said

Never use a long word when a short one will do

he clearly did not mean
Never use a long word.
As far as I know, he never said
Why use a long word when you can use a lot of short ones instead?
How many short words would I need in order to suggest that your premise is an absurd extrapolation?"
Posted by Sax Appeal at 10:10 AM 2 comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: language, programming

Friday, July 31, 2015

Efficient CKeditor tabbing with bootstrap and jquery

The Problem


Ok, so you are back in web coding and want to add the nifty CKeditor to your site, so some admin will be edit to add, say descriptions or notes in crisp, nicely formatted HTML (or maybe crufty, luridly formatted HTML - it really makes no difference).

More than that, you need to do that in a form, want to keep your elements as textareas, and you need more than one editor - in fact, you want one per language on a multilanguage site. Also you would like to keep not in use editors tucked away from view.

So you gather a tabbing widget, put textareas where they belong, deploy your editors in their place (no, not going into details here, but they will be shown momentarily).

And behold! Everything is painfully slow, even  with a paltry 4 editors on your page (four europeans languages, is that asking too much?). Ouch.

The idea. The recipe

Of course, what's needed is:
  • lazy creation of the editors
This is OK, since most of them are already out of view when the page starts up - that's because we're tabbing, remember?

This also means that the admirably short:

$('textarea').ckeditor()

provided by CKeditor's jquery plugin won't cut it, as it will do everything at once, and your page will pop back up to consciousness only after it's finished - several seconds later.

This is not enough, however. CKeditor's 'classic' view, sitting in its own iframe, is quite hefty in itself - and even with lazy instantiation, mapping the GUI takes forever. So I'll also need:

  • CKeditor inline editing
That's lingo meaning that CKeditor will be attached to an element until it is clicked, when it springs into existence. That turns out to be much lighter.

CKeditor will inline a lot of elements which set the HTML5 attribute contenteditable to true - DIVs, notably .  I am an old timer, however, and I want this to happen in a form's textarea, so I can enjoy the automatic variable population that happens when my little lusers hit the "Submit" button. (Aside: can this also be made to happen with DIVs, I wonder? Comment if you know it.)

Critically, CKeditor allows to do inline on textareas  since V4.2. And this is another reason why the jquery plugin for CKeditor cannot be used - its .ckeditor() method appears to force 'classic' view on textareas (a feature request that appears to be promising on the CK's blog gave me no joy whatsoever).

What else? Oh, right, I'm gonna need

  • a good tabbing widget
unless, that is, one wants to do the  click-hide-show wiring and dance by hand. (Which I did, on first iteration. Darn me, for not knowing my manuals - but I'm old, did I already mention it? So never mind me). Not to worry, bootstrap (which makes everything oh, so 2.0 not to mention, responsive) has a perfectly fine tabbing widget camped on an appropriatedly marked up UL section. Be sure to read up on it carefully, or you will be liable to miss (as I did) the critical part on javascript plumbing that makes  the tabbing automatic.

And because it's bootstrap, and 2015 to boot,  I'm going to spruce it all up by adding:

  • jquery and its event wiring
to the mix - after all, bootstrap needs jquery, and will everybody wanting to do browser sniffing  on their own please raise their hands? I thought so. Which of course also implies we will want a last ingredient:

  •   a modern, html5 compliant browser
anything above IE8 will do, but surely you have that - you are not still supporting IE6 and Netscape 4.7, are you? Or, God forbid, IE7.

And voilà. Sounds easy? It's not.

The reasearch

And so, google and stackoverflow to the rescue, you start looking for the solution's pieces, and put them together , and it takes a day or more. Unless of course you stumbled on this page, where I laid it all down for you, my trusty reader. (It took more than a day, thank you very much - show your gratitude by sending money - lots  of it - in a stamped envelope. Yes, I'm that greedy.)

The execution

Markup: the header



<!DOCTYPE html>
<html>
<head>
 <meta charset="utf-8">
 <title>CKEditor ALF</title>
 <link href="/core/jquery-ui-1.11.4/jquery-ui.min.css" rel="stylesheet" type="text/css">
 <script type="text/javascript" src="/core/jquery/jquery-1.11.1.min.js"></script>
 <script type="text/javascript" src="/core/jquery-ui-1.11.4/jquery-ui.min.js"></script>

 <!-- Bootstrap -->
 <script type="text/javascript" src="/core/bootstrap/js/bootstrap.min.js"></script>

 <!-- Bootstrap core CSS -->
 <link href="/core/bootstrap/css/bootstrap.min.css" rel="stylesheet">
 <!-- Optional Bootstrap Theme -->
 <link data-href="/core/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" id="bs-theme-stylesheet">
 <script src="../ckeditor.js"></script><!-- the editor -->
 <script type="text/javascript" src="../adapters/jquery.js"></script>
 <script src="tab4.js"></script>
</head>


Here I'm pulling all of my ingredients - plus  my own code - on board, html5-style.
Not much to see, here - we're loading the CKeditor jquery plugin for the heck of it, since we are not going to use it.

Markup: the body


<body id="main">
  <div style="width:100%; height:400px; border: 3px solid red;">
    <!--First tabset -->
    <ul class="nav nav-tabs">
      <li><a data-target="#oita" data-toggle="tab" class="editor">Italiano</a></li>
      <li><a data-target="#oeng" data-toggle="tab" class="editor">English</a></li>
      <li><a data-target="#oesp" data-toggle="tab" class="editor">Spagnolo</a></li>
      <li><a data-target="#odeu" data-toggle="tab" class="editor">Deutsch</a></li>
    </ul>
    <span style="border:3px solid #0f0;">Seleziona il testo per editare</span>
    <div class="tab-content" style="box-shadow: inset 0 0 10px #999999;border:3px solid yellow;" >
      
      <div id="oita" class="tab-pane" style="height:300px"><textarea id="ita" name="ita">Ciao!</textarea></div>
      <div id="oeng" class="tab-pane" style="height:300px"><textarea id="eng" name="eng"><i>Hello!</i></textarea></div>
      <div id="oesp" class="tab-pane" style="height:300px"><textarea id="esp" name="esp"><b>Hola!</b></textarea></div>
      <div id="odeu" class="tab-pane" style="height:300px"><textarea id="deu" name="deu"><b>Guten tag!</b></textarea></div>
      
    </div>
  </div>
</body>
</html>


The meat and potato of the UI, these is textbook stile bootstrap JS tabbing, with all its data-xxx thingies wired up just right. I am also adding an 'editor' class to seize upon later with a jquery selector, and a few containers and visual cues that will tell the user that yes - click the text and editing will happen.

Javascript: the wiring

It is now time to sprinkle our  jquery magic ppowder, tucked away in tab4.js (yes, the fourth iteration):

$(document).ready( function() {    
    CKEDITOR.config.height = 150;
    CKEDITOR.config.width = 'auto';
  $('.editor').on('shown.bs.tab', function (e) {
 var target = $($(this).data("target"));
 target.find('textarea').each(function () {
     if(!CKEDITOR.instances[this.id]) {
  CKEDITOR.inline(this);
     }
 });
 return 1;
    });
});


A bit of explanation is in order, here.

  1. $(document).ready(): wrap everyhting inside this. No need to worry, I can register as many ready- handlers as you like and they will fire on a first-defined, first-served basis.
  2.  $('.editor'): seize the editor-classed elements . These are the anchors that compose the links on the tabs
  3. .on('shown.bs.tab', function (e) {:  attach a callback to the "expose" event . the funky event name took me forever to locate
  4. $($(this).data("target")): select the target that will be exposed (it is one of the divs, see markup). Is this syntax bit ugly, or what?
  5. target.find('textarea').each(function () {: iterate on the descended textares (better have one per container, or there goes  your efficiencies
  6. if(!CKEDITOR.instances[this.id]) { CKEDITOR.inline(this): if it does not already contain an editor, create it.
Six easy pieces.

Catharsis

And there you have it. Efficient CKeditor tabbing
Posted by Sax Appeal at 10:01 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: bootstrap, CKeditor, jquery, programming

Friday, August 8, 2014

A simple command line remainder, for the linux GUI

One of the first exercises of the Unix (then: Linux) books of yore was using the "at" command to create reminders (or, alarms). If memory serves, it went like this:

$ echo "echo \"Go home!\" > /dev/tty " | at 17:00

Because this is way too much typing, you were then taught how to plop it in a /usr/local/bin script:

alarm.sh:

       #!/bin/sh
       echo "echo \"$1\" > /dev/tty" |  at $2

Those were the tty days. Enter the GUI (or, even, multiple terminals) and your nifty alarm utility does not cut it any more, essentially because you're not usually looking at the right window when the alarm is echoed. Using xdialog or knotify in place of echo does not cut it either, as both rely on being able to connect to the X display (which they cannot do, because they are activated by atd outside the current desktop session).

Of course there must be thousands of fancy reminder/alarm apps from the desktop to the web-based, but none (that I could find) that'd allow me to set a simple reminder by typing it in the terminal I happen to have my focus on.

Enter libnotify and its command line minion notify-send:

alarm.sh:

#!/bin/bash

TITLE=$3
[[ x$TITLE == x ]] && TITLE="Sveglia!!!!"
echo /usr/bin/notify-send  -u critical  \"$TITLE\" \"$2\"\
 |at -m "$1"

And then:

$ alarm.sh 13:00 "Aren't you hungry?" "Lunch time" 

The -m switch tells at to send you mail when it fires  - Fedora pre 20 users may want to take notice of this bug report and compensate accordingly. Of course, the atd service must be running for this to work.
Posted by Sax Appeal at 9:57 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: CLI, coding, command line, linux, programming

Tuesday, June 17, 2014

Running Django scripts from the CLI (Command Line Interface)

Like many frameworks embedding an ORM, Django offers an attractive SQL-less interface to your DBMS, whose worth transcends its usefulness in the traditional web interface.

Which one do you like better:

SELECT n.name m.type FROM nodes n, model m WHERE n.mid=m.id AND m.make='Qfwfq';


or

them=Node.objects.filter(model__name='Qfwfq')
for q in them:
 ...

Yes, I thought so.

However, python's inclusion rules combine with Django's deployment rules to make writing general scripts of this sort a little awkward. The problem is that, for the above goodies to work, all of the django instrumentation surrounding your app has to be available to the python interpreter, a job that is usually taken up by manage.py when invoked from the deployment folder.  That is the effect we want to achieve within our own scripts.

After some mulling, this is what i came up with:


#!/usr/bin/python
#File: prologue.py
import os
import sys
#assumes we are in DJANGO_DIR/sbin
#find our own location
_pdir=os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
#find DJANGO_DIR
_cdir=os.path.dirname(_pdir)
#prepend to include path
sys.path.insert(0,_cdir)
#tell django where settings.py is
os.environ['DJANGO_SETTINGS_MODULE']='settings'


I keep all the django related scripts in a sbin/ subdirectory of the directory where manage.py is located and they all start with:

#!/usr/bin/python
import prologue


Obviously, prologue.py must live in the same folder. I then symlink them to somewhere in system's $PATH (that's usually /usr/local/bin).

This way, every script will get the correct sys.path and the right DJANGO_SETTINGS_MODULE from prologue.py; prologue.py is always found because it's in the same path as the script. The abspath(realpath()) incantation does away with finding the actual path of the prologue.py file under symlinks and other surprises.

Some folks may prefer inserting at the end of, rather then in front of, sys.path. They should use sys.path.append(_cdir).

Et voilà.


Edit:
Discussions on reddit on this this topic prompted me to clarify the purpose a bit.

The whole gist of all this is the toolification  of Django. This does not (solely) mean being able to type django commands from the (Linux) command line (though that is nice, too). It  rather means creating scripts that can then be used by other tools, without needing to know where the particular Django app lives, not even within the script code. (Picture wanting to relocate your django app to some other folder.)

This is why the execfile('myfile.py') feature of manage.py is not relevant in this context, nor is the possibility of adding commands to manage.py via the management commands feature of Django: in both instances, one has to run the correct manage.py, which lives in the app dir hierarchy. The django-extensions package, which allows to run jobs from manage.py, succumbs to the same objection here (at least, I suppose: I haven't reaaly looked extensively into django-extensions, though I will as it looks pretty cool in its own right).
Posted by Sax Appeal at 10:11 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: CLI, django, programming, python

Tuesday, June 3, 2014

Glossario per programmatori



Come accade in tutte le professioni, anche la programmazione ha il suo gergo, espressioni comuni che assumono un significato tecnico a seconda del contesto in cui sono espresse. Di seguito alcuni esempi.(Fonte: the internet)



  • Originale:   Questo va risolto in user support 
    Traduzione:  Non ho idea di come risolvere il problema.
  • Originale:   E' sottospecificato
    Traduzione:  Non ho idea di come risolvere il problema.
  • Originale:   E' stato scritto secondo le specifiche
    Traduzione:  Non ho idea di come risolvere il problema.
  • Originale:   NOTABUG/WONTFIX
  • Traduzione:  Non ho idea di come risolvere il problema.
  • Originale:   Orribile accrocchio 
    Traduzione:  Chi ha scritto questo orribile accrocchio? 
  • Originale:   Soluzione temporanea 
    Traduzione:  Sì, l'ho scritto io, questo orribile accrocchio
  • Originale:   E' rotto 
    Traduzione:  Ci sono bachi nel tuo codice.
  • Originale:   Va perfezionato 
    Traduzione:  Ci sono bachi nel mio codice.
     

  • Originale:  
    Oscuro/Incomprensibile
    Traduzione:  Questo codice è privo di commenti
  • Originale:   Auto documentante 
    Traduzione:  
    Il mio codice è privo di commenti
  • Originale:   Ecco perché è un linguaggio imbattibile!
    Traduzione:  Facile da fare nel mio linguaggio preferito
  • Originale:   Non stai inquadrando correttamente il problema
    Traduzione:  Impossibile da fare nel 
    mio linguaggio preferito
  • Originale:   Mal Strutturato
    Traduzione:  Il tuo codice è mal organizzato
  • Originale:   Ha una struttura complessa
    Traduzione:  
    Il mio codice è mal organizzato
  • Originale:   Carenza
    Traduzione:  Questa feature manca, e a me piace
  • Originale:   Fuori specifica
    Traduzione:  
    Questa feature manca, e non m'interessa
  • Originale:   Un soluzione ottimale
    Traduzione:  Funziona e lo capisco
  • Originale:   Va riscritto
    Traduzione:  
    Funziona, ma non lo capisco
  • Originale:   vi è meglio di emacs
    Traduzione:  Ho voglia di litigare
  • Originale:   emacs è meglio di vi
    Traduzione:  
    Ho voglia di litigare
  • Originale:   IMHO
    Traduzione:  Ho ragione io.
  • Originale:   Codice legacy
    Traduzione:  
    Funziona, ma nessuno sa perchè
  • Originale:   ^X^Cquit^Zfg%^Y^D
    Traduzione:  Come ç@330 si esce da vi?
Posted by Sax Appeal at 9:43 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: humor, programming

Wednesday, April 23, 2014

Admin password generation for phplist3

In phplist, starting (at least) with  version 3 admin passwords are stored as hashed values. The hashing technique is specified in phplist's config file:

define("ENCRYPTION_ALGO",'sha256');

Here the default algorithm is sha256 (but others, such as md5 or sha512 could be used). Because mysql does not offer all of these as builtins, something is needed to generate this value as a useful  way to reset admin passwords, when they are lost/forgotten (which is every time they are needed).

Google, was not helping, so I rolled my own.

A php script containing something along the lines of:

print hash('sha256',$PWD)."\n";

would suffice, but I am more adept at bash scripting. My effort is listed below. Please note:

  1. Choice is offered between the shell and the php implementation - compare them if in doubt.
  2. Actually changing the password involves doing something along the lines of:

    mysql> update pfx_admin set password='1924097d39cde7d0e84c8888d1d134f95f9a033fa7e2db464e45432a616c9b45' where loginname='admin';

    at the  mysql propmt or moral equivalent. Change pfx and admin to match your installation and needs.
  3. phplist uses no password salting.


#!/bin/bash

ALGO=sha256
SUM=/usr/bin/sha256sum

ver=0.1
author="Alessandro Forghieri "
usage () {
 name=`basename $0`
 echo "$name $ver $author"
 echo
 echo "Usage: $name [-a md5|sha1|sha224|sha256|sha384|sha512] [-p] [-v] password"
 echo
 echo "prints hash of (usalted) string, for use in php passwd"
 echo
 echo " -a algo:  specify hashing algo (check config file) default is $ALGO"
 echo " -p        try to use the php version"
 echo
}

#http://stackoverflow.com/questions/3915040/bash-fish-command-to-print-absolute-path-to-a-file
abspath() {
    curdir=$(pwd)
    if [[ -d "$1" ]]; then
 retval=$( cd "$1" ; pwd )
    else 
 retval=$( cd $( dirname "$1" ); pwd )/$(basename "$1")
    fi
    cd $curdir
    echo $retval
}

vbs() {
    [[ x$opt_v != x ]] && echo $1 1>&2
}

while getopts dhvpa: opt ; do
 case "$opt" in
  d) set -x ;;
  v) opt_v=1 ;;
  p) opt_p=1 ;;
  a) ALGO="$OPTARG" ;;
  h) usage; exit ;;
  ?) usage; exit ;;
 esac
done

shift `expr $OPTIND - 1`

# /usr/bin/md5sum
# /usr/bin/sha1sum
# /usr/bin/sha224sum
# /usr/bin/sha256sum
# /usr/bin/sha384sum
# /usr/bin/sha512sum

SUM="/usr/bin/${ALGO}sum"
[[ x$1 != x ]] || { usage ; exit ; } 

vbs "**$ALGO hash of $1"
if [[ x$opt_p != x ]]; then
    php -r  "print hash('$ALGO','$1').\"\n\";"
else
    [[ -f $SUM  ]] || { echo "No algorithm $ALGO" 1>&2 ; usage ; exit ; } 
    echo -n   "$1" | $SUM | cut -d ' ' -f 1
fi
Posted by Sax Appeal at 11:18 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: linux, phplist, programming
Older Posts Home
Subscribe to: Posts (Atom)

Search This Blog

Info about this blog - Legal stuff

  • Privacy e uso dei cookies
  • Disclaimer, cookies and all that jazz
  • Home

About Me

Sax Appeal
View my complete profile

My Blog List

  • Sean Carroll:Discover Blogs
    Rodents' Oddly Humanlike Thumbnails Have Let Them Feast on Nuts Since Ancient Times
    11 hours ago
  • JAZZIT
    Il jazz italiano per le terre del sisma 2025
    1 day ago
  • ruminazioni
    l'immarcescibile lista_libri, fumetti, film del 2019
    5 years ago
  • Casa Valdez Studios
    David Valdez Sextet live at the Blue Room
    5 years ago
  • BREW LITE's JAZZ TALES
    R.I.P. Roy Hargrove (1969 – 2018)
    6 years ago
  • Jazz: The Music of Unemployment
    What We've Become
    7 years ago
  • Tracce di jazz - Blog
    Who should headline the 50th Jazz Fest: Beyonce, Paul McCartney, ABBA, the Stones?
    7 years ago
  • note dissonanti
    Sul perchè dischi e musica improvvisata possono non andare d'accordo. Elogio dell'ascolto estemporaneo.
    9 years ago
  • flageolette
    Felish Cream: Perawatan Kecantikan dan Cream Pemutih Wajah
    10 years ago
  • all that jazz
    Welcome
    10 years ago
  • AccuJazz AccuBlog
    Charlie Haden Tribute on Bass Channel
    11 years ago
  • Mule Walk & Jazz Talk
    Mule Walk by James P. Johnson (1)
    12 years ago
  • Intelligent Life
    A Happy Birthday to a Most Wonderful Grandfather
    12 years ago
  • vitacongusto
    Happy 2013!
    12 years ago
  • MASSIMO MALTESE L'ARTE dell' IMPROVVISAZIONE JAZZ-
    LA SCALA BIZANTINA
    13 years ago
  • Jazz Beyond Jazz
    House Appropriations Committee to NEA: Keep Jazz Masters
    14 years ago
  • Aleaxity
    ubuntu.stackexchange.com now public!
    15 years ago
  • NPR Blogs: A Blog Supreme
    Native To NOLA: Kitchen Sink Klezmer, Young Brass Bands
    15 years ago
  • Hot House
  • Jazz from Italy

Blog Archive

  • ▼  2019 (2)
    • ▼  October (1)
      • Frasario romanesco inglese
    • ►  June (1)
  • ►  2018 (3)
    • ►  August (1)
    • ►  May (1)
    • ►  January (1)
  • ►  2016 (9)
    • ►  December (1)
    • ►  October (2)
    • ►  September (2)
    • ►  June (1)
    • ►  May (1)
    • ►  April (1)
    • ►  February (1)
  • ►  2015 (25)
    • ►  December (1)
    • ►  November (1)
    • ►  October (2)
    • ►  September (1)
    • ►  July (2)
    • ►  June (1)
    • ►  May (2)
    • ►  April (3)
    • ►  March (5)
    • ►  February (4)
    • ►  January (3)
  • ►  2014 (39)
    • ►  December (3)
    • ►  November (1)
    • ►  October (3)
    • ►  September (2)
    • ►  August (4)
    • ►  July (2)
    • ►  June (6)
    • ►  May (5)
    • ►  April (7)
    • ►  March (2)
    • ►  February (4)
  • ►  2013 (24)
    • ►  December (4)
    • ►  October (2)
    • ►  September (4)
    • ►  July (1)
    • ►  June (2)
    • ►  May (2)
    • ►  April (2)
    • ►  March (4)
    • ►  February (2)
    • ►  January (1)
  • ►  2012 (23)
    • ►  October (3)
    • ►  September (2)
    • ►  August (1)
    • ►  July (1)
    • ►  June (2)
    • ►  May (2)
    • ►  April (4)
    • ►  March (4)
    • ►  February (2)
    • ►  January (2)
  • ►  2011 (22)
    • ►  November (1)
    • ►  October (3)
    • ►  September (4)
    • ►  August (1)
    • ►  July (4)
    • ►  June (1)
    • ►  May (1)
    • ►  April (1)
    • ►  March (5)
    • ►  February (1)
  • ►  2010 (31)
    • ►  December (5)
    • ►  November (2)
    • ►  October (5)
    • ►  September (1)
    • ►  August (1)
    • ►  June (1)
    • ►  May (2)
    • ►  April (5)
    • ►  February (6)
    • ►  January (3)
  • ►  2009 (28)
    • ►  December (4)
    • ►  November (3)
    • ►  September (3)
    • ►  May (3)
    • ►  April (5)
    • ►  March (6)
    • ►  February (1)
    • ►  January (3)
  • ►  2008 (18)
    • ►  December (3)
    • ►  November (3)
    • ►  October (2)
    • ►  September (4)
    • ►  August (5)
    • ►  July (1)