When you need to bulk rename files you can not call "mv *.foo *.bar
" to change the extension of all .foo
files to bar
(because bash resolves wildcards and replaces them with the list of matched files).
This works on linuxes who use the Perl version of the rename
command (like Ubuntu):
rename 's/\.foo$/\.bar/' *
You can also use this to rename other parts of the file, e.g. from flag_en.png
, flag_de.png
etc. to just en.png
or de.png
:
rename 's/^flag_//' *
Note that we used $
and ^
to explicitly look at the ...
To list the name and version of your Linux distribution, type the following:
cat /etc/*-release
The idea is this: you take a job that you'd rather not do manually, and describe it to babushka using its DSL. The way it works, babushka not only knows how to accomplish each part of the job, it also knows how to check if each part is already done. You're teaching babushka to achieve an end goal with whatever runtime conditions you throw at it, not just to perform the task that would get you there from the very start.
It's that simple to allow one of your Linux users to run a single command as UID 0:
sudo visudo
/usr/bin/bundle
with root privilegesdeploy ALL=NOPASSWD: /usr/bin/bundle
Call geordi clean
from a project root to remove unused and unnecessary files inside it.
This script is part of our geordi gem on github. In Geordi > 1.2 you can call geordi clean
.
Because Nokogiri needs to be compiled and dynamically linked against both libxml2 and libxslt, it has gained a reputation for being complicated to install. Let’s wrassle this little myth to the ground, shall we?
This is a bash script for those of you who need to install all gems for all projects (e.g. to get started quickly on a newly installed system).
Put it into your ~/bin/
and run it from the directory that holds your projects.
Note that, like the vanilla bundle install
, this will fail whenever a new gem compiles native components and requires a missing system dependency.
Ctrl + R Search commands you entered previously. Press Ctrl + R again to search further back, Ctrl + Shift + R searches forward again.
Ctrl + W Deletes from the cursor position to the left.
Ctrl + _ Undo. Yes, this also works with a German keyboard layout.
Ctrl + L Clear screen.
Ctrl + D _Close shell. (EOT, just like in many other shells.) Note: if you dove into another shell (e.g. with sudo su username
) you will close it and return to ...
I prefer the application that I'm currently working on to be reachable at http://localhost/
.
So when I switch to another project, I use this handy shell script to set one site as the current one. Call it just like this:
apache-site makandra-com
Note that it disables all other sites in your Apache configuration so you would not want to use this on production machines.
Furthermore it will also enable the default
site if that was available.
When you call apache-site
with no arguments, it will list all available sites.
...
This post will describe how I stumbled upon a code path in the Linux kernel which allows external programs to be launched when a core dump is about to happen. I provide a link to a short and ugly Ruby script which captures a faulting process, runs gdb to get a backtrace (and other information), captures the core dump, and then generates a notification email.
If a SSH shell dies (from timeout for example), you cannot kill it with the usual CTRL-C
or CTRL-Z
. Instead, press
[ENTER]~.
(That is ENTER TILDE PERIOD
).
Note that you should disable the Java plug-in in your browsers after installation.
Java 11
sudo apt install openjdk-11-jre-headless
Java 10
sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install oracle-java10-installer
Java 8
You probably want to get rid of OpenJDK (which is installed by default and leads to bad RubyMine performance):
...
If you need to find all files inside a directory that were modified in the last 24 hours you can do this:
find . -mtime 1
You can also refer to another file's timestamp like this:
find . -cnewer other_file
This can be used to check against a specific timestamp, too. This is how you check for all files modified today (since 00:00):
touch -t `date +%m%d0000` /tmp/$$
find . -cnewer /tmp/$$
Note that $$
returns the current bash's PID so you will get some file like /tmp/12345 that stays the same for the current shell. This...
Sometimes files attain executable-flags that they do not need, e.g. when your Windows VM copies them over a Samba share onto your machine.
From inside your Rails project directory call regularly:
geordi remove-executable-flags
Runs chmod -x
on Ruby, HTML, CSS, image, Rake and similar files.
This script is part of our geordi gem on github.
You may omit the /path/to/link_name
to have a link with the same filename appear in the current directory
ln -s /path/to/file /path/to/link_name
unlink link_name // to remove the link and not where it is pointing at
To pause and send a task to the background
ctrl+z
to reactivate the task
fg
to run task in background
bg
to see a list of so running tasks
jobs
Open the configuration file:
gksudo gedit /usr/share/vte/termcap/xterm
Find a line like this:
:co#80:it#8:li#24:\
Change the first and last number to your desired columns and rows:
:co#160:it#8:li#40:\
Save your changes and close all open terminals. New terminals should now open with the new size.
Some browsers render PNG images with color profiles and other shenanigans, some don't.
The cleanest way to have consistent colors across browsers is to convert all your images to a standard color profile, strip the image's original profile and attach the standard profile.
If you can't be bothered to convert color profiles, a quicker (but less effective) method is to remove some PNG chunks from your files.
[Geordi](https://git...
Append this to your ~/.bashrc
:
export PS1='\[\033[01;32m\]\h\[\033[01;34m\] \w\[\033[31m\]$(__git_ps1 "(%s)") \[\033[01;34m\]$\[\033[00m\] '
Reload the changes by saying
source ~/.bashrc
For some customized prompts that also show the current Git prompt, see the examples section at the bottom of our bash prompt customizing card.
I’m working on a problem for a client which involves connecting to a Microsoft SQL Server 2005 database from Linux using Ruby. Here’s what I did to get it working, based off some useful instructions that are tailored for Ruby on Rails:
I've recently moved from using Parallels for browser testing to Sun's Open Source VirtualBox. Here's a walkthrough on how to get a browser testing suite for free on OSX or Ubuntu.
Next in our series on not shooting yourself in the foot: Doing a sudo shutdown -h now on the main database server right before you head home to cook dinner for six.
The FUSE project allows you to create filesystems in userspace - which means you can create a filesystem without having to get your hands dirty and modify your kernel source. This is insanely cool, and can be used for many purposes. Here we're going to look at using the Ruby bindings to create a simple filesystem.