MEDOIX

technology, life & solutions

Disable Bonjour in Cyberduck

by medoix on August 6, 2015, no comments

I used Cyberduck on Mac OS X for quite a lot of tasks including talking to S3 buckets or even SFTP’ing into my Linux servers.

Every time I load up Cyberduck, I get flooded with Bonjour Growl notifications. Since I never use Bonjour with Cyberduck, I figured it’s acceptable to disable it. It’s a simple Terminal command, like so many other things are in the Mac world. To disable Bonjour, fire up Terminal and execute this command:

If you want to re-enable Bonjour, do the same command but change false to true.

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

1Kr8tx6MbBTN1W43nFvgiZ4X76YtUG1nBq

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.

Turnigy 9X ‘resistor fix’ Trainer Port

by medoix on July 25, 2015, no comments

The ‘resistor fix’ solves the problem of needing to unplug the wireless module in order to use the trainer port.

It involves cutting a trace on a PCB inside the transmitter, and soldering a resistor (usually a 1kOhm resistor) in series by bridging the cut trace.

Why do you need to unplug the wireless module in the first place?

A Little More Theory

The trainer port on the 9X contains a switch (that triggers when a plug is inserted into the trainer jack) that powers off the wireless module to ensure the 9X no longer transmits its signal. Normally, when wireless module is powered on, the radio sends a data signal to the wireless module that is between 0V and +3.3V.

Unfortunately, when the 2.4GHz wireless module loses power, the data signal coming from the radio processor is essentially shorted to ground through a high voltage protection diode on the signal pin of the wireless module. The data signal that goes to the wireless module happens to be the same signal routed to the trainer port. Adding a resistor in series with the signal going to the wireless module breaks the short to ground and allows the full voltage signal to reach the trainer port.

Notice, the short to ground only occurs when the 2.4GHz module loses power. When the wireless module receives power, the data signal behaves like a proper input and maintains high impedance, probably in the 10kOhm and above range. By selecting a resistor much lower in resistance than the input impedance of the wireless module, say 1k, the resistance added by the fix is negligible and does not affect normal operation of the radio.

The Actual Fix

Items needed

  • Philips Screw Driver
  • Xact-O Knife or sharp blade
  • Resistor with value around 1k Ohm
  • Soldering iron

Steps

  1. Start by taking off the back of the 9X by removing the 6 screws on the back
  2. Carefully open radio. Manipulating the sides should allow you to be able to lay both sides flat without disconnecting any cables.
  3. Locate the trace for the data signal (top pin and outer trace on left).
  4. Using the Xact-O knife, cut a small notch in trace and scrape the solder mask (green enamel) off of the trace far enough apart so the resistor bridges the notch and both leads lay on bare copper (picture 1 below) or cover a resistor in heat shrink and solder each end to the corresponding pins (picture 2 below).
  5. resistor-heatshrinked

    Solder both sides of the resistor down to either side of the trace where the solder mask has been scraped off.

  6. Carefully close the radio, redoing the screws in the back.
  7. Enjoy not having to unplug the wireless module to use your radio with a sim or trainer!
No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

16YcDAJBYTTjFwBwPgoP9eXBzrj1zcJ6Hw

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.

PBCOPY from SSH to Local OSX

by medoix on November 27, 2014, no comments

I have been wondering for a long time how i could copy large config files or any file for that matter from nano/vi inside an SSH session to my local clipboard (OSX). As you can imagine copying one section at a time from your favourite text editor has long been a pain in the rear end.

The trick uses netcat (nc) to pipe text over an SSH connection to a local listener that passes it to pbcopy. The below should work on both Linux/Unix servers as well as OS X servers.

Local Machine Configuration

Daemonizing pbcopy

The quickest way to “networkify” pbcopy is to run the following snippet in a dedicated terminal tab:

We just asked bash to launch netcat (nc), repeatedly wait for incoming connections on localhost:2224, and pipe any data received into pbcopy.

Now locally, the following two are equivalent:

Exposing our daemon to machines we SSH to.

For security reasons, our “pbcopy daemon” only allows connections from localhost. But the goal is to allow you to pipe text to your local clipboard from a server you’ve SSHd into. This is done via SSH’s reverse tunnel forwarding feature:

# SSH in to remote-server as usual, except -R asks that
# remote’s port 2224 is forwarded to your laptop’s localhost:2224

If you’d prefer to enable reverse tunneling of port 2224 all your future outgoing SSH connections, the following adds the appropriate line to ~/.ssh/config:

Having established the SSH reverse tunnel, you can now do the following from the remote server:

# -q0 is required for GNU’s version of netcat to exit on eof; the osx version does it by default
If the remote server is missing nc, either run sudo apt-get install netcat -y or use telnet instead:

Enjoy your newly-supercharged clipboard!

Getting Fancier

If your laptop is running linux, replacing pbcopy with xcopy should work:

For a more verbose version of our “pbcopy daemon” that prints what’s being sent to the clipboard, try this:

To automatically start the “pbcopy daemon” on boot, you should use launchd.

Remote Machine/Server Configuration

When it comes time to create the shell script on the remote machine, create one called /usr/local/bin/rpbcopy with the contents below:

Make it executable (chmod a+x /usr/local/bin/rpbcopy). Then, in your remote ~/.bash_profile, add the line:

That will create the pbcopy on Linux/Unix or replace the default pbcopy command on OS X with the script above, which checks whether you’re in an SSH session and runs nc or the original pbcopy accordingly.

Instead of the if statement in the shell script, you could also check for the SSH session (using the same check for $SSH_CLIENT) in your .bash_profile and only alias pbcopy if you’re logged in remotely. Your choice.

Now, when you’re logged in on the remote Linux/OS X system over SSH, you can type cat filename|pbcopy or pipe the output of a command to pbcopy and it will show up on your local clipboard. It’s the same result you’d expect if you were just working in Terminal locally, so it requires no change of habits. Handy stuff.

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

17t6139ANyq5KhosmiUnwTjLUbooEBucwf

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.

Make Sudo Sessions Last Longer in Linux

by medoix on August 30, 2013, no comments

Linux Sudo Extention Example

When you run sudo in Ubuntu, your administrative privileges last for 15 minutes by default so you don’t have to type in your password with every command. If that is too long or short for your tastes, you can change it with a simple tweak.

Run the following command in a Terminal:

Scroll down to the line that looks like this:

and change it to this:

Change 30 to the time, in minutes, that you want it to wait before it times out. You can also change it to 0 if you want a password prompt every time you run sudo, or -1 if you never want a password prompt (though we don’t recommend this).

Press Ctrl+X to finish editing, Y to save changes, and Enter to exit if you’re on Ubuntu. Other Linux distros may have different commands depending on the default editor.

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

1NCmjwjTAmLsvB3TLPiRVnPQDzrCPZBPrv

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.

Make Password Asterisks Visible in Your Mac or Linux Terminal

by medoix on August 30, 2013, no comments

Linux Show Password Example

When you run a command with sudo in Linux, the terminal prompts you to type in your password—and doesn’t give you any visual feedback. Here’s a quick tweak that’ll bring back those familiar asterisks (*) when you type in your password.P

I’m a fast typer, so when I mess up my password, I have to start over from scratch. With asterisks, it’s a lot easier—and seeing as no one’s looking over my shoulder in my home office, it doesn’t matter how obscured my password is. To bring back those asterisks:P

Run the following command in a Terminal:

Scroll down to the line that looks like this:

and change it to this:

Press Ctrl+X to finish editing, Y to save changes, and Enter to exit if you’re on Ubuntu. Other Linux distros may have different commands depending on the default editor. Mac users, for example, use vi, and will have to type :wq and press Enter to exit).

Now, when you run a command with sudo, you should get visual feedback when you type in your password. This should work in all versions of Ubuntu after version 10.04, as well as many other versions of Linux. We also tested it on a Mac running OS X 10.9 Mavericks. Check out the link below for more ways to tweak how sudo works.

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

1Esjw5XF7J7Lhuu6GxsjH3WYsLjD6rn9d9

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.

Permanent Delete on OSX (Windows SHIFT + DELETE Alternative)

by medoix on July 16, 2013, no comments

Create an Automator service or application to facilitate executing the rm shell commando, which will permanently delete files or folders and skip the trash.

For example, start with creating a new Service in Automator.app.

  • Select files or folders as input, you probably also want to limit the availability of this service to the Finder app.

Automator service input

  • Optionally, but highly recommended, first add an Ask for Confirmation step to the workflow.

Confirmation step

  • Finally, add the Run Shell Script step to the workflow. Make sure to pass input as arguments. Then you can put in the following script:

Input shell script

You can also add a -P parameter to rm for additional security while deleting. For an extra nicety, you can add some audible feedback by adding the following command at the end of the shell script:

Save your service, and it should be ready to use in Finder from the Services menu in the menu bar. You can also configure a keyboard shortcut to your service in the Keyboard preference pane of System Preferences.

Services menu

Service in action

Instead of creating a service, you could similarly create an application in Automator, which you can pin in the Dock so you can drag files to it.

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

17pum1rXPH1qtq6Kv6fWqap1sSzXrpzLNC

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.

Remove Old Kernels in Ubuntu

by medoix on November 5, 2012, no comments

To get started, open Terminal. When it opens, run the commands below to view your current running kernel.

old_kernel_oneiric

Next, take notes of your current kernel. DO NOT REMOVE THIS!

old_kernel_oneiric_1

Next, type the command below to view / list all installed kernels on your system.

old_kernel_oneiric_5

Next, find all the kernels that which number are lower than your current kernel.  When you know which kernel to remove, continue below to remove it.

old_kernel_oneiric_2

Finally, run the commands below to remove the kernel you selected.

old_kernel_oneiric_6

When you’re done, run the commands below to update grub2

old_kernel_oneiric_7

That’s all.

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

17QuGiz11ahFMQ5tcxEvjVnWb3H2J2r3S9

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.

Stop OS X Terminal SSH Timeout

by medoix on February 24, 2012, no comments

There are three ways to do this using the ServerAliveInterval to send data along every few seconds. Replace the “10” with the number of seconds between pings.

From least to most global:

1. Add the option on the command line:

2. Add the option to your personal ssh config by creating/editing ~/.ssh/config:

3. Add the option to the system-wide ssh config by editing /etc/ssh_config. (Syntax the same as above.)

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

1Bv73v44BQ7qZGzrLxHjQyUiiCAfDZ34ip

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.

Change MySQL Database Location

by medoix on February 19, 2012, no comments

So considering that i am using a 8GB USB Stick as my OS HDD it tends to get full easily and i need to clean stuff up or move things around. This happened recently with my fairly large databases.

Also because of read/write cycles are high i couldn’t imagine this would be good for my flash drive HDD and therefore decided to move it!

 

Stop MySQL

Move existing data directory (which is located in /var/lib/mysql) to new dir /usr/new_datadir

Create symlink from new dir to old one

Don’t change /etc/mysql/my.cnf

Ubuntu uses some security software called AppArmor that specifies the areas of your filesystem applications are allowed to access. Unless you modify the AppArmor profile for MySQL, you’ll never be able to restart MySQL with the new datadir location.

In the terminal, enter the command

Duplicate the lines beginning with /var/lib/mysql and replace duplicated strings with /usr/new_datadir

In my case it was:

Restart the AppArmor profiles

Restart MySQL

MySQL should now start without any errors, have fun!

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

133QnCeWH9s3msDe7GHxA1QKccfNz91zDo

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.

Get external (WAN) IP address from command line in Linux

by medoix on February 3, 2012, no comments

Many services and applications require you to know your external (WAN) IP address. There are plenty of web sites that allow you to do this, but here are a couple of simple ways to do this from the command line in Linux.

The first method uses the cURL utility, which is basically a command-line utility for retrieving data using URL syntax. In Ubuntu or Debian, you can install cURL from the repositories using the command:

After installing cURL, just run this command to get your external IP address:

You can replace ifconfig.me with other service hostnames/URLs, such as:
whatismyip.org
icanhazip.com
tnx.nl/ip
myip.dnsomatic.com
ip.appspot.com
checkip.dyndns.org:8245
whatismyip.com
jsonip.com

The second method is really a variation on the one above and uses the wget command. You can use the same hostnames/URLs as above with this command:

Have fun! And let me know your tips for this in the comments.

No tips yet.
Be the first to tip!

Like this post? Tip me with bitcoin!

1PE1hYSsAFsDW9yL25zzwQzRmuW26HnbD3

If you enjoyed reading this post, please consider tipping me using bitcoin. For an introduction to bitcoin please see weusecoins.com.