Tuesday, May 31, 2016

Speed up ubuntu

Add to /etc/sysctl.conf

vm.swappiness=0
vm.vfs_cache_pressure=50


Add noatime flag to lines in /etc/fstab


Friday, March 18, 2016

Squid load balancing with proxy.pac

function FindProxyForURL(url, host) {
 
// If the hostname matches, send direct.
    if (dnsDomainIs(host, "intranet.domain.com") ||
        shExpMatch(host, "(*.abcdomain.com|abcdomain.com)"))
        return "DIRECT";
 
// If the protocol or URL matches, send direct.
    if (url.substring(0, 4)=="ftp:" ||
        shExpMatch(url, "http://abcdomain.com/folder/*"))
        return "DIRECT";
 
// If the requested website is hosted within the internal network, send direct.
    if (isPlainHostName(host) ||
        shExpMatch(host, "*.local") ||
        isInNet(dnsResolve(host), "10.0.0.0", "255.0.0.0") ||
        isInNet(dnsResolve(host), "172.16.0.0""255.240.0.0") ||
        isInNet(dnsResolve(host), "192.168.0.0""255.255.0.0") ||
        isInNet(dnsResolve(host), "127.0.0.0", "255.255.255.0"))
        return "DIRECT";
 
// Round robin based on source ip address, with failover
// Find the 4th octet
var myip=myIpAddress()
var ipbits=myip.split(".")
var myseg=parseInt(ipbits[3])

// Check to see if the 4th octect is even or odd
if (myseg & 1) {
     // Odd
     return "PROXY 172.18.0.160:9090; PROXY 172.18.0.159:9090; DIRECT";
}
else {
     // Even
     return  "PROXY 172.18.0.159:9090; PROXY 172.18.0.160:9090; DIRECT";
}


}





Saturday, November 28, 2015

Convert all your jsp files to UTF-8 encoding



#Add this header to jsp
<%@ page contentType="text/html; charset=UTF-8" %>

#Command to convert all jsp files to UTF-8
find ./ -iname '*.jsp' -exec iconv -f ISO-8859-1 -t UTF-8

Saturday, November 14, 2015

Installing Android Studio on Ubuntu 14.04 Trusty via Ubuntu Make


# First add the Ubuntu Make ppa:
sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make


#Install umake
sudo apt-get update
sudo apt-get install ubuntu-make

#Install android studio
 umake android

Saturday, October 31, 2015

Fast DNS caching in Debian Jessie with dnsmasq-nocachelimit

Dnsmasq is a popular software to setup a caching nameserver.

The current packages on Debian have a hardcoded limit of 10K names. The software is meant for routers with low memory but servers nowdays have GBs of memory.

I created a personal fork for dnsmasq that removes the cache limit of 10000 names. Meant for modern servers with lots of RAM.

A cache size of 1M names uses about 100MB or RAM.


You can install my binary packages for Debian Jessie from

https://drive.google.com/folderview?id=0B38VG7HG0bZ2Z2d6YVl0MUNvVEk&usp=sharing

After installing, hold the package with

sudo apt-mark hold dnsmasq dnsmasq-base


To setup dnsmasq follow the Debian wiki

https://wiki.debian.org/HowTo/dnsmasq


Later increase the cache-size value to 1000000 in the file /etc/dnsmasq.conf

# Set the cachesize here.
cache-size=1000000



Automated script to transform Ubuntu Trusty into MacBuntu


Run the script here

https://drive.google.com/file/d/0B_TW7XwVogRYZkVldUJxMEFGejQ/view?usp=sharing

The only extra step is to go to 'Startup Applications' and add an item with the command 'docky' (for some reason the config script does not auto run docky).


This is the end result

https://lh5.googleusercontent.com/-RwMQYtS_p_M/VGdMSzOe8EI/AAAAAAAAKi0/dZeBHnFzzU0/s1600/mac-3.jpg