Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts
03 July 2012
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
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
31 October 2010
Debian
Tar éis seacht mbliana le Gentoo, tá sé in am distro nua a thriall. Gach cúpla mí, bhriseadh an shuiteáil le uasghrádú éigin, agus tá mé tinn tuirseach dé. Is maith liom an smacht atá agam le Gentoo, ach silim nach bhfuil an QA ro-mhaith le déanaí.
Tá mé ag baint triall as Debian anois. Ba choir domh cúpla cleas Haskell Platform na linne a shuiteáil, agus XMonad na linne freisin, ach tá sé ceart go leor anois. Tá cúpla breiseáin nach bhfuil ar fáil le IceWeasel (an Firefox fork atá ar fáil le Debian de thairbe licensing issues).
An mbeidh Debian níos fearr domh? Is maith an scéalaí an aimsir.
Tá mé ag baint triall as Debian anois. Ba choir domh cúpla cleas Haskell Platform na linne a shuiteáil, agus XMonad na linne freisin, ach tá sé ceart go leor anois. Tá cúpla breiseáin nach bhfuil ar fáil le IceWeasel (an Firefox fork atá ar fáil le Debian de thairbe licensing issues).
An mbeidh Debian níos fearr domh? Is maith an scéalaí an aimsir.
17 August 2009
Teachtaireacht grinn i nGentoo
Bhí mé ag déanamh "emerge" iontach mór, agus chonaic mé an teachtaireacht seo:
"Unpacking OO.o build tree - [ go and have some tea ] ..."
An-chomhairle ar fad!
"Unpacking OO.o build tree - [ go and have some tea ] ..."
An-chomhairle ar fad!
11 July 2008
Gnome Do
Tá mé ag baint úsáid as Katapult feidhmchláir a thosú le tamall fada. Ach d'aimsigh mé clar gur níos fearr liom, Gnome Do. Tá sé ina cosúil le Quicksilver ar Mac.
Bíonn an cuid is mó de na lainseálaí tascanna faoi thiomáint roghchláir. Ní mór duit coinnigh do chuid roghchláir eagraithe, ach níl sin éasca má úsáideann tú a lán feidhmchláir agus tú i gcónaí suiteáil cinn nua. Is minic gur chuimhin liom an catagóir a chuir mé an feidhmchlár faoi.
Ach tá córas difriúil i nGnome Do. Is feidir leat clóscríobh cúpla carachtar, agus molfaidh Gnome Do an feidhmchlár a ba mhaith leat. (Tá Katapult ábalta é sin a dhéanamh, ach tá sé níos teorantaí ná Gnome Do.) Cuireann Gnome Do in oiriúint do do nósanna, agus éiríonn na tuairimí níos fearr.
Note: Tá an ebuild Gentoo do Gnome Do mascáilte faoi láthair. Seo an chaoi a shuiteáil mé Gnome Do:
flagedit gnome-extra/gnome-do -- +~x86
flagedit dev-dotnet/dbus-glib-sharp -- +~x86
flagedit dev-dotnet/dbus-sharp -- +~x86
I've been using Katapult as my application launcher for a while, but I've found something I prefer Gnome Do. It's inspired by Quicksilver on Mac.
Most app launchers are menu-driven. You have to keep your menus organised, which isn't easy if you have a lot of apps and you're always installing new ones. I often forget which category I put an app under.
But Gnome Do uses a different approach. You can type a couple of letters, and Gnome Do will suggest the application it thinks you want. (Katapult does this too, but in a more limited way.) Gnome do adapts to your habits, and gets better at guessing.
Note: The Gentoo ebuild for Gnome Do is currently masked. Here's how I installed it:
flagedit gnome-extra/gnome-do -- +~x86
flagedit dev-dotnet/dbus-glib-sharp -- +~x86
flagedit dev-dotnet/dbus-sharp -- +~x86
I know dozens of languages (of the computer variety), and I'm fluent in Java. But alas, my Irish is full of syntax errors and isn't Turing-complete. So don't model your Irish on mine.
Bíonn an cuid is mó de na lainseálaí tascanna faoi thiomáint roghchláir. Ní mór duit coinnigh do chuid roghchláir eagraithe, ach níl sin éasca má úsáideann tú a lán feidhmchláir agus tú i gcónaí suiteáil cinn nua. Is minic gur chuimhin liom an catagóir a chuir mé an feidhmchlár faoi.
Ach tá córas difriúil i nGnome Do. Is feidir leat clóscríobh cúpla carachtar, agus molfaidh Gnome Do an feidhmchlár a ba mhaith leat. (Tá Katapult ábalta é sin a dhéanamh, ach tá sé níos teorantaí ná Gnome Do.) Cuireann Gnome Do in oiriúint do do nósanna, agus éiríonn na tuairimí níos fearr.
Note: Tá an ebuild Gentoo do Gnome Do mascáilte faoi láthair. Seo an chaoi a shuiteáil mé Gnome Do:
flagedit gnome-extra/gnome-do -- +~x86
flagedit dev-dotnet/dbus-glib-sharp -- +~x86
flagedit dev-dotnet/dbus-sharp -- +~x86
I've been using Katapult as my application launcher for a while, but I've found something I prefer Gnome Do. It's inspired by Quicksilver on Mac.
Most app launchers are menu-driven. You have to keep your menus organised, which isn't easy if you have a lot of apps and you're always installing new ones. I often forget which category I put an app under.
But Gnome Do uses a different approach. You can type a couple of letters, and Gnome Do will suggest the application it thinks you want. (Katapult does this too, but in a more limited way.) Gnome do adapts to your habits, and gets better at guessing.
Note: The Gentoo ebuild for Gnome Do is currently masked. Here's how I installed it:
flagedit gnome-extra/gnome-do -- +~x86
flagedit dev-dotnet/dbus-glib-sharp -- +~x86
flagedit dev-dotnet/dbus-sharp -- +~x86
I know dozens of languages (of the computer variety), and I'm fluent in Java. But alas, my Irish is full of syntax errors and isn't Turing-complete. So don't model your Irish on mine.
Subscribe to:
Posts (Atom)

