Category Archives: Tech Tips

How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

When recently using Intel Active Management Technology (AMT) I was remotely connected via the RealVNC client, but was having trouble sending keystrokes like F2 to enter the BIOS, F12 to select a startup device, or F8 to access the Windows startup menu. This setup is complicated for a few reasons – first I’m using a Mac keyboard. Secondly, OS X remaps the function keys to do things like dashboard, expose, brightness, and volume by default. After a little searching and trial and error, I found that I can use the free utility included with Mac OS X – AppleScript Editor.app – to send keycodes to the VNC connection. Here’s the code for the applescript you can use to send the F12 key: tell application “VNC Viewer” activate tell application “System Events” to key code 111 end tell This is what it should look like in the editor: To send key combos, like holding down alt and pressing F4, the syntax would be something like this: tell application “System Events” to key code 118 using {command down} We use command instead of alt because that is how Real VNC Viewer translates the “alt” key for a remote windows system by default. To send other keyboard F-keys to the remote Windows machine, use the table below to find the appropriate key – make sure to reference the “Mac” column even if the remote machine is a Windows box. What about JAVA? But what happens if you are running a java applet for … Continue reading

Posted in Tech Tips | Tagged , , , | Leave a comment

How to use http_build_url with pecl_http version 2.0 with PHP 5.4, 5.5, and 5.6

The old way to use http_build_url This is how to use http_build_url with pecl_http version 1.x: $parse = parse_url(‘http://example.com/index.asp?test=123#hash’); print_r($parse); # # Yields a result of: # # Array # ( # [scheme] => http # [host] => example.com # [path] => /index.asp # [query] => test=123 # [fragment] => hash # ) $url = http_build_url($parse); echo $url; # # Yields a result of: # # http://example.com/index.asp?test=123#hash The new way to use http_build_url with pecl_http version 2.x: This functionality has now moved into the http\Url class: $parse = parse_url(‘http://example.com/index.asp?test=123#hash’); print_r($parse); # # Yields a result of: # # Array # ( # [scheme] => http # [host] => example.com # [path] => /index.asp # [query] => test=123 # [fragment] => hash # ) $url = new \http\Url($parse); echo $url->toString(); # # Yields a result of: # # http://example.com/index.asp?test=123#hash #

Posted in Tech Tips | Tagged , | Leave a comment

How to disable the LEDs on the PogoPlug running Debian Squeeze

If you’ve installed Debian Squeeze on the PogoPlug you’ll notice there is no longer an /sys/module/xce/sections/ or /dev/xce path for you to echo commands to. However, you can still control the LEDs by using the sys -> devices -> platform -> LEDS / GPIO How to disable the LEDs echo 0 > /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness echo 0 > /sys/devices/platform/leds-gpio/leds/status:green:health/brightness How to make the LED green echo 0 > /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness echo 1 > /sys/devices/platform/leds-gpio/leds/status:green:health/brightness How to make the LED red echo 1 > /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness echo 0 > /sys/devices/platform/leds-gpio/leds/status:green:health/brightness How to make the LED orange / yellow echo 1 > /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness echo 1 > /sys/devices/platform/leds-gpio/leds/status:green:health/brightness You can also try using values 1-255 to control the brightness but I didn’t see much difference between different numbers. ymmv. Also, if you wish to read the status of the LEDs you can do so by using something like cat with these paths: cat /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness A value of 0 indicates the LED is off. Most likely if you are running Debian there will be no events that turn the LEDs on – but in case you have issues you can disable system events from triggering the LEDS you also need to change the ‘triggers’ – first check out the existing ones: cat /sys/devices/platform/leds-gpio/leds/status:green:health/trigger This results in: [none] nand-disk timer oneshot ide-disk1 ide-disk2 heartbeat gpio default-on mmc0 And for the red led use: cat /sys/devices/platform/leds-gpio/leds/status:red:fault/trigger Which should result in: [none] nand-disk timer oneshot ide-disk1 ide-disk2 heartbeat gpio default-on mmc0 Next, to disable the events from triggering the LEDs run: … Continue reading

Posted in Server Admin, Tech Tips | Tagged , | Leave a comment

Chrome Developer Tools now Open on Right opposed to Opening on the Bottom

If you’ve downloaded a recent beta or canary build of Google Chrome you may notice that sometimes the “developer tools” seem to open at the right instead of at the bottom. If you’re not using a large, wide-screen monitor you may find this inconvenient. Unfortunately it seem the Chromium Developer’s personal preferences have to come before user-experience. If you want the default setting for the position of Chrome’s Developer tools to be customizable, you’re out of luck. It will attempt to use your last-used preference, but you’ll notice that with incognito mode it will always end up being on the right. Because it is more convenient for the developers, and easier for them to change a default value string rather than code in an actual preference. Wouldn’t it be nice to do this: Unfortunately, that is not currently available. So what should you do? Star it, and complain about it here.

Posted in Tech Tips, Web Development | Tagged | Leave a comment

Stay.app’s “Restore All Windows” command from Applescript

If you want to use applescript to run cordlessdog.com‘s Stay.app command “Restore All Windows” command from Applescript, here is how to do it: tell application “Stay” set resultBoolean to restore all windows end tell Stay.app supports 5 applescript commands which are: restore active application windows restore all windows store active application windows store active window store all windows

Posted in Mac, Tech Tips | Leave a comment

How to install pecl pecl_http with homebrew php54 / php55

You may be tempted to try and run pecl install pecl_http if you’re using homebrew on Mac OS X in order to be able to access functions like http_get_request_headers – but there’s a better way. Instead, try using the command brew install php54-http or brew install php55-http ( depending on if you are using php 5.4 or php 5.5 with homebrew ) You can get more info about pecl_http with homebrew by using brew info php54-http or brew info php55-http ( again depending on your PHP version ). If you have already tried pecl install pecl_http you may want to run pecl uninstall pecl_http before running the other commands. If you have previously used something like brew install php54-http and now it doesn’t seem to be loading, check your configuration file in /usr/local/etc/php/5.4/conf.d or try doing: brew remove php54-http And then running: brew install php54-http

Posted in Tech Tips | Tagged , | Leave a comment

zshell: rsync hostname completion with zsh

If you use ssh a lot with zsh and have a lot of entries in your hostsfile (/etc/hosts) you might find it convenient to disable completion from these hosts by using: zstyle ‘:completion:*’ hosts off However, this may give you adverse affects, and your hostnames may stop auto-completing with rsync – in order to fix this try also adding this in to your .zshrc zstyle -s ‘:completion:*:hosts’ hosts _ssh_config [[ -r ~/.ssh/config ]] && _ssh_config+=($(cat ~/.ssh/config | sed -ne ‘s/Host[=\t ]//p’)) zstyle ‘:completion:*:hosts’ hosts $_ssh_config If you also use oh-my-zsh and are still having trouble, trying adding those lines after this line: source $ZSH/oh-my-zsh.sh

Posted in Tech Tips | Tagged , | 1 Comment

What does zsh-lovers do?

What is zsh-lovers? What does zsh-lovers do? You may have run something like brew search zsh and gotten a few results: zsh zsh-completions zsh-history-substring-search zsh-lovers zsh-syntax-highlighting zshdb Running brew info zsh-lovers isn’t that helpful: zsh-lovers: stable 0.9.0 http://grml.org/zsh/#zshlovers /usr/local/Cellar/zsh-lovers/0.9.0 (2 files, 60K) * Built from source From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/zsh-lovers.rb And neither is visiting the website that is referenced: http://grml.org/zsh/#zshlovers So, what is zsh-lovers? And what does zsh-lovers do? Simple! It’s just a man page with a lot of zsh examples that gets added alongside your other man pages, allowing you to run: man zsh-lovers And get this: ZSH-LOVERS(1) ZSH-LOVERS(1) NAME zsh-lovers – tips, tricks and examples for the Z shell SYNOPSIS Just read it. ;-) OVERVIEW Whenever we look at the zsh manual we wonder why there are no examples or those simply things in (shell) life. The zsh contains many features, but there was no manpage with some examples (like procmailex(5)). That’s why we wrote this manpage. Most of the tricks and one-liner come from the mailing lists zsh-users, zsh-workers, google, newsgroups and from ourself. See section LINKS for details. Note: This manpage (zsh-lovers(1)) is not an official part of the Z shell! It’s just a just for fun – manpage ;) For comments, bug reports and feedback take a quick look at the section BUGS.

Posted in Tech Tips | Tagged | Leave a comment

NoSleep Command Line Tool

The NoSleep utility for Mac OSX ( Mavericks et. all) that allows you to keep your computer from going to sleep even when the lid / clamshell is shut. It is accessed via a System Preferences pane and when running also shows up in the menu bar. To use the command line tool you need to choose that option when installing NoSleep: It will be installed as /usr/local/bin/NoSleepCtrl and you should be able to type in NoSleepCtrl in your Terminal.app to run it ( or use the full path if that doesn’t work ) Here are the options for using it: Usage: NoSleepCtrl [OPTIONS] … Options: -h Show this usage guide -v VRBLVL Verbose level. Default value is 1. 0 – minimal output, 1 – normal output, 2 – include driver output. -a Mode qualifier. Used to select AC-Adapter mode -b Mode qualifier. Used to select Battery mode Modes can be combined (-a -b). Use no qualifiers to select a current mode -g Get status for selected mode -s NVAL Set status for selected mode NVAL should have (%d) or (%d,%d) format, depending on the specified mode (without parentheses)

Posted in Tech Tips | Tagged , | 2 Comments

ShareThis Asynchronous Javascript Loading

Unfortunately the ShareThis service has a lot of known issues, like loading a lot of data from their tracking site, b.scorecardresearch.com and other types of bloat when initializing their icons. Because calling stLight.options depends on having the buttons.js script already loaded, it is not really feasible to initialize the code like this: <script type=”text/javascript” src=”http://w.sharethis.com/button/buttons.js”></script> <script type=”text/javascript”>stLight.options({publisher: “6beba854-ee6d-4ae1-a4f3-b69815c8ef63”});</script> However, you could use an onload function to do the stLight.options, and then wrap the entire thing inside of a function that won’t interfere with the global namespace, like this: <script> // ShareThis Asynchronous Javascript Loading // from https://techblog.willshouse.com/?p=5265 (function(){ // window.switchTo5x=false; // (optional) var e=document.createElement(“script”); e.type=”text/javascript”; e.async=true; e.onload=function(){ try{ stLight.options({publisher: “6beba854-ee6d-4ae1-a4f3-b69815c8ef63”, doNotHash: true, doNotCopy: true, hashAddressBar: false}); }catch(e){ /* optionally do something to handle errors here */ } } e.src=(‘https:’ == document.location.protocol ? ‘https://ws’ : ‘http://w’) + ‘.sharethis.com/button/buttons.js’; var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(e, s); })(); </script> Make sure to update your publisher ID in the code above if you copy / paste it.

Posted in Social Media, Tech Tips | Tagged | 2 Comments