Wednesday 31 July 2013

DHCP on CLI for Ubuntu-like systems


  1. Add these lines to /etc/network/interfaces, or tweak existing eth0 lines
    1. auto eth0
    2. iface eth0 inet dhcp
  2. bring it up
    1. sudo ifup eth0
  3. bring it down
    1. sudo ifdown eth0
  4. add some stuff to /etc/dhcp/dhclient.conf
    1. interface "eth0" {
    2.     prepend domain-name-servers 192.168.100.10, 8.8.8.8, 8.8.4.4;
    3.     supersede domain-search "mydom.com", "mydom-vpc.internal";
    4. }
  5. flush on occasion
    1. ip addr flush eth0

Saturday 27 July 2013

Match different sets of equally distributed things into groups: hosts and weeks in the year

Use modulo if you want to match up sets of things into groups.

They have to be equally distributed by number.

Here it is with modulo 3: hosts on left, weeks of the year on right.


Wednesday 24 July 2013

Clear CLI with 1000 blank lines

For when you really want older output way out of your way, e.g., debugging, copying/pasting.
  1. for i in {1..1000};do echo;done

Thursday 18 July 2013

Zenoss: remodel all Linux servers at once



  1. su - zenoss
  2. zenmodeler run --path=/Server/Linux 

Wednesday 17 July 2013

Mac "Screen Sharing" using vncviewer and ssh tunnel

problem: Remmina (or similar) fail to connect to Mac over Cisco wireless (or whatever router is the problem), and you are tired of having to physically connect your Mac to make VNC work.

  1. make sure "Screen Sharing" is on as normal on your Mac
  2. ssh -L5900:localhost:5900 192.168.X.X
    1. replace 192.168.X.X with the IP of your Mac
    2. "Remote Login" is on
    3. set display to "Scaled" and "1024x768" if your Mac is just an Outlook client now
  3. vncviewer -encodings 'copyrect tight zrle hextile' localhost:5900

Monday 15 July 2013

Selenium test on CLI in 5 minutes using Java

This took me two weeks to nail down looking at it here and there.
  1. mkdir stests
  2. cd stests
  3. wget http://selenium.googlecode.com/files/selenium-java-2.33.0.zip
  4. unzip selenium-java-2.33.0.zip
  5. mkdir jars
  6. find selenium-2.33.0 -type f -name '*jar' -exec mv -v {} jars \;
  7. rm -rfv selenium-*
  8. mkdir src
  9. vi src/Test.java
    1. use below code
  10. mkdir out
  11. javac -d out -cp 'jars/*' src/MyTest.java
    1. ignore "Notes" output
  12. cd out
  13. rm -rfv org
  14. java -cp '../jars/*:.' MyTest

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class MyTest  {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
        WebElement element = driver.findElement(By.name("q"));
        element.sendKeys("Cheese!");
        element.submit();
        System.out.println("Page title is: " + driver.getTitle());
        (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("cheese!");
            }
        });
        System.out.println("Page title is: " + driver.getTitle());
        driver.quit();
    }
}

Saturday 6 July 2013

Could not update ICEauthority file /home/myuser/.ICEauthority


Your home directory perms got messed up somehow
  1. sudo chown myuser:myuser /home/myuser
If it still doesn't work, this may be necessary as well
  1. sudo chmod 750 /home/myuser

Friday 5 July 2013

apache-cassandra11 conflicts with apache-cassandra11-1.1.11-1.noarch

The Error:

Running rpm_check_debug
ERROR with rpm_check_debug vs depsolve:
apache-cassandra11 conflicts with apache-cassandra11-1.1.11-1.noarch

Solution:
  1. wget http://rpm.riptano.com/community/noarch/apache-cassandra11-1.1.11-1.noarch.rpm
  2. rpm -i apache-cassandra11-1.1.11-1.noarch.rpm --nodeps
This might be necessary before step 2, but make sure you back up your data first, even this should not delete it, you never know:
  1. yum remove apache-cassandra11

Thursday 4 July 2013

Poke an ssh tunnel to your house


  1. remote server
    1. ssh -R 19999:localhost:22 myhomeuser@myhome.domain.org
  2. home server
    1. ssh myremoteuser@localhost -p 19999

  1. use below on your remote server to keep connection open
    1. ~/.ssh/config
Host myhome.domain.org
  User myhomeuser
  ServerAliveInterval 60

Wednesday 3 July 2013

bash: funky hostname expansion in for loop


  1. for host in myhosts-{2{2,{6..9}},3{2,5,{7..9}}}.mydomain.com
    1. do 
      1. echo $host
      2. echo "ssh $host cmd"
  2. done

Interview questions: 2020-12

Terraform provider vs provisioner Load balancing Network Load Balancer vs Application Load Balancer  Networking Layer 1 vs Layer 4 haproxy u...