Sunday, 12 May 2013

Η ΣΧΟΛΗ ΤΩΝ ΘΕΩΝ #remember

Ο κόσμος είναι όπως τον ονειρεύεσαι... είναι ένας καθρέφτης. Εκεί έξω βρίσκεις τον δικό σου κόσμο, τον κόσμο που έχτισες, που ονειρεύτηκες.Έξω βρίσκεις εσένα! Πήγαινε να δεις ποιος είσαι.Θ΄ανακαλύψεις ότι οι άλλοι είναι η αντανάκλαση της εικόνας του ψέματος που έχεις μέσα σου, του συμβιβασμού, της άγνοιάς σου... Άλλαξε!... και ο κόσμος θ' αλλάξει.Δημιουργείς έαν άρρωστο κόσμο και έπειτα φοβάσαι το δημιούργημά σου, τη βία που εσύ ο ίδιος προκάλεσες. Πιστεύεις ότι ο κόσμος είναι αντικειμενικός... αλλά ο κόσμος είναι όπως εσύ τον ονειρεύεσαι. Πήγαινε στον κόσμο και αποδέξου τον... Συνάντησε τους φτωχούς, τους βίαιους, τους λεπρούς που έχεις μέσα σου. Αποδέξου τους... Μην τους αποφεύγεις, μην τους κατηγορείς... Παραδώσου στον κόσμο σου. Πήγαινε και συνειδητά αποδέξου αυτό που έχεις δημιουργήσει: έναν κόσμο σε άγνοια, σκληρό, αμαθή... έναν κόσμο χωρίς ζωή. Η δύναμη ενός ανθρώπου είναι να εξουσιάζει τον εαυτό του και την ίδια στιγμή να παραδίδεται στον εαυτό του.Η ζωή σου, ο κόσμος όπου πιστεύεις ότι μπορείς να επιλέγεις και να αποφασίζεις, είναι πλασματικά... είναι ένας φρικτός εφιάλτης. Μόνο το "όνειρο" είναι πραγματικό. Το "όνειρο" είναι το πιο αληθινό πράγμα που υπάρχει. Αυτό που εσύ αποκαλείς πραγματικότητα είναι μόνο φαινόμενα, πρέπει να την αναποδογυρίσεις τελείως και δεν μπορείς να κρατήσεις μέσα σου τίποτα από τα παλιά... Θα πρέπει να μάθεις έναν νέο τρόπο να σκέφτεσαι, ν' αναπνέεις, να δρας και ν' αγαπάς...Έζησες μια ύπαρξη χωρίς σκοπό... οδυνηρή. Κρυμμένος πίσω από μια απασχόληση, πίσω από την απατηλή προστασία ενός μισθού, διαιωνίζεις τη φτώχεια, τη δυστυχία του κόσμου. Η ζωή είναι πάρα πολύ πολύτιμη για να εξαρτάσαι, και πάρα πολύ πλούσια για να χάνει! Ήρθε η ώρα ν' αλλάξεις!Έφτασε ο καιρός να εγκαταλείψεις τον όλο συγκρούσεις τρόπο με τον οποίο βλέπεις τον κόσμο. Έφτασε ο καιρός να πεθάνει μέσα σου ό,τι δεν έχει ζωή. Είναι καιρός για μια αναγέννηση. Είναι καιρός για μια νέα έξοδο, μια νέα ελευθερία. Είναι η μεγαλύτερη περιπέτεια που μπορεί να φανταστεί ένας άνθρωπος: η κατάκτηση της προσωπικής του ακεραιότητας.

Wednesday, 8 May 2013

Socket.io example


down vote
accepted
index.html
<!doctype html>
<html>
    <head>
        <script src='//code.jquery.com/jquery-1.7.2.min.js'></script>
        <script src='//localhost:3000/socket.io/socket.io.js'></script>
        <script>
            var socket = io.connect('//localhost:3000');

            socket.on('welcome', function(data) {
                $('#messages').append('<li>' + data.message + '</li>');

                socket.emit('i am client', {data: 'foo!'});
            });
            socket.on('time', function(data) {
                console.log(data);
                $('#messages').append('<li>' + data.time + '</li>');
            });
            socket.on('error', function() { console.error(arguments) });
            socket.on('message', function() { console.log(arguments) });
        </script>
    </head>
    <body>
        <ul id='messages'></ul>
    </body>
</html>

app.js

var http = require('http'),
    fs = require('fs'),
    // NEVER use a Sync function except at start-up!
    index = fs.readFileSync(__dirname + '/index.html');

// Send index.html to all requests
var app = http.createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.end(index);
});

// Socket.io server listens to our app
var io = require('socket.io').listen(app);

// Send current time to all connected clients
function sendTime() {
    io.sockets.emit('time', { time: new Date().toJSON() });
}

// Send current time every 10 secs
setInterval(sendTime, 10000);

// Emit welcome message on connection
io.sockets.on('connection', function(socket) {
    socket.emit('welcome', { message: 'Welcome!' });

    socket.on('i am client', console.log);
});

app.listen(3000);



http://stackoverflow.com/questions/9914816/what-is-an-example-of-the-simplest-possible-socket-io-example

Thursday, 2 May 2013

build-your-first-javascript-library

http://net.tutsplus.com/tutorials/javascript-ajax/build-your-first-javascript-library/ code: https://github.com/msroot/dome/blob/master/src/dome.js

how jquery works

http://www.mikedoesweb.com/2012/creating-your-own-javascript-library/

Tuesday, 30 April 2013

fix your ~/.ssh permissions


Ssh is very picky about permissions on the ~/.ssh directory and files. Sometimes you may do something to mess up these permissions. Run the following to fix most permissions problems. You may have to do this on both the remote host and local host.
    chmod 700 ~/.ssh

    chmod 600 ~/.ssh/id_rsa

    chmod 644 ~/.ssh/id_rsa.pub  

    chmod 644 ~/.ssh/authorized_keys

    chmod 644 ~/.ssh/known_hosts




Also no directory above ~/.ssh can have 'group' or 'other' write permissions.
http://blog.kristeraxel.com/2012/06/fix-your-ssh-permissions/

Most useful function!

function get_happy { open -a "/Applications/Google Chrome.app" "http://play.navabros.com/vivire-para-ti.mp3" }

a great pattern in js





http://www.slideshare.net/toddanglin/5-tips-for-better-javascript

Saturday, 27 April 2013

Immediately-invoked function expression

An immediately-invoked function expression (or IIFE, pronounced "iffy") is a JavaScript design pattern which produces block scoping using JavaScript's function scoping. Immediately-invoked function expressions can be used to avoid variable hoisting from within blocks, protect against polluting the global environment and simultaneously allow public access to methods while retaining privacy for variables defined within the function. This pattern has been referred to as a self-executing anonymous function,[1] but Ben Alman introduced the term IIFE as a more semantically accurate term for the pattern.[2][3]

Usage

Immediately-invoked function expressions may be written in a number of different ways,[4] although a common convention is to enclose both the function expression and invokation in parentheses.[5][6]
(function(){
  /* code */ 
}());





Examples

Key to understanding design patterns such as immediately-invoked function expressions is to realize JavaScript has function scope (but not block scope) and passes values by reference inside a closure.[7]

[edit]Evaluation context

A lack of block scope means that variables defined inside, for example, a for loop will have their definition "hoisted' to the top of the enclosing function. Evaluating a function which depends on variables modified by the outer function (including by iteration) can be difficult. We can see this without a loop if we update a value between defining and invoking the function.[8]
var v, getValue;
getValue = function() { return v; };
v = 2;
 
getValue(); // 2
While the result may seem obvious when updating v manually, it can produce unintended results when getValue() is defined inside a loop.
var v, getValue;
v = 1;
getValue = (function(v) {
  return function() {return v;};
}(v));
v = 2;
 
getValue(); //1
Here the function passes v as an argument and is invoked immediately, preserving the inner function's execution context.[9]
David Herman's Effective JavaScript contains an example illustrating the problems of evaluation context inside loops.[10] While Herman's example is deliberately convoluted it arises directly from the same lack of block scope.[11]



Establishing private variables and accessors

IIFEs are also useful for establishing private methods for accessible functions while still exposing some properties for later use.[12] The following example comes from Alman's post on IIFEs.[2]
var counter = (function(){
  var i = 0;
 
  return {
    get: function(){
      return i;
    },
    set: function( val ){
      i = val;
    },
    increment: function() {
      return ++i;
    }
  };
}());
 
// 'counter' is an object with properties, which in this case happen to be
// methods.
 
counter.get(); // 0
counter.set( 3 );
counter.increment(); // 4
counter.increment(); // 5
If we attempt to access counter.i from the global environment, it will be undefined as it is enclosed within the invoked function and is not a property of counter. Likewise, if we attempt to access i it will result in an error as we have not declared i in the global environment.

[edit]
















http://en.wikipedia.org/wiki/Immediately-invoked_function_expression