Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS 

Creating a clean url for a ProjectX method

Following on from the projectx-helper.cgi [dzone.com] post the following Apache rewrite instruction reduces the url to something more user friendly. In this example the user would enter the URL http://someurl.com/planner/create/date/190808 for a new planner record to be created for the 19th August.

   1  
   2     RewriteEngine on
   3     RewriteRule ^/planner/create/date/(\d+)$ /p/projectx-helper.cgi?project=mdynarex&method=create&file=planner&date=$1 [p]
   4  


Note the destination address is proxied to allow the execution of the script to be permitted.

Configuring Apache for Ruby CGI

When using Apache on Ubuntu add the following configuration to the httpd.conf file within the file directory /etc/apache2.

   1  
   2  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
   3  
   4  <Directory "/usr/lib/cgi-bin">
   5          AllowOverride None
   6          Options +ExecCGI +Indexes
   7          Order allow,deny
   8          Allow from all
   9  </Directory>
  10  


Note: Don't forget to make the script file executable.

Squid Conf file

Personal squid conf file. Allowing AIM ports and all web browsing.

   1  
   2  cache_dir ufs /Users/dave/Library/Caches/squid 100 16 256
   3  acl dontcacheanything src 0/0
   4  no_cache deny dontcacheanything
   5  maximum_object_size 32768 KB
   6  http_port 28080
   7  visible_hostname localhost
   8  cache_access_log /Users/dave/Library/Logs/squid-access.log
   9  cache_log /Users/dave/Library/Logs/squid-cache.log
  10  cache_store_log /Users/dave/Library/Logs/squid-store
  11  pid_filename /tmp/squid.pid
  12  hierarchy_stoplist cgi-bin ?
  13  acl QUERY urlpath_regex cgi-bin 
  14  no_cache deny QUERY
  15  acl all src 0.0.0.0/0.0.0.0
  16  acl AIM_ports port 5190 9898 6667
  17  acl AIM_domains dstdomain .oscar.aol.com .blue.aol.com .freenode.net
  18  acl AIM_domains dstdomain .messaging.aol.com .aim.com
  19  acl AIM_hosts dstdomain login.oscar.aol.com login.glogin.messaging.aol.com toc.oscar.aol.com irc.freenode.net
  20  acl AIM_nets dst 64.12.0.0/255.255.0.0
  21  acl AIM_methods method CONNECT
  22  http_access allow AIM_methods AIM_ports AIM_nets
  23  http_access allow AIM_methods AIM_ports AIM_hosts
  24  http_access allow AIM_methods AIM_ports AIM_domains
  25  acl manager proto cache_object
  26  acl localhost src 127.0.0.1/255.255.255.255
  27  acl SSL_ports port 443 563 1863 5190 5222 5050 6667 8443
  28  acl Safe_ports port 80 81 21 443 563 70 210 1025-65535 280 488 591 777
  29  acl CONNECT method CONNECT
  30  http_access allow manager localhost
  31  http_access deny manager
  32  http_access deny !Safe_ports
  33  http_access deny CONNECT !SSL_ports
  34  http_access allow all
  35  http_access deny all
  36  always_direct deny all

Using an Apache proxy RewriteRule

This Apache Rewrite instruction uses the url http://mywebsite.com/cards as a proxy to access another web server within the LAN.

   1  
   2          RewriteEngine on
   3          RewriteRule ^cards$ http://192.168.1.15/ [P]

Configuring Asterisk as a Jabber client

Here's my working instructions to connect my Asterisk box as a client to my Jabber server. When a call comes in on extension 10 a message is sent to me.


file: jabber.conf
   1  
   2  [general]
   3  debug=yes                               ;;Turn on debugging by default.
   4  autoprune=no                            ;;Auto remove users from buddy list.
   5  autoregister=yes                        ;;Auto register users from buddy list. 
   6  
   7  [asterisk]                              ;;label
   8  type=client                             ;;Client or Component connection
   9  serverhost=jamesrobertson.eu
  10                                          ;;      talk.google.com
  11  username=asterisk@jamesrobertson.eu/Home        ;;Username with optional roster.
  12  
  13  secret=XXXXXXXX                         ;;Password
  14  port=5222                               ;;Port to use defaults to 5222
  15  usetls=no                               ;;Use tls or not
  16  ;usesasl=yes                            ;;Use sasl or not
  17  buddy=james@jamesrobertson.eu
  18  statusmessage="I am available"          ;;Have custom status message for
  19                                          ;;Asterisk.
  20  timeout=100                             ;;Timeout on the message stack.
  21  

file: extensions.conf
   1  
   2  exten => 10,1,JABBERSend(asterisk,james@jamesrobertson.eu, Call from ${CALLERID(name)} at number <${CALLERID(num)}> on ${STRFTIME(,GMT-1,%A %B %d %G at %l:%M:%S %p)} )
   3  exten => 10,n,Macro(stdexten,100,100)
   4  


output (observed in my chat window from user Asterisk)
Call from Line 1 - Home at number <6200> on Sunday May 18 2008 at 8:53:24 PM
« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS