<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: X code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 02:23:42 GMT</pubDate>
    <description>DZone Snippets: X code</description>
    <item>
      <title>Capturing the mousemove coordinates</title>
      <link>http://snippets.dzone.com/posts/show/5264</link>
      <description>Source code copied from &lt;a href="http://javascript.internet.com/page-details/mouse-coordinates.html"&gt;The JavaScript Source: Page Details: Mouse Coordinates&lt;/a&gt; [internet.com]&lt;br /&gt;Tested on Firefox.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!-- ONE STEP TO INSTALL MOUSE COORDINATES:&lt;br /&gt;&lt;br /&gt;  1.  Copy the coding into the BODY of your HTML document  --&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- STEP ONE: Paste this code into the BODY of your HTML document  --&gt;&lt;br /&gt;&lt;br /&gt;&lt;BODY&gt;&lt;br /&gt;&lt;br /&gt;&lt;form name="Show"&gt;&lt;br /&gt;X &lt;input type="text" name="MouseX" value="0" size="4"&gt;&lt;br&gt;&lt;br /&gt;Y &lt;input type="text" name="MouseY" value="0" size="4"&gt;&lt;br&gt;&lt;br /&gt;&lt;/form&gt;&lt;br /&gt;&lt;br /&gt;&lt;script language="JavaScript1.2"&gt;&lt;br /&gt;&lt;!-- Original:  CodeLifter.com (support@codelifter.com) --&gt;&lt;br /&gt;&lt;!-- Web Site:  http://www.codelifter.com --&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- This script and many more are available free online at --&gt;&lt;br /&gt;&lt;!-- The JavaScript Source!! http://javascript.internet.com --&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- Begin&lt;br /&gt;  var IE = document.all?true:false;&lt;br /&gt;  if (!IE) document.captureEvents(Event.MOUSEMOVE)&lt;br /&gt;    document.onmousemove = getMouseXY;&lt;br /&gt;    &lt;br /&gt;  var tempX = 0;&lt;br /&gt;  var tempY = 0;&lt;br /&gt;  &lt;br /&gt;  function getMouseXY(e) {&lt;br /&gt;    if (IE) { // grab the x-y pos.s if browser is IE&lt;br /&gt;      tempX = event.clientX + document.body.scrollLeft;&lt;br /&gt;      tempY = event.clientY + document.body.scrollTop;&lt;br /&gt;    }&lt;br /&gt;    else {  // grab the x-y pos.s if browser is NS&lt;br /&gt;      tempX = e.pageX;&lt;br /&gt;      tempY = e.pageY;&lt;br /&gt;    }  &lt;br /&gt;    &lt;br /&gt;    if (tempX &lt; 0){tempX = 0;}&lt;br /&gt;    if (tempY &lt; 0){tempY = 0;}  &lt;br /&gt;    &lt;br /&gt;    document.Show.MouseX.value = tempX;&lt;br /&gt;    document.Show.MouseY.value = tempY;&lt;br /&gt;    &lt;br /&gt;    return true;&lt;br /&gt;  }&lt;br /&gt;//  End --&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;center&gt;&lt;br /&gt;&lt;font face="arial, helvetica" size"-2"&gt;Free JavaScripts provided&lt;br&gt;&lt;br /&gt;by &lt;a href="http://javascriptsource.com"&gt;The JavaScript Source&lt;/a&gt;&lt;/font&gt;&lt;br /&gt;&lt;/center&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- Script Size:  1.33 KB --&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;*update 10:55am 21-Mar-08*&lt;br /&gt;I have decided to use the following code instead as it looks a bit cleaner, and more up-to-date.&lt;br /&gt;Tested on Firefox 2 and IE 6.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;document.onmousemove = mouseMove;&lt;br /&gt;&lt;br /&gt;function mouseMove(ev){&lt;br /&gt;	ev           = ev || window.event;&lt;br /&gt;	var mousePos = mouseCoords(ev);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function mouseCoords(ev){&lt;br /&gt;	if(ev.pageX || ev.pageY){&lt;br /&gt;		return {x:ev.pageX, y:ev.pageY};&lt;br /&gt;	}&lt;br /&gt;	return {&lt;br /&gt;		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,&lt;br /&gt;		y:ev.clientY + document.body.scrollTop  - document.body.clientTop&lt;br /&gt;	};&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Reference: &lt;a href="http://snipr.com/22a5e"&gt;How to Drag and Drop in JavaScript&lt;/a&gt; [webreference.com]</description>
      <pubDate>Thu, 20 Mar 2008 22:39:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5264</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Xlib - mouseMove</title>
      <link>http://snippets.dzone.com/posts/show/2743</link>
      <description>// muove il mouse alle coordinate currentX + x, currentY + y&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;&lt;br /&gt;#include &lt;X11/Xlib.h&gt;&lt;br /&gt;#include &lt;X11/Xutil.h&gt;&lt;br /&gt;&lt;br /&gt;void mouseMove(int x, int y)&lt;br /&gt;{&lt;br /&gt;	Display *displayMain = XOpenDisplay(NULL);&lt;br /&gt;&lt;br /&gt;	if(displayMain == NULL)&lt;br /&gt;	{&lt;br /&gt;		fprintf(stderr, "Errore nell'apertura del Display !!!\n");&lt;br /&gt;		exit(EXIT_FAILURE);&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	XWarpPointer(displayMain, None, None, 0, 0, 0, 0, x, y);&lt;br /&gt;&lt;br /&gt;	XCloseDisplay(displayMain);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;// gcc source.c -L /usr/X11R6/lib -lX11</description>
      <pubDate>Sat, 30 Sep 2006 16:18:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2743</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>Memcached StartupItem for Mac OS X</title>
      <link>http://snippets.dzone.com/posts/show/2618</link>
      <description>&lt;br /&gt;Here is an OS X StartupItem for memcached...&lt;br /&gt;&lt;br /&gt;/Library/StartupItems/Memcached/StartupParameters.plist &lt;br /&gt;&lt;code&gt;&lt;br /&gt;{&lt;br /&gt;  Provides        = ("Memcached");&lt;br /&gt;  Description     = "Memcache Daemon";&lt;br /&gt;  Uses            = ("Network");&lt;br /&gt;  OrderPreference = "None";&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;/Library/StartupItems/Memcached/Memcached&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;#&lt;br /&gt;# /Library/StartupItems/Memcached/Memcached&lt;br /&gt;#&lt;br /&gt;# Script to startup memcached with OS X. Tested on 10.4 Tiger&lt;br /&gt;#&lt;br /&gt;# To enable, copy this file and StartupParameters.plist to&lt;br /&gt;# /Library/StartupItems/Memcached and add "MEMCACHED=-YES-"&lt;br /&gt;# to /etc/hostconfig ... You can then reboot or execute &lt;br /&gt;# "sudo /sbin/SystemStarter start Memcached" from a terminal&lt;br /&gt;# to start it up.&lt;br /&gt;#&lt;br /&gt;# I should mention that this file uses my preferred development &lt;br /&gt;# settings. You can edit them before copying this script over &lt;br /&gt;# or they can be overriden by creating a config file named &lt;br /&gt;# memcached.conf in /etc, /opt/etc, or /usr/local/etc with the &lt;br /&gt;# following contents (modified to suit, of course):&lt;br /&gt;#&lt;br /&gt;#   MEMCACHED_EXE=/usr/local/bin/memcached&lt;br /&gt;#   MEMCACHED_PIDFILE=/var/run/memcached.pid&lt;br /&gt;#   MEMCACHED_MAX_MEM=128&lt;br /&gt;#   MEMCACHED_INTERFACE=127.0.0.1&lt;br /&gt;#   MEMCACHED_PORT=1121&lt;br /&gt;#   MEMCACHED_RUN_AS=nobody &lt;br /&gt;#&lt;br /&gt;# ------------------------------------------------------------------- &lt;br /&gt;# NOTE: Memcached &lt; 1.2.0 has issues specifying the interface via the&lt;br /&gt;# '-l' switch on the Mac for some reason so if the service fails to &lt;br /&gt;# start with the following error:&lt;br /&gt;#&lt;br /&gt;#    bind(): Can't assign requested address&lt;br /&gt;#    failed to listen&lt;br /&gt;#&lt;br /&gt;# then you will need to either upgrade to version 1.2.0+ or forgo&lt;br /&gt;# specifying an interface to listen on by removing the references&lt;br /&gt;# to A_INTERFACE on lines 65 and 75 of this script. &lt;br /&gt;# ------------------------------------------------------------------- &lt;br /&gt;#&lt;br /&gt;# Tim Ferrell &lt;s0nspark@gmail.com&gt;&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;# Suppress the annoying "$1: unbound variable" error &lt;br /&gt;if [ -z $1 ] ; then&lt;br /&gt;  echo "Usage: $0 [start|stop|restart] "&lt;br /&gt;  exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;# Source the common setup functions for startup scripts&lt;br /&gt;test -r /etc/rc.common || exit 1&lt;br /&gt;source /etc/rc.common&lt;br /&gt;&lt;br /&gt;NAME=memcached&lt;br /&gt;DESC="Memcached server"&lt;br /&gt;&lt;br /&gt;# look for a config file name ${NAME}.conf in /etc, /opt/etc, &lt;br /&gt;# and /usr/local/etc ... in that order.&lt;br /&gt;[ -r /etc/${NAME}.conf ] &amp;&amp; source /etc/${NAME}.conf&lt;br /&gt;[ -r /opt/etc/${NAME}.conf ] &amp;&amp; source /opt/etc/${NAME}.conf&lt;br /&gt;[ -r /usr/local/etc/${NAME}.conf ] &amp;&amp; source /usr/local/etc/${NAME}.conf&lt;br /&gt;&lt;br /&gt;# these are _my_ defaults... &lt;br /&gt;DAEMON="${MEMCACHED_EXE:=/usr/local/bin/memcached}"&lt;br /&gt;A_PIDFILE="-P ${MEMCACHED_PIDFILE:=/var/run/memcached.pid}"&lt;br /&gt;A_MAXMEM="-m ${MEMCACHED_MAX_MEM:=128}"&lt;br /&gt;A_INTERFACE="-l ${MEMCACHED_INTERFACE:=127.0.0.1}"&lt;br /&gt;A_PORT="-p ${MEMCACHED_PORT:=11211}"&lt;br /&gt;A_RUNAS="-u ${MEMCACHED_RUN_AS:=nobody}"&lt;br /&gt;&lt;br /&gt;StartService () &lt;br /&gt;{&lt;br /&gt;  if [ "${MEMCACHED:=-NO-}" = "-YES-" ] &amp;&amp; ! GetPID ${NAME} &gt; /dev/null; then&lt;br /&gt;    if [ -f /var/run/${NAME}.StartupItem ] ; then exit ; fi&lt;br /&gt;    touch /var/run/${NAME}.StartupItem&lt;br /&gt;    echo "Starting ${DESC}"&lt;br /&gt;    ${DAEMON} -d ${A_PIDFILE} ${A_MAXMEM} ${A_INTERFACE} ${A_PORT} ${A_RUNAS} &lt;br /&gt;  fi&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;StopService ()&lt;br /&gt;{&lt;br /&gt;  if PID=$(GetPID ${NAME}); then&lt;br /&gt;    echo "Stopping ${DESC}, (PID ${PID})"&lt;br /&gt;    kill -TERM "${PID}"&lt;br /&gt;    rm -f ${A_PIDFILE}&lt;br /&gt;  else&lt;br /&gt;    echo "${DESC} not running."&lt;br /&gt;  fi&lt;br /&gt;  rm -f /var/run/${NAME}.StartupItem&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;RestartService () { StopService; StartService; }&lt;br /&gt;&lt;br /&gt;if test -x $DAEMON ; then&lt;br /&gt;  RunService "$1"&lt;br /&gt;else&lt;br /&gt;  echo "Could not find ${DAEMON}!"&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt; &lt;br /&gt;</description>
      <pubDate>Sun, 17 Sep 2006 22:15:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2618</guid>
      <author>s0nspark (Tim Ferrell)</author>
    </item>
    <item>
      <title>One-click connect from cygwin to full-screen Linux (X stuff required)</title>
      <link>http://snippets.dzone.com/posts/show/1298</link>
      <description>Optional: execute the following once (see http://hacks.oreilly.com/pub/h/66 for &lt;br /&gt;details), to avoid typing in the password.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;set LINUX_HOST=mylinuxhost&lt;br /&gt;ssh-keygen -t rsa&lt;br /&gt;ssh %USERNAME%@%LINUX_HOST% "mkdir .ssh; chmod 0700 .ssh"&lt;br /&gt;bash -c 'scp ~/.ssh/id_rsa.pub %LINUX_HOST%:.ssh/authorized_keys2'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Now, if you save the following as a BATCH file, you can just click it &lt;br /&gt;to connect to fullscreen Linux: &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;set LINUX_HOST=mylinuxhost&lt;br /&gt;start /min xinit &lt;br /&gt;xhost +%LINUX_HOST%&lt;br /&gt;ssh %LINUX_HOST% "declare -x DISPLAY=%COMPUTERNAME%:0; echo $DISPLAY;gnome-session"'&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;NOTES: &lt;br /&gt;1. &lt;br /&gt;Sometimes xhost + does not execute in time. O well. Just close&lt;br /&gt;all windows that got opened and try again.&lt;br /&gt;&lt;br /&gt;2.&lt;br /&gt;If you didn't do the step one (ssh keys), you will be prompted &lt;br /&gt;to enter the linux password; this increases the chances of the above&lt;br /&gt;error.&lt;br /&gt;&lt;br /&gt;3.&lt;br /&gt;The single terminal window appearing in the Linux desktop is in fact &lt;br /&gt;a window from your PC. &lt;br /&gt;&lt;br /&gt;</description>
      <pubDate>Wed, 25 Jan 2006 22:13:49 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1298</guid>
      <author>debedb (http://www.hrum.org)</author>
    </item>
  </channel>
</rss>
