HowTo: How to use your jack audio card with pulseaudio in Fedora 20 2

I, honestly, don’t know what happens here. I dunno if you’re delegating pulseaudio to jack or viseversa. Anyway, I use this method to enable my Focusrite Scarlett 18i20 in Fedora 20. I hope it helps out:

Procedure

#!/usr/bin/env bash

pulseaudio -k
pulseaudio -k
pulseaudio -k

pactl load-module module-jack-source;
pactl load-module module-jack-sink

After that (in GNOME 3), just go to Settings > Sound > Output and choose “Jack sink” as the default device. It should now work as your main audio output device.

Let me know, with your comments, of any success stories or feedback you might provide.


HowTo: Change your css according to client’s time

I am no fan of javascript. In fact, I despise it. But, recently, it occured to me that it would be cool to change the CSS theme according to the client’s time.

Here’s how:

function change_css_according_to_time() {
    var d = new Date();
    var h = d.getHours();

    if ( h >= 7 && h <= 19 ) {
        console.log( 'Good day!' );
        document.getElementById("mainStyle").href = '/css/default-day.css';
    } else {
        console.log( 'Good evening!' );
    }
}

change_css_according_to_time()

Demo: http://web2.woralelandia.com/

Check out the default.js. It’s as simple as that.

Also, you just need the VanillaJS framework: http://vanilla-js.com/.

Have fun!


HowTo: Cómo poder ver The Pirate Bay si tu país está bloqueando el acceso

Hoy, tras leer: http://derechoaleer.org/blog/2014/07/the-pirate-bay-el-catalogo-de-la-biblioteca-de-babel.html, me dió por ponerme de subversivo.

No me gusta cuando un país hace cosas en favor de los intereses comerciales de empresas con moral distraída.

Así que, ahí van algunas técnicas para que puedas esquivar los intentos de bloqueo de tu país:

Acceso por medio del PirateBrowser

Si descargas el navegador, podrás accesar sin problemas: http://piratebrowser.com/

IP en tu archivo hosts

Para los que preferimos seguir usando nuestro navegador, y si tu ISP está bloqueando thepiratebay.se por medio de DNS, solo debes agregar la IP de thepiratebay.se en tu archivo de hosts. Actualmente, la IP es: 194.71.107.27 pero puede cambiar. Para averiguarla, busca un servicio de dig online.

Solo pon el dominio y te dará la IP. Luego, es fácil de agregar a tu archivo de hosts.

Para GNU & Linux:

    # agrega la IP a tu archivo /etc/hosts (en Fedora, necesitas tener bind-tools instalado)
    echo $( dig @8.8.8.8 +short thepiratebay.se ) thepiratebay.se www.thepiratebay.se > /etc/hosts

Si eso no funciona, edita, como root, el archivo /etc/hosts y agrega la entrada: 194.71.107.27 thepiratebay.se www.thepiratebay.se

Es posible que tengas que actualizar manualmente la IP de vez en cuando. Solo repite los pasos y ya.

Para usuarios de mac o windows, sigue los pasos provistos acá; pero usando el mismo tipo de entrada expuesto en este artículo: http://www.rackspace.com/es/knowledge_center/article/how-do-i-modify-my-hosts-file


HowTo: Create an interface configuration with nmcli on CentOS7 and Fedora 2

I ran through hell today!

I tried doing things the old way. You know; edit /etc/sysconfig/network-scripts/ifcfg-eth1 in order to set it to a static IP. Well, bad idea.

I had all kinds of problems when the two interfaces where online (eth0 and eth1). For example:

  • eth0, even having BOOTPROTO=dhcp, would get the static IP address of eth1.
  • eth1 would get an IPv6 address but not it’s static address.
  • network.service would NOT work at all.

So, my solution. Use NetworkManager.

I found that we have nmtui and nmcli. The former has a Terminal User Interface (TUI); which makes it friendlier to the average user. The former, is a CLI application; which makes it friendlier for scripting and nerds.

I preferred nmcli; since I like remembering stuff in scripts. So, here is how to do it:

nmcli c add type ethernet ifname eth1 con-name private autoconnect yes save yes ip4 192.168.1.10/24
nmcli c modify eth1 ipv4.ignore-auto-routes yes ipv4.ignore-auto-dns yes ipv4.may-fail no

That command will and eth1 with “private” as it’s friendly anme and will connect on boot and persist in configuration. We, also, remove auto routes and auto dns; and make it fail loudly!

Check out the man page to add more stuff like default routes and stuff.


HowTo: Two different public IPs on a single server

Ok, today, I discovered I am still an idiot.

Yep, I tried to add 2 public networks to one of my CloudSigma servers and one of them didn’t work.

I thought everything was to blame but my configuration (as always). Well, I managed to discover what the problem was and how to correct it.

The problem is that since there is only one default route, packets going through eth1 didn’t know how to go back to where they came from. This is solved by adding a rule and telling the kernel where to look for info on those packets:

How

# first my NIC configuration
## cat /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
DEFROUTE=yes

## cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
DEFROUTE=no

# my routing table
## ip route
111.111.111.0/24 dev eth0  proto kernel  scope link  src 111.111.111.111 
222.222.222.0/23 dev eth1  proto kernel  scope link  src 222.222.222.222 
169.254.0.0/16 dev eth0  scope link  metric 1002 
169.254.0.0/16 dev eth1  scope link  metric 1003 
default via 111.111.111.1 dev eth0 

# look for info on packets comming from network 222.222.222.0/23 on table 1
ip rule add from 222.222.222.0/23 tab 1 priority 500

# append to default gateway telling it to look for info on table 1
ip route add default via 222.222.222.1 dev eth1 tab 1

# flush cache
ip route flush cache

Rationalization

So, eth0 (111.111.111.111) is the default route. It is declared in ifcfg-eth0. If I do not declare DEFROUTE=no on eth1, then, the last NIC to become available becomes the default route. So, I specify which is the default so I can add rules later.

Then, there is eth1 (222.222.222.222) which is a completely different network. We add the rules needed for the info of it to be found on it’s own table and we add it to the default.

This works ipso facto. I don’t know if it will survive a reboot, but, hey, I know my readers will tell me if it does or not.