Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like
Application Management
The Best Way to Tweet to Twitter, Post on Facebook from WordPress
Jul 26th
I’ve been focusing some time recently to the foundation levels of Internet marketing. I’m aiming to increase visibility as strongly as possible at the core of a website giving it the power to leverage evolving trends as simply as possible. This of course means utilizing APIs from other web applications, such as social networks. The title of this post is true but deceptive. I consider the following method the best way to tweet from WordPress but it’s actually a whole lot more than that. It’s a gateway to a large number of social media applications; one account to rule them all. ping.fm is a service that allows you to link multiple social network websites, such as facebook, twitter, linkedin and more.
So the idea then, is to leverage then is to utilize the ping.fm application from your website. If you’re using WordPress then you’re set, the simple no frills publish 2 ping.fm plugin will allow you to interact with ping.fm from your blog/website.
I’ve tested this out with the free open-source GPL First Person Shooter, Xonotic and a new site I just started dumbtubes.com. Both have twitter accounts that you can see publishing twitter.com/dumbtubes, twitter.com/xonotic. Xonotic also publishes to many other social accounts, see the Xonotic homepage to find other accounts.
Stay tuned for more wordpress tips.
Blocking Ads Cross-browser and Save Bandwith Using Your Hosts file
May 26th
Ethics of blocking ads vs. data mining aside, one of the smartest ways I found to block ads is at http://someonewhocares.org/hosts/zero/ where the author, Dan Pollock has compiled a list of urls, with the help of contributors that all redirect to 0.0.0.0 or 127.0.0.1 (localhost, your machine). By appending this list to your current hosts file (or selectively adding parts), whenever your machine attempts to look up a domain name in this list, it will resolved to 0.0.0.0 or your machine. It will never make a request on the internet to the intended server. It will never even download the advertisement.
To take this a step further, you could develop a similar list for your router or DNS server (if you operate it).
I still use adblock plus on top for missed entries.
The “easy” way to listen to internet radio in Ubuntu
Jul 15th
I started with rhythmbox like most new Ubuntu users. It seemed nice enough but not in the area I was concerned with, internet radio. I tried out many players but was disappointed with different areas of different players. From Ubuntu 8.04 to 8.10 I was using the “good” Amarok (for KDE 3.5). Disappointed by the exclusion of that version in Ubuntu Jaunty 9.04 and unimpressed with workarounds like the PPA’s, I decided to play the field. I came across Exaile, which I’ve blogged about in the past. It’s a good enough player… most of the time. It crashed too often for my likings and I’m getting sick of pkilling it.
It struck me today that I needed a simplier more streamlined solution for my simple needs. I needed a console application. Through a little research, I found moc, which happens to play shoutcast streams as I’ve become accustom to.
I then proceeded to set myself the following way:
sudo apt-get install moc mkdir -p ~/Music/internet_radio && cd ~/Music/internet_radio wget -r -l2 -nd -Nc -A.pls http://www.di.fm/index.php for file in *.pls; do mocp -a $file; done mocp
1) Installed moc
2) created a directory to download all the playlists from di.fm (since this is the station I listen to most often)
3) wget all the playlists
4) add them all to moc
5) start moc and [tab] to the play list side, enter to play
enter -- starts playing
s -- stops playing
n -- plays next item from the playlist
b -- plays previous item from the playlist
space -- pause
p -- pause
S -- plays at random
R -- repeats the same song in a loop,
Next (X button below) must be OFF
X -- switches to play sequentially
o -- plays a file from the Internet
u -- moves playlist item up
j -- moves playlist item down
Ctrl+u -- adds the URL to the playlist
g -- searches marked string in file names
/ -- searches marked string in file names
r -- rereads the directory
T -- switches to the theme selection menu
f -- toggles display mode of song titles
TAB -- switches marker bar between the playlist
and the file manager panels
l -- switches between displaying the playlist
or the file manager panel
P -- switches full path in the playlist
H -- toggles hidden files view
Ctrl-t -- toggles song duration time
Ctrl-f -- toggles format file view
m -- moves to directory entered in config file
G -- moves to directory with currently played file
i -- moves to marked directory
U -- moves to upper directory
a -- adds a file to the playlist
A -- adds a directory recursively to the playlist
C -- clears the playlist
V -- saves the playlist
d -- removes marked item from the playlist
Y -- removes all empty items from the playlist
< -- decreases volume by 1%
, -- decreases volume by 5%
> -- increases volume by 1%
. -- increases volume by 5%
x -- toggles the mixer channel
? -- shows help
! -- goes to a fast dir 1 (set in config file)
@ -- goes to a fast dir 2
# -- goes to a fast dir 3
$ -- goes to a fast dir 4
% -- goes to a fast dir 5
^ -- goes to a fast dir 6
& -- goes to a fast dir 7
* -- goes to a fast dir 8
( -- goes to a fast dir 9
) -- goes to a fast dir 10
F1 -- executes ExecCommand1 (set in config file)
F2 -- executes ExecCommand2
F3 -- executes ExecCommand3
F4 -- executes ExecCommand4
F5 -- executes ExecCommand5
F6 -- executes ExecCommand6
F7 -- executes ExecCommand7
F8 -- executes ExecCommand8
F9 -- executes ExecCommand9
F10 -- executes ExecCommand10
Above commands from polish linux’s article on moc audo player, great resource.
whygitisbetterthanx.com – Explaining git
May 17th
Trying to avoid looking like a fanboy but whygitisbetterthanx.com is a really well done website explaining the pros of Git version control.
Cool XUL tricks with Firefox using Stylish
Apr 13th
Firefox is an excellent browser that runs on an open, extendable platform by Mozilla which many users have improved through the creation of extensions, themes and add-ons. As a web developer / design and code hobbyist, I’m always looking for ways to give myself more power out of my browser and communicate ideas visually in the most efficient way. Using Stylish (a program that runs css on top of userStyles.css), I’ve found I can not only edit the looks of webpages with CSS but XUL, the building language of Firefox. This allows for some nice little enhancements.
Align Bookmarks to the Top Right
Here’s one I brewed up myself spawning from an discussion on IRC where someone pointed out the clutter I had going on in my bookmarks toolbar, I set out to condense my collection.
The plan was to align a few folders to the top right of my browser at the same level as my file menu and remove the bookmarks toolbar. Sounds easy enough right? Well.. perhaps it’s my ignorance in the XUL / CSS relationship that doesn’t allow me to float boxes but I actually ended up doing a strange little trick to make this successful.
To figure out how to get it to align to the right, I had to first figure out some class and id names. That I started trying different atrributes with….
Until I came up with the code below.
/* Align Bookmarks to the top right of Firefox Tyler Mulligans www.doknowevil.net -- Right click the your file menu and click customize to drag around your bookmarks. */ @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); #toolbar-menubar { direction:rtl !important; } #toolbar-menubar #menubar-items, #toolbar-menubar .bookmarks-toolbar-items { direction:ltr !important; }
Using that code in stylish, I right clicked my file menu, click customize and dragged my file menu, bookmarks and loader to their appropriate places.
Fixing webpages that don’t explicitly define the background and foreground as white and black
I changed my default background color so that I’m not blinded by white when I open a new blank tab. Unfortunately many web developers assume that users have a white background with black text and don’t bother to explicitly define them. I use the script below to fix 95% of these pages… some just use inheritently bad design techniques like defining their background color in the html tag (something w3c recommended you DON’T do in HTML. While technically okay in XHTML, I think it’s better to use the first VISUAL tag on the page. After the HTML tag you have a head… and title.. etc, which technically inherit the HTML tag settings.
@-moz-document url-prefix(http://), url-prefix(https://) { body { background-color:#fff; color:#000; } }Theme specific enhancements
I use an unusual brown theme and I’ve do what I can to match and extend my applications. I borrowed and enhanced the scripts below
Tabs / Tab Bar
A darker background and more prominent selected tab (pictured above)
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); [class="close-button tabs-closebutton"], .tabbrowser-tabs tab[selected="true"] { -moz-appearance: none !important; background-color: #654C30 !important; } .tabbrowser-tab[selected="true"] .tab-text { color: white !important; -moz-opacity: .85 !important; } .tabbrowser-tab[selected="true"]:hover { -moz-opacity: 1 !important; background-color: #755533 !important; } .tabbrowser-tabs { border-top:1px solid #5F4A2A; border-bottom:2px solid #503C1E; background-color:#120F0B !important; padding:5px 1px 0 1px; }
Awesome Bar
Added colors to match my theme.
/* _________________________________________________________________________ | | | | Title: | Awesome Bar Background Color Based on Type (WOW) | | Description: | Different Colors based on Bookmark, tag, or regular | | Author: | -=Ben=- | | Date Created: | July 3, 2008 | | Last Updated: | October 7, 2008 | | Version: | 1.0.0.3 | |__________________|______________________________________________________| */ @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); .autocomplete-richlistitem[type="bookmark"] /*Blue*/ { background-color: #45586A; /*#E3FCFE;*/ color: #fff; } .autocomplete-richlistitem[type="favicon"] /*Green*/ { background-color: #556A45; /*#E3FEE5;*/ color: #fff; } .autocomplete-richlistitem[type="tag"] /*Yellow*/ { background-color: #6A5745; color: #fff; } .autocomplete-richlistitem:focus { background-color: #0A246A; color: #FFFFFF; }
If you enjoy my theme, you can download a beta I’ve been working on here: http://z.nexuizninjaz.com/linux/themes/
Ubuntu Window Management with Multiple Monitors, Window Effects and Default File Associations
Nov 25th
Multiple Monitors Window Management in Ubuntu
Moving your applications from one monitor to the next with hotkeys
I’ve been using multiple monitors for a while now, Starting with a 17″ CRT with a 19″ CRT and moving up to two 19″ LCD, then 3, then temporarily one wide screen and back to 2. Something I always loved having as a utility in ultramon that I couldn’t find in Ubuntu (Gnome) or any window manager for that matter, was the ability to move applications from monitor to monitor. I had assumed the search futile until I was searching about some questions I had concerning Compiz-fusion with dual monitors and I came about this thread on Ubuntu forums which brightened up my day. A fellow named gfixler posted a bash script that utilizes command line applications to move the windows.
For you multi-monitor users seeking salvation from removing your hand from the keyboard to move your application from one monitor to another, here’s the skinny on getting it setup using compiz-fusion, aka Advanced Desktop Effects, to set my keybinds.
1. Open a terminal and setup your prerequisites with apt-get:
sudo apt-get install wmctrl xprop xwininfo
If you get errors about x11-utils, just ignore them, this package will handle your needs.
2. Next, lets put the script somewhere you can call it, say “~/scripts”
mkdir ~/scripts && cd ~/scripts && touch movewin.sh && chmod +x movewin.sh && gedit movewin.sh
2. Paste the following code, find the first function “getNumberOfMonitors” and configure it to the number of monitors you have (default 2).
#!/bin/bash # swap_monitor.sh (original version) # Moves the active window to the other screen of a dual-screen Xinerama setup. # # movewin.sh (modified version) # allows movement of windows left and right between multiple monitors # # Requires: wmctrl, xprop, xwininfo # # Original Author: Raphael Wimmer # raphman@gmx.de # # Modified by: Gary Fixler # gfixler+bash@gmail.com function getNumberOfMonitors { # simply must be hardcoded # e.g. MatroxTripleHead2Go can service 3 screens, # but appears as only one monitor to the computer # change to your number of monitors echo 2 } function getMonitorWidth { numberOfMonitors=$(getNumberOfMonitors) monitorLine=$(xwininfo -root | grep "Width") monitorWidth=$((${monitorLine:8}/$numberOfMonitors )) echo $monitorWidth } function getActiveWindowID { activeWinLine=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)") activeWinID="${activeWinLine:40}" echo $activeWinID } function getActiveWindowHorizontalPosition { activeWinID=$(getActiveWindowID) xPosLine=$(xwininfo -id $activeWinID | grep "Absolute upper-left X") xPos=${xPosLine:25} echo $xPos } function getActiveWindowWidth { activeWinID=$(getActiveWindowID) xWidthLine=$(xwininfo -id $activeWinID | grep "Width") xWidth=${xWidthLine:8} echo $xWidth } function getActiveWindowCurrentMonitor { numberOfMonitors=$(getNumberOfMonitors) monitorWidth=$(getMonitorWidth) activeWinID=$(getActiveWindowID) xPos=$(getActiveWindowHorizontalPosition) i="0" while [ $xPos -gt $monitorWidth ] do xPos=$[$xPos-$monitorWidth] i=$[$i+1] done echo $i } function getActiveWindowPositionOneMonitorToTheLeft { monitorWidth=$(getMonitorWidth) currentMonitor=$(getActiveWindowCurrentMonitor) activeWinID=$(getActiveWindowID) xPos=$(getActiveWindowHorizontalPosition) xPos=$[$xPos-$monitorWidth] echo $xPos } function getActiveWindowPositionOneMonitorToTheRight { monitorWidth=$(getMonitorWidth) numberOfMonitors=$(getNumberOfMonitors) currentMonitor=$(getActiveWindowCurrentMonitor) activeWinID=$(getActiveWindowID) xPos=$(getActiveWindowHorizontalPosition) xPos=$[$xPos+$monitorWidth] echo $xPos } function changeActiveWindowMonitor { activeWinID=$(getActiveWindowID) if [ $1 -eq "0" ] then newXPos=$(getActiveWindowPositionOneMonitorToTheLeft) newXPos=$[$newXPos-5] else newXPos=$(getActiveWindowPositionOneMonitorToTheRight) newXPos=$[$newXPos-5] fi winState=$(xprop -id ${activeWinID} | grep "_NET_WM_STATE(ATOM)" ) if [[ `echo ${winState} | grep "_NET_WM_STATE_MAXIMIZED_HORZ"` != "" ]] then maxH=1 wmctrl -i -r ${activeWinID} -b remove,maximized_horz fi if [[ `echo ${winState} | grep "_NET_WM_STATE_MAXIMIZED_VERT"` != "" ]] then maxV=1 wmctrl -i -r ${activeWinID} -b remove,maximized_vert fi if [[ `echo ${winState} | grep "_NET_WM_STATE_FULLSCREEN"` != "" ]] then fulls=1 wmctrl -i -r ${activeWinID} -b remove,fullscreen fi # move window (finally) wmctrl -i -r ${activeWinID} -e 0,${newXPos},-1,-1,-1 # restore maximization ((${maxV})) && wmctrl -i -r ${activeWinID} -b add,maximized_vert ((${maxH})) && wmctrl -i -r ${activeWinID} -b add,maximized_horz ((${fulls})) && wmctrl -i -r ${activeWinID} -b add,fullscreen # raise window (seems to be necessary sometimes) wmctrl -i -a ${activeWinID} } function moveActiveWindowOneMonitorToTheLeft { changeActiveWindowMonitor 0 } function moveActiveWindowOneMonitorToTheRight { changeActiveWindowMonitor 1 } "$1" exit 0
3. Setup your hot keys with compiz-fusion. Go to System >> Preferences >> Advanced Desktop Effects. Inside “General Options“, click on the command tab (I apologize for my heinous blue links).
Use
scripts/./movewin.sh moveActiveWindowOneMonitorToTheRight
and
scripts/./movewin.sh moveActiveWindowOneMonitorToTheLeft
respectively
Per Application Window Effects in Ubuntu
Bring character and tickle your soul with per application window effects
Another cool feature Compiz-fusion has is window animations. My friend James Lindsay recently reminded me about Window Effects… which when I first install Ubuntu on my laptop, I experimented my butt off… but being a laptop… I just used simple ones I’d turn off half the time anyway. He asked me why I don’t use them on my desktop and I didn’t have a good reason. Well, now I have 2 good reasons to keep using compiz.
I made my Thunderbird use the airplane effect so when I send emails, it flys away and for Geany, I used the magic lamp for open, close, maximize and minimize (different speeds). It’s a fun little effect that breaks up the stiffness of the desktop.
Default File Associations in Ubuntu
geany > gedit
I was tired of gedit popping up when geany’s just as lightweight but more affective. So found a command and altered it a bit to make my default editor geany.
1. Open the terminal and create\open the following file:
gedit ~/.local/share/applications/defaults.list
If it’s blank, add “[Default Applications]“. If it’s not, find “[Default Applications]“.
2. Then, back to the terminal, grep the default files associations and replace gedit with your editor of choice
grep gedit /usr/share/applications/defaults.list | sed s/gedit/geany/g
Copy (ctrl+shift+c) and paste the output into gedit, below the “[Default Applications]” header.
3. Restart nautilus to load the changes (will close all your file managers that are open and blink/freeze your desktop for a second)
pkill nautilus
Good luck, have fun and happy coding












