Beautiful JavaScript code, example

Yesterday I work a lot with JavaScript and here is beautiful JS example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var Example = window.Example || (function() {
    var self = {};
 
    // This method:
    self.Update = function() {
        var self = {};
 
        self.itemcurrency = function() {
 
        }
 
        self.currency = function() {
 
        }
 
        return self;    
    },
 
    // Or this method:
    self.Update2 = {
        ItemCurrency: function() {
 
        },
 
        Currency: function() {
 
        }
    }
 
    return self;
})();

Usage:

1
2
3
4
// For first method
Example.Update().itemcurrency();
// For second method
Example.Update2.itemcurrency();

Hope this helps you to create nice JavaScript code!

MySQL InnoDB, one file problem

I installed new server about 6 months ago and now found problem with MySQL InnoDB. I add and delete a few big InnoDB tables, but space of InnoDB still grow. I found a lot ideas how to fix it (dump all DB and restore back), but the best way is to add to MySQL config file “innodb_file_per_table”.

TODO:

  • Stop the MySQL server (usually “/etc/init.d/mysql stop” on Linux).
  • Edit the my.cnf file (located at somewhere like /etc/my.cnf or /etc/mysql/my.cnf)
  • Add “innodb_file_per_table” on a single line by itself into the my.cnf file.
  • Start the MySQLserver (“/etc/init.d/mysql start”).

Any new InnoDB tables that are created will now be created in the database’s directory with a single file per database table. Doing this does not affect any existing InnoDB tables they will still use the common data file.

My 2 first projects with PHP and MySQL in 2001 and 2002!

I found DVD disk with 2002 backup from server and I found 2 my first projects:

1. Ozas.bst.lt – this project was made in 2001, with PHP, JavaScript and etc. No MySQL, all data was saved in TXT file’s. That is my first internet project and it still looks very good!

2. Ozas.bst.lt/WAP – it was time, when Nokia 3310 was the best phone in the world, we also had GSM data transfer (PC at that time had 56K), but then came to Lithuania GPRS data transfer.. and also came Nokia 3510i! That was amazing phone, TFT color screen, very good battery and etc, so I buy this new phone and for him made WML (no xHTML support at that time) WAP site with HTML support for PC browsers (that works very good and now). This site had every night about 100-150 peoples online with phones and they talk in chat rooms, forums, PM messages and more.

Sorry, but site’s have only Lithuanian language support, but still, you can check how it looks in 2001-2002, amazing.

Then I open both sites.. it something.. I don’t know how to say, that was made about 10 years ago, at school, home.. is just fantastic. I will try to save for future.

How to edit 5.3 GB file over SSH

I have problem with InnoDB on mine server so I dumped all files and want to change in SQL file table type from InnoDB to MyISAM, but can’t because file size is 5.3 GB. No one editor can’t edit so big file over SSH, so I found amazing solution for that:

1
split -b 10000k mysqldump.sql

You split one file by pieces, then edit piece what you want and when can make one file, by this command:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
cat xa* > mysqldump.sql
 
SYNOPSIS
       split [OPTION]... [INPUT [PREFIX]]
 
       -a, --suffix-length=N
              use suffixes of length N (default 2)
 
       -b, --bytes=SIZE
              put SIZE bytes per output file
 
       -C, --line-bytes=SIZE
              put at most SIZE bytes of lines per output file
 
       -d, --numeric-suffixes
              use numeric suffixes instead of alphabetic
 
       -l, --lines=NUMBER
              put NUMBER lines per output file

Hope that idea helps you too!