chmod

Written by leif. Posted in Linux, Tips

  • 644 make a file readable by anyone and writable by the owner
    only.
  • go-w deny write permission to group and others.
  • =rw,+X set the read and write permissions to the usual defaults, but retain any execute permissions that are currently set.
  • +X make a directory or file searchable/executable by everyone
    if it is already searchable/executable by anyone.
  • 755
    u=rwx,go=rx
    u=rwx,go=u-w make a file readable/executable by everyone and writable by
    the owner only.
  • go= clear all mode bits for group and others.
  • g=u-w set the group bits equal to the user bits, but clear the
    group write bit.
954 views

apt-get commands

Written by leif. Posted in Linux

Installation commands

  • apt-get install <package_name>

    This command installs a new package.

  • apt-get build-dep <package_name>

    This command searches the repositories and installs the build dependencies for <package_name>. If the package is not in the repositories it will return an error.

  • aptitude install <package_name>

    Aptitude is an Ncurses viewer of packages installed or available. Aptitude can be used from the command line in a similar way to apt-get. See man aptitude for more information.

852 views

Launch Sublime Text 3 from the command line from OS X

Written by leif. Posted in OS X, Tips

If the path /usr/local/bin does not exist, then create it.

sudo mkdir /usr/local/bin

Create the symbolic link:

sudo ln -s “/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl” /usr/local/bin/subl

close and reopen terminal and then your are set.

Testing

Open a Terminal window and run:

1
sublime ~/Documents

or

1
2
cd
sublime Documents/

or even

1
2
# to open the entire current directory
sublime .
1111 views

How to ‘insert if not exists’ in MySQL?

Written by leif. Posted in Mysql, PHP, Tips

see http://bogdan.org.ua/2007/10/18/mysql-insert-if-not-exists-syntax.html

there’s also INSERT … ON DUPLICATE KEY UPDATE syntax, you can find explanations on dev.mysql.com


Post from bogdan.org.ua
18th October 2007

To start: as of the latest MySQL, syntax presented in the title is not possible. But there are several very easy ways to accomplish what is expected using existing functionality.

There are 3 possible solutions: using INSERT IGNORE, REPLACE, or INSERT … ON DUPLICATE KEY UPDATE.Imagine we have a table:

CREATE TABLE `transcripts` (
1595 views

Compare two MySQL databases

Written by leif. Posted in Tips

If you’re working with small databases I’ve found running mysqldump on both databases with the --skip-comments and --skip-extended-insert options to generate SQL scripts, then running diff on the SQL scripts works pretty well.

By skipping comments you avoid meaningless differences such as the time you ran the mysqldump command. By using the --skip-extended-insert command you ensure each row is inserted with its

1285 views