03 July 2012
28 July 2011
14 March 2011
créatúir saorga
Tá rath ar mo chuid créatúir saorga. Tá siad ag ithe, ag cúpláil, agus ag fuascailt fadhbanna. Beidh muid réidh smacht a chur ar an domhain gan mhoill. Mwah ha ha ha!
Ach ar dtús, caithfidh mé scríobh mo thráchtas agus cúpla páipéar.
My little a-life creatures are thriving. They're eating, mating, and solving puzzles. We'll be ready to take over the world soon. Mwah ha ha ha!
But first, I've a thesis and a couple of papers to write.
Ach ar dtús, caithfidh mé scríobh mo thráchtas agus cúpla páipéar.
My little a-life creatures are thriving. They're eating, mating, and solving puzzles. We'll be ready to take over the world soon. Mwah ha ha ha!
But first, I've a thesis and a couple of papers to write.
10 December 2010
14 November 2010
OpenDNS - Treoir Gearr do Usáideorí Debian
OpenDNS - Treoir Gearr do Usáideorí Debian | OpenDNS - Quick Start for Debian Users |
Tá na treoracha seo níos giorra ná na cinn Gentoo.De gnáth, caithfidh tú /etc/resolv.conf a chur in eagar, agus deimhnigh ní athróidh rud ar bith é. Ach tá muid ábalta an stuif sin a fhágáil ar lar mar bheidh muid ag suiteáil pdnsd mar taisc DNS. Nuair a shuiteálann Debian pdnsd, déanann sé an stuif eile sin. | These instructions are a lot shorter than the ones for Gentoo users. Normally you would have to edit /etc/resolv.conf, and make sure that nothing will overwrite your changes. However, we can skip all that because if you're using OpenDNS, you'll probably want a local DNS cache so your computer doesn't have to go back to OpenDNS for subsequent queries. I used pdnsd. When Debian installs pdnsd, it does that other stuff for us. |
1. Suiteáil pdnsd. | 1. Install pdnsd. |
aptitude install pdnsd | |
Roghnaigh "manual" mar "pdnsd configuration method". | When asked to select the pdnsd configuration method, choose "manual". |
2. Cumraigh pdnsd. | 2. Configure pdnsd. |
Cuir an roinn "server" in eagair mar an sampla seo a leanas. Scrios an /* roimhe sin agus an */ ina dhiaidh sin. | Edit the "server" section in /etc/pdnsd.conf, following the example below. Be sure to uncomment it by removing the /* before and the */ after it. |
server { label = "root-servers"; root_server=on; ip = 208.67.222.222 , 208.67.220.220 ; timeout = 5; uptest = query; interval = 30m; // Test every half hour. ping_timeout = 300; // 30 seconds. purge_cache = off; exclude = .localdomain; policy = included; preset = off; } | |
3. Tosaigh pdnsd. | 3. Start pdnsd. |
/etc/init.d/pdnsd start | |
Má bhfaigheann tú teachtaireacht mar "Could not bind tcp socket: Address already in use", b'fheidir go bhfuil named ag rith. Stop é le killall named. | If you get messages such as "Could not bind tcp socket: Address already in use", you might have named running. Stop it with killall named. |
4. Deimhnigh go feidhmíonn sé le ceist úr. | 4. Verify that it works for fresh queries. |
dig www.opendns.com | |
Seo toradh ceart: | The result should look like this: |
; <<>> DiG 9.4.2-P2 <<>> www.opendns.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7419 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.opendns.com. IN A ;; ANSWER SECTION: www.opendns.com. 30 IN A 208.67.219.101 ;; Query time: 927 msec ;; SERVER: 208.67.220.220#53(208.67.220.220) <-- OpenDNS server ;; WHEN: Sat Nov 15 18:46:44 2008 ;; MSG SIZE rcvd: 49 | |
5. Deimhnigh go úsáidtear sonraí thaiscthe le hathceist. | 5. Verify that it uses cached data for repeated queries. |
Eisigh an ceist céanna dig (dig www.opendns.com) faoi dhó, agus breathnaigh ar an líne ;; Query time:. An darna uair ba cheart do beagnach ar an toirt mar tá an eolas sa taisc cheana féin. | Run the same dig query (dig www.opendns.com) again, and look for the ;; Query time: line. The second time it should be nearly instantaneous because the information is already in the cache. |
13 November 2010
Blúire Téacs ar Linux, le feidhmchlár ar bith
Seo cúpla script a dhéanamh blúire téacs ar Linux, le feidhmchlár ar bith. Ní gá leat ach ceann amháin acu. Léigh na nótaí tráchta le roghnaigh.
Here are a couple of scripts that implement text snippets in Linux, in any application. You only need one of them. Read the comments to decide which is best for you.
snippy
snippy1line
Here are a couple of scripts that implement text snippets in Linux, in any application. You only need one of them. Read the comments to decide which is best for you.
snippy
#!/bin/bash # # Based on "snippy" by "sessy" # (https://bbs.archlinux.org/viewtopic.php?id=71938) # # You will also need "dmenu", "xsel" and "xdotool". Get them from your linux # distro in the usual way. # # To use: # 1. Create the directory ~/.snippy # # 2. Create a file in that directory for each snippet that you want. # The filename will be used as a menu item, so you might want to # omit the file extension when you name the file. # # TIP: If you have a lot of snippets, you can organise them into # subdirectories under ~/.snippy. # # TIP: The contents of the file will be pasted asis, so if you # don't want a newline at the end when the text is pasted, don't # put one in the file. # # 3. Bind a convenient key combination to this script. # # TIP: If you're using XMonad, add something like this to xmonad.hs # ((mod4Mask, xK_s), spawn "/path/to/snippy") # DIR=${HOME}/.snippy DMENU_ARGS="-b -nf green -nb black -sf yellow -sb black" XSEL_ARGS="--clipboard --input" cd ${DIR} # Use the filenames in the snippy directory as menu entries. # Get the menu selection from the user. FILE=`find . -type f | grep -v '^\.$' | sed 's!\.\/!!' | /usr/bin/dmenu ${DMENU_ARGS}` if [ -f ${DIR}/${FILE} ]; then # Put the contents of the selected file into the paste buffer. xsel ${XSEL_ARGS} < ${DIR}/${FILE} # Paste into the current application. xdotool key ctrl+v fi
snippy1line
#!/bin/bash # # Based on "snippy" by "sessy" # (https://bbs.archlinux.org/viewtopic.php?id=71938) # # This version may be more convenient for people who only need # one-line snippets, because all your snippets can go in one file. # # You will also need "dmenu", "xsel" and "xdotool". Get them from your linux # distro in the usual way. # # To use: # 1. Create a file in your home directory called ".snippyrc". # # 2. The format of the file is shown below: # # [tag] text_to_paste # # Where "[tag]" starts in column 1. For example: # # [hw] Hello, world! # [wombatSmilie] [img]http://nualeargais.ie/pictiuir/emoticons/wombatSmilie.gif[/img] # # 3. Bind a convenient key combination to this script. # # TIP: If you're using XMonad, add something like this to xmonad.hs # ((mod4Mask, xK_s), spawn "/path/to/snippy") # CONFIG=${HOME}/.snippyrc DMENU_ARGS="-b" XSEL_ARGS="--clipboard" # Display the menu and get the selection SELECTION=`sed 's/\].*/]/' ${CONFIG} | /usr/bin/dmenu ${DMENU_ARGS}` # Strip out the square brackets... PATTERN=`echo ${SELECTION} | tr -d "[]"` # ...and put them back in, escaped with a backslash. # Get the text associated with the selection. TEXT=`grep "\[${PATTERN}\]" ~/.snippets | sed "s/\[${PATTERN}\] //"` if [ "${TEXT}" ]; then # Put the selected string (without the trailing newline) into the paste buffer. echo -n ${TEXT} | xsel ${XSEL_ARGS} # Paste into the current application. xdotool key ctrl+v fi
Haskell daemon, cuid a dó
D'athfhachtóirigh (refactored) mé an cód:
Daemon.hs
Seo úsáid samplach:
Main.hs
Daemon.hs
module Daemon where import System.Exit import System.IO.Unsafe import System.Posix.Signals import Control.Concurrent class DaemonState a where initialise :: IO a work :: a -> IO a finalise :: a -> IO () termReceived = unsafePerformIO (newMVar False) handleTERM :: IO () handleTERM = swapMVar termReceived True >> return () loop :: (DaemonState a) => a -> IO (Maybe a) loop d = do timeToStop <- readMVar termReceived if timeToStop then finalise d >> return Nothing else work d >>= loop start :: (DaemonState a) => IO (Maybe a) start = installHandler sigTERM (Catch handleTERM) Nothing >> initialise >>= loop
Seo úsáid samplach:
Main.hs
module Main where import Daemon instance DaemonState Int where initialise = do putStrLn "Starting up" return 0 work i = do putStrLn (show i) return (i+1) finalise i = do putStrLn "Shutting down" return () main = start :: IO (Maybe Int)
12 November 2010
Haskell daemon
Seo sampla daemon Haskell:
import System.Exit
import System.IO.Unsafe
import System.Posix.Signals
import Control.Concurrent
termReceived = unsafePerformIO (newMVar False)
handleTERM :: IO ()
handleTERM = do
swapMVar termReceived True
return ()
wrapup :: IO ()
wrapup = do
-- Shut down cleanly
putStrLn "shutting down"
return ()
doWork :: IO ()
doWork = do
-- For now, just pretend we're doing something
putStrLn "working"
threadDelay 20000
loop :: IO ()
loop = do
timeToStop <- readMVar termReceived
if timeToStop
then wrapup
else do
doWork
loop
main = do
installHandler sigTERM (Catch handleTERM) Nothing
loop
Údaraigh cabal pacáistí a shuiteáil go huilíoch mar réamhshocrú
(Turn on --global by default in cabal)
Cuir ~/.cabal/config in eagar
user-install: False
root-cmd: sudo
Cuir ~/.cabal/config in eagar
user-install: False
root-cmd: sudo
Cuir úsáideoir le liosta "sudoers"
Mar root, clóscríobh visudo
Scrollaigh go:
root ALL=(ALL) ALL
user ALL=(ALL) ALL <-- Clóscríobh an líne seo
Scrollaigh go:
root ALL=(ALL) ALL
user ALL=(ALL) ALL <-- Clóscríobh an líne seo
aptitude install git doesn't!
Nach sílfeá gurb é an rud a dhéanfadh an t-ordú aptitude install git ná git a shuiteáil? Bhuel, ní bheadh an ceart agat. Ina áit sin, cuir an líne seo le /etc/apt/sources.list:
deb http://backports.debian.org/debian-backports lenny-backports main contrib non-free
Agus ansin, clóscríobh an t-ordú seo:
aptitude -t lenny-backports install git
Running aptitude install git on Lenny doesn't actually install git! Instead, put the following in /etc/apt/sources.list:
deb http://backports.debian.org/debian-backports lenny-backports main contrib non-free
And then do:
aptitude -t lenny-backports install git
deb http://backports.debian.org/debian-backports lenny-backports main contrib non-free
Agus ansin, clóscríobh an t-ordú seo:
aptitude -t lenny-backports install git
Running aptitude install git on Lenny doesn't actually install git! Instead, put the following in /etc/apt/sources.list:
deb http://backports.debian.org/debian-backports lenny-backports main contrib non-free
And then do:
aptitude -t lenny-backports install git
Subscribe to:
Posts (Atom)