venerdì 9 settembre 2016

ffmpeg cheatsheet


Converting movie container without changing encoding:

ffmpeg -i movie.MTS -vcodec copy -acodec copy movie.mp4

lunedì 22 settembre 2014

Accurately checking memory usage in linux

A nice python script published here:

https://github.com/pixelb/ps_mem/

It implements a number of algorhythms to be as accurate as possible

Recurring locale problem in Ubuntu

A fix for Perl warnings, command-not-found crashes, etc:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales

I don't think this is the real solution, there may be something on the client side (iTerm2) to figure out as well.

UPDATE:

Adding the following to .bashrc seems to solve the problem:

export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

martedì 2 aprile 2013

Here's a nice collection of Ruby one-liners. Having a few of these formulas at hand, may save you lots of work...

mercoledì 27 marzo 2013

Creating a remote git repo

Assuming you have a project in your local machine and console access to a remote server (and git installed on both), these instructions will accomplish the following:

  1. turn your local copy into a git repository
  2. push it to the remote server

venerdì 25 maggio 2012

Finding out where a ruby method is defined

To find out the source file/line of a ruby method definition, do something like the following:

Post.all.method(:all).source_location
Post.first.method(:save).source_location

Here's the source of this tip.

lunedì 18 luglio 2011

Unencrypting home directory in Ubuntu

In an Ubuntu install, I once requested home folder encryption. Bad idea.

To revert to regular file management I followed these instructions, which involved commenting out a line in each of the /etc/pam.d/common* files.

During a subsequent aptitude safe-upgrade, those lines were restored, not sure why.

I have again commented them out.

martedì 14 giugno 2011

UTF-8-related warning from rack

After a recent bundle update (early June 2011), the following warning shows up while running specs:

GEM_PATH/rack-1.2.3/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string

This post addresses the problem, although it's strange that the problem in my case appeared just now.

martedì 17 maggio 2011

Restoring proper TextMate bindings for RoR and RSpec

If you cannot get TextMate to use the correct bundles for Ruby on Rails and RSpec code, then you may have manually modified the bindings in a way that confuses TM.

These instructions will fix the problem.

lunedì 9 maggio 2011

Ubuntu server: mounting a USB drive

Follow these directions!

In a nutshell, for an NTFS drive:
$ sudo fdisk -l
$ sudo mkdir /media/myusb
$ sudo mount -t ntfs-3g /dev/sdb1 /media/myusb
$ sudo umount /media/myusb

mercoledì 27 aprile 2011

dot-underscore files when macos copies to other file systems

In certain situations, copying files from the Mac file system to a different fs (e.g. to NTFS via NTFS-3g) results in the creation of extra 4KB-long files with names that begin with ._

Not sure how to prevent this. Look at the comments in this post.

To erase all those files from a directory tree:

$ rm */._* -R -v

(careful...)

Also see this for a terminal command that merges ._s with the original file

giovedì 23 dicembre 2010

Problem connecting to a MySql server

While trying to connect MS-Access via ODBC to a mysql server, I kept getting this error:

connection failed mysql 10060

The page that explained the problem is:

http://forge.mysql.com/wiki/Error2003-CantConnectToMySQLServer

The default /etc/mysql/my.cnf has

[mysqld]
...
bind_address=127.0.0.1
...


which must be commented out for a remote client to gain access to the server

mercoledì 22 dicembre 2010

HTML cleanup with regexp and TextMate

to remove all spans: cmd-F, activate regexp, then:

Find: <span.*?>(.+?)<\/span>
Replace: $1


the question marks prevent greedy matching

lunedì 20 dicembre 2010

Autotest config

What seems to be working for me is the following:

group :development, :test do
gem 'rspec-rails'
gem 'webrat'
gem 'autotest'
gem 'autotest-growl'
gem 'autotest-rails'
gem 'cucumber-rails'
gem 'factory_girl_rails'
gem 'mocha'
gem 'launchy'
end

And in ~/:autotest
require 'autotest/growl'
Autotest::Growl::clear_terminal = false
Autotest.add_hook :initialize do |at|
at.find_directories = ['./features', './spec', './app', './lib']
end

The hook selects directories to watch. The default setup caused autotest to run features continuously

venerdì 17 dicembre 2010

Setting up SSHFS connections

First, make sure you can ssh to the server

On the local machine (universe must be enabled):
$ sudo aptitude install sshfs
$ sudo chmod +x /bin/fusermount
$ mkdir /home/giuseppe/remote
$ sudo modprobe fuse
the last command loads fuse. In order for this to happen automatically at startup:
$ sudo cp /etc/modules /etc/modules_bak
$ sudo sh -c "echo 'fuse' >> /etc/modules"
Now the actual mounting:
$ sshfs the.remote.machine:/shared/path /home/giuseppe/remote