Kategorie: Ubuntu
15.09.11
Disable disk cache in Chromium / Google Chrome
There is no user interface in Google's browser Chrome yet to disable the disk cache, or control its size (version 14 appears to have something in the developer tools section).
But it can be done using command line options when starting the browser, and you can configure this globally for Ubuntu.
The following command line flags will use /dev/null ("the sink") as cache dir, and additionally limits it to 1 byte:
--disk-cache-dir=/dev/null --disk-cache-size=1
(I have tried just --disk-cache-size=0 or 1, but it did not appear to work as expected)
On Ubuntu/Debian, you can just add these flags to the CHROMIUM_FLAGS variable in /etc/chromium-browser/default and it will be used every time when starting Chromium.
The motivation to do this comes from me using a local (intercepting) HTTP proxy with its cache on a RAM disk. Therefore I do not want Chromium to store quite the same retrieved files on disk again.
Additionally, this is a SSD, which is not that happy about being written to in general.
Therefore /tmp is a tmpfs mount already, and the same should be the case for temporary browser files.
15.03.11
Script to double/halve OpenVZ resources
The following script allows you to easily double or halve resources in an OpenVZ container.
You would install this script as "/usr/local/bin/vz-double-resources" and also create a symlink named "vz-half-resources" to it (probably also in /u/l/b).
This then allows you to just call "vz-double-resources 123 shmpages" in case you've been notified that there have been shmpages beancounter failures (resource limit has been hit).
This outputs the command to double the bean counter limit, and allows for easy execution by just forwarding the output to "sh", as in "vz-double-resources 123 shmpages | sh -".
Here's the script (available and maintained as/at Gist):
Code:
# cat =vz-double-resources | |
#!/bin/bash | |
| |
VZ="$1" | |
RESOURCE="$2" | |
| |
if [ -z $VZ ] || [ -z $RESOURCE ]; then | |
echo "Usage: $0 VZ RESOURCE" | |
exit 1 | |
fi | |
| |
case $0 in | |
*-double-*) OPERATION="*2" ;; | |
*-half-*) OPERATION="/2" ;; | |
*) echo "Invalid: $0" ; exit 1;; | |
esac | |
| |
echo "# Operation: $OPERATION" | |
| |
# get failures: | |
# awk '$NF ~ /[0-9]*[1-9]$/' /proc/bc/*/resources | |
| |
if [ -f /proc/bc/$VZ/resources ] ; then | |
# uid resource held maxheld barrier limit failcnt | |
| |
resource=$(echo $RESOURCE | tr '[:upper:]' '[:lower:]') | |
awk /$resource/ /proc/bc/$VZ/resources | { | |
read resource held maxheld barrier limit failcnt | |
if [ -n "$resource" ]; then | |
cmd="vzctl set $VZ --$resource $(($barrier $OPERATION)):$(($limit $OPERATION)) --save" | |
echo $cmd | |
exit | |
fi | |
} | |
fi | |
[[ -n "$cmd" ]] && exit | |
if [ -f /etc/vz/conf/$VZ.conf ] ; then | |
value=$(grep -i "^$RESOURCE=" /etc/vz/conf/$VZ.conf) | |
eval $value | |
RESOURCE=$(echo $RESOURCE | tr '[:lower:]' '[:upper:]') | |
resource=$(echo $RESOURCE | tr '[:upper:]' '[:lower:]') | |
value=$(eval echo \$${RESOURCE}) | |
echo $value | { | |
IFS=: read barrier limit | |
cmd="vzctl set $VZ --$resource $(($barrier $OPERATION)):$(($limit $OPERATION)) --save" | |
echo $cmd | |
} | |
else | |
echo "ERROR: container $VZ not found." | |
exit 1 | |
fi |
This is a script I've been using since quite a while (otherwise it would use zsh instead of bash), and have not looked into after creating it.
I just noticed that it is quite useful in general and therefore wanted to make it public.
26.02.11
Puppet definition to add Launchpad PPA repository
Link: https://gist.github.com/844735
The provided puppet definition(s) will allow you to add a PPA repository on a host managed by Puppet, e.g. by means of a class like this:
Code:
class blueyedppa { | |
pparepo { "blueyed/ppa": apt_key => "7CC17CD2" } | |
} |
I have created this to easily add the Current BOINC releases PPA to one of my hosts, and refactored a previously snippet for this.
Since I could not find anything for this, but questions asked about it, I like to share this. The actual code is available at the Gist linked to by this post.
18.08.10
Reinstall Debian init.d scripts into default runlevels
The following zsh snippet allows you to re-install any missing startup/init.d links.
This can be useful/required when e.g. installing an upstart based distribution (like Ubuntu Lucid) has removed some of those, and you want them back after downgrading to Hardy or switching to Debian testing (like I just did).
(apt-get install --reinstall won't bring back those links; you would have to purge (apt-get purge) and reinstall the package instead, removing any other configuration of the package though)
It basically looks for any init scripts that are not present in /etc/rc?.d/S* and then looks at the packages' postinstallation script for an update-rc.d command.
It will not install anything, but only output them (and allows you to pipe it into "sh" for execution).
Worked fine on my "messed up" system, but has rather odd results on my Maverick desktop.
Code:
for i in /etc/init.d/* ; do | |
a=( /etc/rc?.d/S*$i:t(N) ); | |
((${#a})) && continue; | |
package=$(dpkg -S $i 2>/dev/null |cut -d: -f1); | |
[[ -z $package ]] && continue; | |
echo "# $i: $package"; | |
grep "update-rc\.d $i:t" /var/lib/dpkg/info/$package.postinst; | |
done |
(in case you need to extract the init script altogether, the following might help for starters:
dpkg-deb --extract /var/cache/apt/archives/$PACKAGE.deb /tmp/foo.)
04.08.10
Ubuntu Stack Exchange opened for public beta
Link: http://ubuntu.stackexchange.com/
Ubuntu Stack Exchange has been opened for public beta.
It's similar to (and driven by the same software as) Stackoverflow or Superuser: a user driven site focused on questions and answers regarding a particular topic.
While being in closed beta (to get an initial set of questions, answers and users), the Ubuntu Stack Exchange got more support than the (more generic) Linux Stack Exchange (according to Joel).
21.05.10
Useful wrappers for apt-get, apt-source and apt-file
Link: https://github.com/blueyed/oh-my-zsh/blob/master/plugins/apt/apt.plugin.zsh
I've finally started to manage the setup of my dotfiles (configuration files) for shell, editor etc.
It is based on the popular dotfiles repository of ryanb and my fork can be found at github:blueyed/dotfiles.
While I'm still in the process of setting this up, I've just added the apt-* helpers I wrote some years ago:
They provide neat things like asrc -g hardy hello to get the version of the "hello" package from hardy (via "apt-get source" and the version number grepped from "apt-cache madison" - so you need to have it in your apt sources list, of course).
Also, ashow -g testing hello will show the package from Debian testing.
Apart from that these are mostly aliases, like "aup" for "sudo apt-get update" and some of them support shell completion (of package names) for e.g. "ainst" ("sudo apt-get install"). Shell completion works in both zsh and bash (at least).
You can get the file (to be sourced in a shell) from:
https://github.com/blueyed/oh-my-zsh/blob/master/plugins/apt/apt.plugin.zsh.
Feedback is very welcome and I am sure some of this is in packages like debian-goodies already (actually, there's nothing like that in _that_ package, but..).
Does it make sense to add (parts of) it to some package for easy installation across Debian/Ubuntu?
07.05.10
tqWorms reloaded
I've noticed some days ago that the DOS game I've written in 1999 can get played still using DOSBox.
The sound is apparently a bit crappy - but fortunately this is not on Linux only..
You can view the old software home at thequod.de/.../tqworms, but this is apparently very old already and I should get it some new home probably. Anyway, https://www.thequod.de/de/comp/mysoft/tqworms should be fine.
Screenshots are up on Flickr finally and it's known to cause maximum pleasure with 5+ users on the same keyboard only.
Would love to play this again - maybe even more when sound stutter (via DOSBox) is being fixed.

