Category:To categorize

From campisano.org
Jump to navigation Jump to search

Links

Google

DNS Server

Functions

Statistics

Finance

Others

Mac OSX

Keyboard binding linux-like

To reach a partial linux keyboard compatibility for Terminal.app

Sadly, it can not work if you switch CTRL and COMMAND keys...

1. disable all shortcuts
   go to system preference -> keyboard -> shortcuts
     for each menu item, for each subitem, disable it
2. overwrite default Terminal shortcuts to avoid unwanted behaviors (e.g. close using emacs Alt+W copy shortcut)
   go to system preference -> keyboard -> shortcuts -> App Shortcuts
     search for Terminal.app
     add a new shortcut for Terminal.app, with the exact name 'Quit Terminal' and assign something like 'Alt+Command+Q'
     add a new shortcut for Terminal.app, with the exact name 'Close Window' and assign something like 'Shift+Command+Q'
     add a new shortcut for Terminal.app, with the exact name 'Close Tab' and assign something like 'Shift+Command+W'
     add a new shortcut for Terminal.app, with the exact name 'Show Next Tab' and assign something like 'Ctrl+Shift+Option+['
     add a new shortcut for Terminal.app, with the exact name 'Show Previous Tab' and assign something like 'Ctrl+Shift+Option+]'
3. setup Terminal.app as xterm
   open Terminal.app -> preferences -> profiles
   choose a profile, make default, go to keyboard tab
     mark Use Option as Meta key
     REMOVE ALL KEYBINDINGS
     add    HOME             as \001
     add    END              as \005
     add    CTRL+LEFT        as \033[1;5D
     add    CTRL+RIGHT       as \033[1;5C
     add    CTRL+SHIFT+LEFT  as \033[1;6D
     add    CTRL+SHIFT+RIGHT as \033[1;6C
     add    CTRL+UP          as \033[1;5A
     add    CTRL+DOWN        as \033[1;5B
     add    CTRL+SHIFT+UP    as \033[1;6A
     add    CTRL+SHIFT+DOWN  as \033[1;6B
     add    SHIFT+LEFT       as \033[1;2D
     add    SHIFT+RIGHT      as \033[1;2C
     add    SHIFT+UP         as \033[1;2A
     add    SHIFT+DOWN       as \033[1;2B

NTFS

From techbytesxpress.com

  • Install OSXFuse. Make sure to select installing MacFuse during installation for backwards compatibility.
  • Install NTFS-3G.
  • Reboot

CSS

Commands

Split/Merge large files

from http://magazine.redhat.com/2007/10/24/tips-from-an-rhce-splitting-tar-archives-on-the-fly/

  • Split:
user@host:~$ cat bkp-audio.tar | split -b3GB -d - bkp-audio-
user@host:~$ ls -sh
total 16G
2.8G bkp-audio-00  2.8G bkp-audio-01  2.8G bkp-audio-02  2.8G bkp-audio-03  2.8G bkp-audio-04  1.9G bkp-audio-05
  • Merge:
user@host:~$ cat bkp-audio-* >> bkp-audio.tar
user@host:~$ ls
bkp-audio-00  bkp-audio-01  bkp-audio-02  bkp-audio-03	bkp-audio-04  bkp-audio-05

Encrypt/Decrypt files

from http://linuxpoison.blogspot.com.br/2009/01/encrypt-decrypt-files-using-mcrypt-on.html

  • Encrypt:
user@host:~$ tar -cf - dati | mcrypt > dati.crypted
Enter the passphrase (maximum of 512 characters)
Please use a combination of upper and lower case letters and numbers.
Enter passphrase: 
Enter passphrase: 

Stdin was encrypted.
  • Decrypt:
user@host:~$ cat dati.crypted | mcrypt -d > dati.tar
Enter passphrase: 
Stdin was decrypted.

Remote ssh backup and transfer

user@host:~$ tar -czf - /etc | ssh root@YOUR_DEST_HOST 'cat - > /tmp/bkp-etc.tgz'
### optionally, TO WORK IN BACKGROUND:
CTRL+Z
user@host:~$ bg
user@host:~$ disown -h %1
### now you can exit
user@host:~$ exit

Algebra relacional / SQL

Schema

  • Algebra relacional
Fornecedores(fid:integer, fnome:string, end:string)
Pecas(pid:integer, pnome:string,cor:string)
Catalogo(fid:integer,pid:integer,preco:real)
  • SQL
CREATE TABLE Fornecedores
(
  fid     INT,
  fnome   VARCHAR(32),
  end     VARCHAR(32),
  PRIMARY KEY (fid)
);

CREATE TABLE Pecas
(
  pid     INT,
  pnome   VARCHAR(32),
  cor     VARCHAR(32),
  PRIMARY KEY (pid)
);

CREATE TABLE Catalogo
(
  fid     INT,
  pid     INT,
  preco   DOUBLE,
  PRIMARY KEY (fid, pid),
  FOREIGN KEY (fid) REFERENCES Fornecedores(fid),
  FOREIGN KEY (pid) REFERENCES Pecas(pid)
);

INSERT INTO Fornecedores VALUES (1, 'forn1', '');
INSERT INTO Fornecedores VALUES (2, 'forn2', '');
INSERT INTO Fornecedores VALUES (3, 'forn3', '');
INSERT INTO Fornecedores VALUES (4, 'forn4', '');
INSERT INTO Fornecedores VALUES (5, 'forn5', '');

INSERT INTO Pecas VALUES (1, 'peca1', 'vermelha');
INSERT INTO Pecas VALUES (2, 'peca2', 'vermelha');
INSERT INTO Pecas VALUES (3, 'peca3', 'verde');
INSERT INTO Pecas VALUES (4, 'peca1', 'amarela');
INSERT INTO Pecas VALUES (5, 'peca1', 'verde');

INSERT INTO Catalogo VALUES (1, 1, 100);
INSERT INTO Catalogo VALUES (1, 2, 100);
INSERT INTO Catalogo VALUES (1, 3, 150);
INSERT INTO Catalogo VALUES (1, 4, 120);
INSERT INTO Catalogo VALUES (1, 5, 120);
INSERT INTO Catalogo VALUES (2, 3, 90);
INSERT INTO Catalogo VALUES (2, 2, 110);
INSERT INTO Catalogo VALUES (3, 3, 100);
INSERT INTO Catalogo VALUES (3, 4, 110);
INSERT INTO Catalogo VALUES (4, 4, 100);
INSERT INTO Catalogo VALUES (5, 5, 150);

Subtração

Consulta: Obtenha o nome das peças que são fornecidas pelo fornecedor 'fonr1' e não são fornecidas por nenhum outro fornecedor.

  • Algebra relacional
( P pnome ( Pecas |><| ( P pid ( Catalogo |><| ( S fname = 'forn1' ( Fornecedores ) ) ) - P pid ( Catalogo |><| ( S fname <> 'forn1' ( Fornecedores ) ) ) ) ) )
  • SQL
SELECT DISTINCT pnome
FROM   Pecas
NATURAL JOIN Catalogo
NATURAL JOIN Fornecedores
WHERE  fnome = 'forn1'
AND    (pid) NOT IN
(  
  SELECT pid
  FROM   Catalogo
  NATURAL JOIN Fornecedores
  WHERE  fnome <> 'forn1'
);

Divisão

Consulta: Obtenha o nome dos fornecedores que fornecem todas as peças

  • Algebra relacional
( P fnome ( Fornecedores |><| ( P fid, pid ( Catalogo ) -:- P pid ( Pecas ) ) ) )
SELECT DISTINCT fnome
  FROM Fornecedores NATURAL JOIN Catalogo AS R1
WHERE NOT EXISTS
(
  SELECT pid
    FROM Pecas AS S
   WHERE NOT EXISTS
  (
    SELECT fid, pid 
      FROM Catalogo AS R2
     WHERE R1.fid = R2.fid
       AND R2.pid = S.pid
  )
);

Ideas

  • true tables
  • cep vs address
  • brute hash table break 1 2
  • voice chat utility









Patterns

from http://www.coderanch.com/t/224682/Web-Services/java/Facade-design-pattern-web-services

In terms of general design patterns you are actually dealing with
issues usually addressed by at least three design patterns:
Facade - Define a higher-level interface that makes the subsystem easier to use.
Decorator - Attach additional responsibilities to an "object"
(possibly dynamically) without any modification of the underlying
"class".
Adapter - Let "classes" work together that couldn't otherwise because
of incompatible interfaces.


Ultimately you are using the Facade Pattern because you are trying to
present one simple unified interface for a whole mess of pre-existing
business logic. The purest form of the facade pattern applied to web
services is a web service that simply delegates the work to more basic
web services.

see also http://www.coderanch.com/t/100717/patterns/Stratergy-vs-Factory-method-vs

Pages in category "To categorize"

This category contains only the following page.