Register now and start sharing your code snippets.
-->

Sphinx configuration file template

Plain Text posted 6 months ago by christian

   1  source feed_items
   2  {
   3          type                    = mysql
   4  
   5          sql_host                = 127.0.0.1
   6          sql_user                = root
   7          sql_pass                =
   8          sql_db                  = xxx_production
   9          sql_port                = 3306  # optional, default is 3306
  10          sql_sock                = /var/run/mysqld/mysqld.sock
  11  
  12          sql_query_pre           = SET NAMES utf8
  13          #sql_query_pre          = SET SESSION query_cache_type=OFF
  14  
  15  	# Unique ID should be first column
  16          sql_query               = \
  17                  SELECT i.id, i.title, i.link, f.link, f.title FROM feed_items i LEFT JOIN feeds f ON f.id = i.feed_id
  18  }
  19  
  20  
  21  index feed_items
  22  {
  23          source                  = feed_items
  24          path                    = /var/sphinx/xxx
  25          morphology              = libstemmer_sv
  26          charset_type            = utf-8
  27  }
  28  
  29  
  30  indexer
  31  {
  32          mem_limit               = 32M
  33  }
  34  
  35  searchd
  36  {
  37          address                 = 127.0.0.1
  38          port                    = 3312
  39          log                     = /var/log/sphinx/searchd.log
  40          query_log               = /var/log/sphinx/query.log
  41          pid_file                = /var/log/searchd.pid
  42          max_matches             = 1000
  43  }
  44  

Tagged sphinx, template, configuration

Notes on how to develop a Firefox extension

Plain Text posted 7 months ago by christian

Create a new profile for extension development

http://lifehacker.com/software/firefox/geek-to-live%E2%80%94manage-multiple-firefox-profiles-231646.php

Tweak Firefox configuration for extension development

http://developer.mozilla.org/en/docs/Setting_up_extension_development_environment

Create a skeleton extension

http://ted.mielczarek.org/code/mozilla/extensionwiz/

Extract it to the your project folder, for example:

   1  /home/name/projects/my_extension

Setup Firefox to load your extension

Follow these instructions to configure Firefox to load your extension from /home/name/projects/my_extension: http://developer.mozilla.org/en/docs/Setting_up_extension_development_environment#Custom_code_location http://developer.mozilla.org/en/docs/Setting_up_extension_development_environment#Using_directories_rather_than_JARs

Install the Extension developer

http://ted.mielczarek.org/code/mozilla/extensiondev/

Start Firefox with the development profile

   1  firefox-bin -P development -no-remote

To start the default profile use:

   1  firefox-bin -P THE_PROFILE_NAME -no-remote

Build your extension

http://www.xulplanet.com/

The extension wizard includes a build script, but it might be a good idea to upgrade it to the latest version, which can be found here (including a Windows build script): http://kb.mozillazine.org/Bash_build_script

Gotchas

If you’re on windows and using CygWin, you might get this error:

   1  ./build.sh: line 6: $'\r': command not found
   2  ./build.sh: line 29: $'\r': command not found
   3  ./build.sh: line 40: $'\r': command not found
   4  ./build.sh: line 70: syntax error near unexpected token `$'do\r''
   5  '/build.sh: line 70: `for CHROME_SUBDIR in $CHROME_PROVIDERS; do

The solution is to run the dos2unix command on the *.sh files:

   1  d2u build.sh
   2  d2u config_build.sh

Tagged firefox, extension, development, notes

How to make GVim look and behave better on Windows

Plain Text posted 9 months ago by christian

I use this configuration with GVim (sometimes I’m forced to use Windows). It makes the GVim behave and look better.

   1  " Start maximized
   2  au GUIEnter * simalt ~x
   3  
   4  " Use CUA keystrokes for clipboard: CTRL-X, CTRL-C, CTRL-V and CTRL-z
   5  source $VIMRUNTIME/mswin.vim
   6  
   7  syntax on
   8  set nocompatible
   9  filetype on
  10  filetype indent on
  11  filetype plugin on
  12  
  13  " General options
  14  set incsearch
  15  set ignorecase smartcase 
  16  
  17  " Use two space tabs
  18  set tabstop=2
  19  set shiftwidth=2
  20  set expandtab
  21  
  22  " No menus and no toolbar
  23  "set guioptions-=m  
  24  set guioptions-=T
  25  
  26  set guifont=Consolas:h11:cANSI
  27  
  28  highlight Normal guifg=White   guibg=Black
  29  highlight Cursor guifg=Black   guibg=White
  30  highlight Keyword guifg=#FF6600
  31  highlight Define guifg=#FF6600
  32  highlight Comment guifg=#9933CC
  33  highlight Type guifg=White gui=NONE
  34  highlight rubySymbol guifg=#339999 gui=NONE
  35  highlight Identifier guifg=White gui=NONE
  36  highlight rubyStringDelimiter guifg=#66BB00
  37  highlight rubyInterpolation guifg=White
  38  highlight rubyPseudoVariable guifg=#339999
  39  highlight Constant guifg=#FFEE98
  40  highlight Function guifg=#FFCC00 gui=NONE
  41  highlight Include guifg=#FFCC00 gui=NONE
  42  highlight Statement guifg=#FF6600 gui=NONE
  43  highlight String guifg=#66BB00
  44  highlight Search guibg=White
  45  
  46  function RubyEndToken ()
  47    let current_line = getline( '.' )
  48    let braces_at_end = '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?$'
  49    let stuff_without_do = '^\s*\(class\|if\|unless\|begin\|case\|for\|module\|while\|until\|def\)'
  50    let with_do = 'do\s*\(|\(,\|\s\|\w\)*|\s*\)\?$'
  51  
  52    if match(current_line, braces_at_end) >= 0
  53      return "\<CR>}\<C-O>O" 
  54    elseif match(current_line, stuff_without_do) >= 0
  55      return "\<CR>end\<C-O>O" 
  56    elseif match(current_line, with_do) >= 0
  57      return "\<CR>end\<C-O>O" 
  58    else
  59      return "\<CR>" 
  60    endif
  61  endfunction
  62  
  63  function UseRubyIndent ()
  64    setlocal tabstop=8
  65    setlocal softtabstop=2
  66    setlocal shiftwidth=2
  67    setlocal expandtab
  68  
  69    imap <buffer> <CR> <C-R>=RubyEndToken()<CR>
  70  endfunction
  71  
  72  autocmd FileType ruby,eruby call UseRubyIndent()

Tagged gvim, _vimrc, windows, vim

Getting WLAN to work on a Fujitsu Amilo laptop is difficult...

Plain Text posted about 1 year ago by christian

I fought and won over WLAN drivers and Linux, but later switched to using a Mac, because driver support for WLAN , printers and other hardware is non-existent Linux:

   1  apt-get install wpasupplicant
   2  
   3  http://ubuntuforums.org/showthread.php?t=313914
   4  
   5  vim /etc/wpa_supplicant.conf
   6  
   7  ctrl_interface=/var/run/wpa_supplicant
   8  ctrl_interface_group=0
   9  eapol_version=1
  10  ap_scan=2
  11  fast_reauth=1
  12  
  13  
  14  network={
  15      ssid="...yer-ssid..."
  16      scan_ssid=1
  17      proto=WPA
  18      key_mgmt=WPA-PSK
  19      psk="...yer-pass..."
  20      priority=5
  21      pairwise=TKIP
  22  }
  23  
  24  vim /etc/network/interfaces
  25  
  26  auto lo
  27  iface lo inet loopback
  28  
  29  auto eth1
  30  iface eth1 inet dhcp
  31     wpa-driver wext
  32     wpa-conf /etc/wpa_supplicant.conf
  33  
  34  auto wlan0
  35  iface wlan0 inet dhcp
  36  
  37  iface eth0 inet dhcp
  38  
  39  auto eth0
  40  
  41  vim /etc/init.d/wpasupplicant
  42  
  43  #!/bin/sh
  44  
  45  PATH=/usr/sbin:/usr/bin:/sbin:/bin
  46  
  47  case "$1" in
  48          start|restart|force-reload)
  49                  wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -dd -B
  50                  ;;
  51          stop)
  52                  killall -9 wpa_supplicant
  53                  ;;
  54          *)
  55                  echo "Usage: $0 {start|stop|restart|force-reload}" >&2
  56                  exit 3
  57                  ;;
  58  esac
  59  
  60  exit 0
  61  
  62  ----------------
  63  
  64  chmod +x ...
  65  cd /etc/rcS.d
  66  ln -s ../init.d/wpasupplicant S40iwpa
  67  
  68  
  69  -------------
  70  
  71  auto lo
  72  iface lo inet loopback
  73  
  74  auto eth1
  75  iface eth1 inet dhcp
  76  
  77  auto wlan0
  78  iface wlan0 inet dhcp

Tagged fujitsu, linux, wlan, amilo, wpa-supplicant

How to improve your PageRank with 301 permanent redirects when using Nginx

Plain Text posted about 1 year ago by christian

Mathew Innman of seomoz.org fame wrote about how Digg could increase their revenue by using a so called canonical URL for their whole site. This can be implemented by redirecting users that type in, for example, www.digg.com to digg.com. The reasoning being that instead of having backlinks pointing to two different domains (www and no-www), all backlinks should point to just one, which increases your search engine ranking.

   1  if ($host ~* "www") {
   2        rewrite ^(.*)$ http://aktagon.com$1 permanent;
   3        break;
   4      }

Permanent redirects are also a good idea, if you move your content to a new domain—digg.com to dugg.com, for example…

The syntax for the Nginx rewrite module is documented here.

Tagged seo, www, 301, permanent, nginx, redirect, rewrite, module