Tech notes & snippets

Random assortment of little snippets and hiccups I came them useful (or at least amusing). Got something to add / correct? I' love your feedback.

Install the Backup Gem in Fedora (Server)

October, 03th 2016
The marvellous backup Gem isn’t available as a pre-packaged RPM and as Fedora is missing a simple =build_essentials=-Style meta package, there are some dependencies you’ll have to provide, before you can install it via Rubygems: sudo dnf group install "C Development Tools and Libraries" sudo dnf install rubygems ruby-devel patch redhat-rpm-config libxml2-devel # and you're good to go: sudo gem install backup Fore more details, check the Fedora Rubygems page.

Access Logstash JSON objects

August, 08th 2016
If you want to access Logstash log values buried deep in objects, be sure to use the bracket-syntax, as [object.field.name] won’t get you anywhere. This is the way to go, e.g. for mutate{}: mutate { rename => { "[object][field][name]" => "new_field" } }

Access MongoDB Shell from docker

July, 05th 2016
Sometimes it’s the little things in life. For example trying to connect to a MongoDB instance over and over again, without getting attached to a proper shell. $ docker run --rm --net=host mongo mongo mydb MongoDB shell version: 3.2.7 connecting to: mydb bye So, before you end up like me – debugging things on the server side: Check your docker parameters. You might be missing a -ti argument to receive an interactive shell.

Recover stuck RancherOS after upgrade to 0.4.5

June, 29th 2016
Just tripped into that one: I upgraded a Rancher host to 0.4.5, rebooted it & somehow only the system-docker daemon came up. The user facing container was stuck in a reboot loop: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e11da889990c rancher/os-docker:v0.4.5 "/usr/sbin/entry.sh /" 11 minutes ago Restarting (0) 47 seconds ago docker 9f0f66b8eef0 rancher/os-console:v0.4.5 "/usr/sbin/entry.sh /" 11 minutes ago Up 11 minutes console cbe4d0a044a7 rancher/os-network:v0.4.5 "/usr/sbin/entry.sh /" 13 minutes ago Up 13 minutes network d9da62a858d4 rancher/os-ntp:v0.4.5 "/usr/sbin/entry.sh /" 13 minutes ago Up 13 minutes ntp dc4b0f37cd86 rancher/os-udev:v0.4.5 "/usr/sbin/entry.sh /" 13 minutes ago Up 13 minutes udev e932a592abf3 rancher/os-acpid:v0.4.5 "/usr/sbin/entry.sh /" 13 minutes ago Up 13 minutes acpid c866fe780221 rancher/os-syslog:v0.4.5 "/usr/sbin/entry.sh /" 13 minutes ago Up 13 minutes syslog Check your /var/log/docker.log see if you are running into #18283: Error starting daemon: Error initializing network controller: could not delete the default bridge network: network bridge has active endpoints.

Enabling emacs style shortcuts in GNOME

April, 01th 2016
Emacs aficionado? Want to use your beloved keyboard movements everywhere – including Firefox? Turns out this is just one command away: $ gsettings set org.gnome.desktop.interface gtk-key-theme "Emacs" And we’re done.

Enabling public key authentication in CentOS

February, 13th 2015
If you are wondering why CentOS is ignoring your ~/.ssh/authorized_keys file for a user you created with an interactive script or e.g. using Puppet – check that you restored the SELinux context in the users home directory: $ restorecon -Rv /home/user/.ssh

Choosing a Vagrant default provider

December, 12th 2013
If you are using the VMWare Fusion or Workstation Providers with Vagrant, you are likely to have VirtualBox Installation left on your machine. At least that’s the case for me. So if you’re annoyed about the Vagrant default behaviour $ va status Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed. Vagrant uses the `VBoxManage` binary that ships with VirtualBox, and requires this to be available on the PATH.

Adjusting the Crunchbang cursor size

October, 17th 2013
Firing up Crunchbang in dual screen mode (via arandr) made the cursor appear huge on some windows. A quick duck duck go search revealed this forum post, which had the correct solution: Just adjust your ~/.Xdefaults file to your liking: {% highlight bash %} Xcursor.size: 16 {% endhighlight %} (I guess the additional xrdb -merge ~/.Xdefaults is just cargo culting)

Building a Vagrant VMware base box for CentOS 6.4

October, 07th 2013
If you followed the ‘semi official’ guides for installing the vmware-tools in CentOS 6, you might end up with a box that has all necessary tools installed, but won’t load them at boot time. Vagrant doesn’t like it that much: {% highlight bash %} [default] Configuring network adapters within the VM… The HGFS kernel module was not found on the running virtual machine. This must be installed for shared folders to work properly.

Unzipping encrypted (win)zip files in linux

July, 17th 2013
Last week I got my hands on an »encrypted« .zip file, the built-in zip command wouldn’t eat: {% highlight bash %} $ unzip vpn.zip Archive: vpn.zip skipping: vpn/my-config-file.ovpn need PK compat. v5.1 (can do v4.5) {% endhighlight %} The solution is pretty simple: Just install 7-Zip. It’s free software and should come with every decent linux distribution. {% highlight bash %} $ 7z x vpn.zip Processing archive: vpn.zip Extracting vpn Extracting vpn/my-config-file.ovpn Enter password (will not be echoed) : {% endhighlight %} Done.

Emulate a robots.txt file with a simple nginx directive

June, 20th 2013
If you use nginx as a reverse proxy, you might want to emulate a simple robots.txt file just to be sure that Googlebot doesn’t traverse into each and every location. So why bother serving those bytes from a file when you can answer requests directly from nginx: location /robots.txt { return 200 "User-agent: *\nDisallow: /"; }

Bootstrap a Vagrant VM before running the provisioner.

June, 08th 2013
This might not be the most elegant way to deal with this problem, but often enough I find myself in a situation in which I try to run bootstrapping-stuff in my puppet-manifests or run a simple apt-get update command before provisioning with Puppet. One way to solve this dilemma is to bootstrap custom Vagrant boxes with a tool like Veewee, which has served me well for more than a few times now.

Subsonic won't play MP3 or AAC files

June, 05th 2013
I’m currently running my private trial in hosting Subsonic as my personal Spotify-Replacement. So far everything worked out well unless I noticed that it kept skipping all the songs I’ve bought in iTunes. A quick peek at the logs reveals {% highlight text %} Log: (/var/subsonic/transcode/ffmpeg) Encoder (codec id 86017) not found for output stream #0.0 {% endhighlight %} so what was missing, was just the standard evil codec package. E.g.

Importing Posterous archives into Jekyll

June, 04th 2013
As I got dropped from posterous I was searching for a simple solution to import my old posterous content into a simple Jekyll Blog structure. All the other importers I tried had problems importing my posts directly from posterous (as they are probably already down at the time you are reading this). Gladly Paul McCarthy already got this covered with PR 12. So just checkout out his branch (or the Jekyll-Importer master if it got merged meanwhile): {% highlight sh %} $ git clone https://github.com/jekyll/jekyll-import.git $ git checkout initial-migrator-import {% endhighlight %} Extract your posterous archive and run the importer: {% highlight sh %} $ unzip /tmp/space-691755-techbascht-02f0c75da3aece386d91260.zip -d /tmp/ $ ruby -r ‘./lib/jekyll/importers/posterous-archive.rb’ -e ‘ >> Jekyll::PosterousArchive.process(“/tmp/space[…]“)’ {% endhighlight %} Check and extract the files.

re-init

June, 03th 2013
Let’s get this started again. Ever since Posterous shut down their platform I’ve wanted to move my old tech.bascht.com snippet-blog to my own site. I am using Octopress for my main blog at bascht.com but there is no simple solution for splitting up the _posts directory into multiple sub-sites I went back to trusty ol’ Jekyll. Enjoy reading.

Getting the EPSON CX11NF to work with Linux

December, 10th 2012
Linux. And printing. Well that’s another chapter. In my current office there is a EPSON AcuLaser CX11(NF) - the setup is fairly simple (if you know the hoops you’ll have to jump through). Get the driver from the (horrible) EPSON Download Section. Install the .rpm / make install the .tar.gz. Create proper symlinks to the epson binaries {% highlight sh %} $ ln -s /usr/bin/pstoalcx11.sh /usr/lib/cups/filter/ $ ln -s /usr/bin/alcx11_lprwrapper.sh /usr/lib/cups/filter/ $ ln -s /usr/bin/alcx11 /usr/lib/cups/filter/ {% endhighlight %} Talk to the printer via a direct socket (If prompted by your GUI use something like socket://10.10.0.11:9100) Voila.

5 Scary Things That Facebook Knows About You

January, 01th 0001
Amidst the privacy policy debacle that Facebook is facing, another tip off from one of their employee is definitely not helping their current situation. An interview with an anonymous Facebook employee conducted on blogsite The Rumpus confirms that Facebook knows your every move. They know who you are stalking and when you do it; this information is stored permanently. The full interview can be found here, and not all the information are new but there are a few shocking statements included.

An interview with Andrew Plotkin : The Setup

January, 01th 0001
Because if your typing doesn't sound like a hailstorm on a tin roof, you're not typing. via andrew.plotkin.usesthis.com Quiet amusing usesthis Interview with Andrew Plotkin.

Apaches little helpers

January, 01th 0001
I installed my mamp stack via macports, so the normal GUI-tools of Mac OS won't let me toggle any services. Coming from the Linux / init world thats my bumbling approach to have a quick startup-script for Apache and MySQL: #!/bin/bash if [ "$1" == "start" ]; then /opt/local/apache2/bin/apachectl start& /opt/local/bin/mysqld_safe5& else /opt/local/apache2/bin/apachectl stop /opt/local/bin/mysqladmin5 -u root shutdown fi

Applying Mathematics To Web Design - Smashing Magazine

January, 01th 0001
Mathematics is beautiful.” This may sound absurd to people who wince at numbers and equations. But some of the most beautiful things in nature and our universe exhibit mathematical properties, from the smallest seashell to the biggest whirlpool galaxies. In fact, one of the greatest ancient philosophers, Aristotle, said: “The mathematical sciences particularly exhibit order, symmetry and limitation; and these are the greatest forms of the beautiful. via smashingmagazine.com

Compass CSS

January, 01th 0001
via compass-style.org Compass is a stylesheet authoring tool that uses the Sass stylesheet language to make your stylesheets smaller and your web site easier to maintain. Compass provides ports of the best of breed css frameworks that you can use without forcing you to use their presentational class names. It’s a new way of thinking about stylesheets that must be seen in action!

Don’t be afraid of PHP 5.3 | Juozas devBlog

January, 01th 0001
While attending PHPUK conference in London, I noticed how much talk there is about PHP 5.3 and “when to upgrade?”, there was even a presentation about that. Because I have been using PHP 5.3 for more than half a year, I decided to share my views on this topic. This topic is very important as the earlier PHP 5.3 is adopted, the sooner second iteration of frameworks can be released

Everyone thinks they're hiring the top 1 percent

January, 01th 0001
By the way, it's because of this phenomenon—the fact that many of the great people are never on the job market—that we are so aggressive about hiring summer interns. This may be the last time these kids ever show up on the open market. In fact we hunt down the smart CS students and individually beg them to apply for an internship with us, because if you wait around to see who sends you a resume, you're already missing out.

Exclude .svn subdirectories in your grep search

January, 01th 0001
Just a little reminder for myself: In 93 of 95 cases i want to exclude all of the .svn subdirectories lying around in my working copy. Andreas brought that one to my mind again with a nasty forest of grep pipes. ;-) grep -R --exclude \*.svn\* your_pattern gives me only the output I really need. Update (2:42pm): Gosh. After @denderello got nudged about my last blog post I gave http://betterthangrep.com/ a try.

Expedia on how one extra data field can cost $12m

January, 01th 0001
Online travel firm Expedia has found that data analytics can deliver a multi-million dollar kick to a company's bottom line. The company used analytics to identify a single change to a web page that generated an overnight surge in sales, Expedia's VP of global analytics and optimisation Joe Megibow told the Premier Business Leadership Series conference in Las Vegas last week. via silicon.com

FBI drive for encryption backdoors

January, 01th 0001
According to the proposal, any company doing business in the States could not create an encrypted communication system without having a way for the government to order the company to decrypt it, and those who currently do offer that service would have to retool it. It's the equivalent of outlawing whispering in real life. Cryptographers have long argued that backdoors aren't a feature—they are just a security hole that will inevitably be abused by hackers or adversarial governments.

Fixing apache2 on Ubuntu 10.04

January, 01th 0001
Everything went well after upgrading my Ubuntu LTS installation to 10.04 LTS until I noticed that apache and lighttpd won't come up after a system reboot. I thought it might be a small hickup with the upstart-migration. Well, turns out it wasn't: In /var/log/boot.log i have found Cannot assign requested address: make_sock: could not bind to address Yep. Ubuntu wouldn't bring up my virtual network interfaces on time… Gladfully someone else had this problem before.

Fuzz Box: Resign Patterns

January, 01th 0001
2.5 Fromage The Fromage Pattern is often full of holes. Fromage consists of cheesy little software tricks that make portability impossible. The older this pattern gets, the riper it smells. via fuzz-box.blogspot.com

Germany.rb 2010 in Leipzig

January, 01th 0001
Germany.rb 2010 in Leipzig Am 18. und 19. September 2010 findet im sublab in Leipzig zum ersten Mal das Ruby User Treffen Germany.rb statt. Eingeladen ist jede an Ruby Interessierte Person – vom Beginner bis zum Experten. via ruby-lang.org

Google Instant Makes SEO Irrelevant

January, 01th 0001
Google today launched an ambitious effort to speed up searching. But what they really did is kill SEO. Google says: "Google Instant is a new search enhancement that shows results as you type. We are pushing the limits of our technology and infrastructure to help you get better search results, faster. Our key technical insight was that people type slowly, but read quickly, typically taking 300 milliseconds between keystrokes, but only 30 milliseconds (a tenth of the time!) to glance at another part of the page.

Hello, Posterous.

January, 01th 0001
Though there's a permanent need to post tech stuff to my primary blog at http://blog.bascht.com, I wanted to keep that place more like a personal weblog, e.g. clean. So what you're seeing here, is the workaround for that: It's the Tech-Blog of Bascht. This is the place where I want to post code snippets, rants and beautiful findings around the world of Symfony, Doctrine and other fancy stuff. And, beware: It's got syntax highlighting!

Hudson's future | Hudson Labs

January, 01th 0001
Second, out of respect for Oracle's trademark claim on Hudson, we will move our infrastructure off of Oracle-owned and hosted servers, and we will rename existing independent components of the infrastructure to no longer use "Hudson" - i.e., mailing lists, Github repos, etc. This would be a gradual process, obviously. via hudson-labs.org

Installing the ruby-filemagic gem via bundler on OSX

January, 01th 0001
If you're running into trouble when installing the ruby-filemagic gem on Mac OS X: Installing ruby-filemagic (0.4.2) with native extensions /Users/bascht /.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /Users/bascht/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb checking for magic_open() in -lmagic... no *** ERROR: missing required library to compile this module You might wanna hand over the path to your macports installation of file. --with-magic-dir=/opt/local Kudos to @Xylakant who

Kill Your To-Do List | Zen Habits

January, 01th 0001
Those who don’t have a to-do list probably feel they should, because they’re swamped and feeling overwhelmed. I’m here to suggest: kill your to-do list. via zenhabits.net Good read. Especially If you are stuck somewhere in the middle of your Allen Bible (like me).

Ksplice - Hello from a libc-free world!

January, 01th 0001
As an exercise, I want to write a Hello World program in C simple enough that I can disassemble it and be able to explain all of the assembly to myself. This should be easy, right? via blog.ksplice.com

Mac & the iPad

January, 01th 0001
Unlike Microsoft in the early days, these guys move fast, and they add real additional value along the way. via asktog.com Good essay on the parallels between iPad and the first Macs. (via Slashdot)

Master Foo and the Ten Thousand Lines

January, 01th 0001
“And who better understands the Unix-nature?” Master Foo asked. “Is it he who writes the ten thousand lines, or he who, perceiving the emptiness of the task, gains merit by not coding?” Upon hearing this, the programmer was enlightened. via catb.org

Run Effective, Google-Style Meetings - Lifehacker

January, 01th 0001
via lifehacker.com

Say Something Nice About Every Language You’ve Used

January, 01th 0001
In Michael Easter’s recent post, I was struck by his comment that Guy Steele like all languages. Seems like a pretty chill way to live a programming career. So I wondered, do I like all languages? Can I say something nice about every language I’ve used? As the saying goes, “If you can’t say something nice, don’t say nothin’ at all.” via blog.darevay.com

Scott Chacon | The Geek Talk

January, 01th 0001
At GitHub we don’t have a project tracker or todo list – we just all work on whatever is most interesting to us. No standup meetings, burndown charts or points to assign. No chickens or pigs. It’s sort of the open source software style of business – everyone itches thier own scratch. Inexplicably, it works really well and keeps everyone engaged, new features appearing quickly and bugs fixed rather fast. No managers, directors, PMs or departments – and it’s the most agile, focused and efficient team I’ve ever worked with.

Secured Typing - The Daily WTF

January, 01th 0001
Gary's company has an "enterprise" application, and like any enterprise application, it was built to be all things for all people, by people that didn't have a clear picture of which things it was supposed to be to whom. While a customer could, in theory, install and configure it on their own, pretty much everyone paid for a consultant to handle the setup for them. Gary was one of those consultants.

Skip closing Brackets in VIM

January, 01th 0001
I love VIM and I recently stumbled upon a feature that you probably know from TextMate: Skip the Closing bracket when typing. Sure. VIM can do that. inoremap ( () inoremap ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\" : ")" This just skips the closing bracket and you can go on typing without having to leave insert mode or do some awkward Emacs movements. Found at http://vim.wikia.com/wiki/Automatically_append_closing_characters

Slicehost Articles: Ubuntu Lucid Setup - Part 2

January, 01th 0001
If the code doesn't match what it should be for the localization you would like to use for your slice (or if it uses a generic locale like 'POSIX'), run something like the following commands: sudo /usr/sbin/locale-gen en_US.UTF-8 sudo /usr/sbin/update-locale LANG=en_US.UTF-8 via articles.slicehost.com I should get these two lines tattooed somewhere, as I always end up on google, when setting up some new lucid boxes…

Solve the Problem, Calm the Client & Save the Project

January, 01th 0001
We’re always talking about tough clients, bad clients and boring clients. But what about the great clients who are simply having a hard time? When you work remotely, it can be difficult to tell when clients or colleagues — good or otherwise — are having serious trouble achieving a task you need them to do. via webworkerdaily.com A must-read for every freelance worker / artist.

Soon to come: Symfony definitive guide for 1.3 and 1.4

January, 01th 0001
Hi all, I'm listening... but I needed some time to think about the topic a bit more before answering. Here are my thoughts(…) via groups.google.co.uk Looks like Fabien is definitely one of those guys with 48 hours / day. No matter how he manages his time, this step looks really promising.

Spamassassin FH_DATE_PAST_20XX test buggy in 2010

January, 01th 0001
It seems there is an issue with the Spamassassin FH_DATE_PAST_20XX test. This test checks whether the email has a date in the future and, if this is the case, raises the message’s score. Apparently, this test is falsely triggered by all emails that have been sent in 2010, producing several false positives. via g-loaded.eu Due to a bug in the Spamassassin ruleset a lot of messages fail the FH_DATE_PAST_20XX check 'cause they are sent in 2010(!).

Symfony Live Conference, Symfony 2.0 and DI

January, 01th 0001
Now if some people cannot accept that Symfony 2 is really fast and if they cannot accept that Symfony 2 is great step forward for PHP, that's sad. The web evolves very fast. Competition is everywhere for PHP. We should all be in the same boat. via fabien.potencier.org

Thank you, Rails

January, 01th 0001
This is all pretty understandable: it’s easy to define community in terms of what we’re not. A common enemy focuses and drives us. Competition can take a positive form: when it’s friendly and constructive both communities benefit. Lately, though, I’ve noticed the tone of the arguments in the Django community getting nastier — especially when it comes to Rails. Again, I’m far from innocent in this regard: I’ve certainly done my fair share of Rails-bashing, and I regret it.

The MIT Hacker Ethic

January, 01th 0001
Steve Levy, author of Hackers: Heroes of the Computer Revolution," outlined the hacker ideal at MIT as consisting of the following principles: Sharing Openness Decentralization Free access to computers World Improvement via hangger.com

fguillen/simplecov-rcov - GitHub

January, 01th 0001
SimpleCov Rcov Formatter gem Is a Rcov style formatter for the ruby 1.9+ coverage gem: SimpleCov. The target of this formatter is to cheat on Hudson so I can use the Ruby metrics plugin with SimpleCov. So if you are looking some kind of workaround to integrate SimpleCov with your Hudson + Ruby metrics plugin this is a beginning. via github.com

lolbash.sh

January, 01th 0001
# LOL!!1 alias wtf='dmesg' alias onoz='cat /var/log/errors.log' alias rtfm='man' alias visible='echo' alias invisible='cat' alias moar='more' alias icanhas='mkdir' alias donotwant='rm' alias dowant='cp' alias gtfo='mv' alias hai='cd' alias plz='pwd' alias inur='locate' alias nomz='ps -aux' alias nomnom='killall' alias cya='reboot' alias kthxbai='halt'

tmux settings for screen + vim fans

January, 01th 0001
If you don't mind, I'd share my tmux config with you. I have mapped the control key to <ctrl> + <a> because I also got some boxes with GNU Screen flying around and I just can't remap my fingers… The pane movements are adapted from the standard VIM movements. setw -g window-status-current-attr underscore setw -g mode-keys vi set -g status-keys vi set -g prefix C-a set-window-option -g utf8 on set-window-option