How to install a debian/ubuntu package without dependencies
Please note that you can break your system with this! This is not recommended.
Sometimes the package repository has errors. If you can't install a package because you can't install the dependencies with the package manager you can try this:
(You have to download the deb first e.g. from here or here)
dpkg -x bad-package.deb common
dpkg --control bad-package.deb
Then you have to edit DEBIAN/control
with an editor. You can delete the broken dependencies t...
Git: Change author of a commit
Using git rebase
can be painful but luckily you can resort to cheating with git reset
and committing anew.
Now what if you wanted to rebase commits of other people and still wish them to be the authors of their code? Easy: make them the author of a commit you made.
When you have freshly staged changes that are ready to be committed, just use the --author
switch:
git commit -m "Hello Universe" --author="Philip J Fry <someone@example.com>"
If...
How to fix: Gems are unavailable although they are installed
- If Rails or Rake are complaining about a missing gem that is listed in your
Gemfile.lock
and the listed version is properly installed, something is seriously wrong and needs to be fixed. - If you accidently executed
bundle install some_gem
although you wantedbundle update some_gem
What is wrong
Let's say your Gemfile
asks for some-gem
which you can see when running gem list
but bundle show some-gem
just gives you an error:
Could not find gem 'some-gem', in any of the sources
Another indicator: Doing a `...
Git: List remote branches
Sometimes you may need to figure out what branches exist on a remote repository so you can pull them down and check them out, merge them into your local branches, etc. You can see the remote branches by saying
git branch -r
Or, if you want to see both local and remote branches, you can say
git branch -a
sstephenson/execjs - GitHub
ExecJS lets you run JavaScript code from Ruby. It automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Ruby object.
We forked craken
We forked craken today and fixed one of the issues we had with new (>0.8.7) rake versions.
The craken:install
rake task raised a "can't convert Hash into String" error e.g. while deploying with Capistrano.
A few git tips you didn't know about
Random list of useful git commands for advanced users. I found some of them useful.
xdissent/ievms - GitHub
Microsoft provides virtual machine disk images to facilitate website testing in multiple versions of IE, regardless of the host operating system. Unfortunately, setting these virtual machines up without Microsoft's VirtualPC can be extremely difficult. These scripts aim to facilitate that process using VirtualBox on Linux or OS X. With a single command, you can have IE6, IE7, IE8 and IE9 running in separate virtual machines.
mojombo/grit - GitHub
Grit gives you object oriented read/write access to Git repositories via Ruby.
Fix Rubygems warning: Gem.source_index is deprecated, use Specification
After updating Rubygems you see a wall of deprecation warnings like this:
NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from /usr/local/lib/site_ruby/1.8/rubygems/source_index.rb:197.
NOTE: Gem::SourceIndex#add_specs is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#spec_dirs= called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.14/lib/bundler/rubygems_integration.rb:175
...
Best GitHub feature
When browsing a repository, pressing "t" allows you to quickly search for file names. Very awesome!
Go here to try it out.
Solarized color scheme for Rubymine
If you want to use the (badly implemented!) solarized color scheme in your Rubymine IDE:
-
Clone the IntelliJ IDEA port:
git clone https://github.com/jkaving/intellij-colors-solarized.git
-
Import the settings in Rubymine by chosing the above directory
File -> Import Settings
-
Change the color scheme in the settings (Ctrl-Alt-S) in
Editor -> Colors & Fonts
Note that selecting a color scheme will also reset your previous editor font choice. You might want to change the font to [Envy Code R](http://damieng.com/blog/2008/05/2...
Shell script to generate a Git commit with Pivotal Tracker story ID and title
We usually generate our commit messages from Pivotal Tracker IDs and titles, like
[#15775609] Index view for conflicts
The geordi command commit
automates this. (See: Pretty Commit messages via geordi).
Just run geordi commit
and it will connect to PT and let you select from a list of all started and finishes stories. Then it runs git commit
with the generated message (i.e. all staged changes will be commited).
When running for the first time, Geordi will request your PT...
Dotfiles: Keep your linux configuration on github
Running the Awesome window manager within Gnome
Note: Consider using MATE instead of Gnome 3 on newer system
Awesome is a very good tiling window manager that provides neat features like automatic layouting of windows, good multi-display support with per display workspaces and more. Unfortunately, it is only a window manager, and lacks a lot of Gnome's conveniences like the network manager, application menus, automatic updates etc.
Fortunately, Gnome allows you to selectively replace only the win...
Installing Rails on a fresh system
- Install Ruby from the Ubuntu repository:
sudo apt-get install ruby ruby-dev
\
ruby
is the meta package. If you want to explicitly install 1.8 or 1.9, installruby1.8
orruby1.9
instead (the same applies forruby-dev
). - Do not install RubyGems from the repository but install the version from the webpage instead.
- Get Bundler:
sudo gem install bundler
Rails and other gems for a project should now be installed via bundle install
from the...
console-for opens a Rails console remotely on a Capistrano deployment target
We're adding a script console-for
to open a remote Rails console with one command. Also have a look at shell-for
, which this script is relying on.
Run it from any project directory like this, passing a Capistrano multistage deployment target:
console-for staging
This script is part of our geordi gem on github.
How to fix: undefined method `specifications' (caused by RubyGems 1.8)
Sometimes, when running a rake task, RubyGems 1.8.5 raises an error:
rake aborted!
undefined method `specifications' for "/usr/lib/ruby/gems/1.8":String
This has been fixed since May 31 but is still not available as a new RubyGems version.
Either wait for a new version to eventually come out, downgrade to some really old version (1.6.2 works for some) or apply the fix manually:
- Find your rubygems.rb -- mine was located at `/usr/local/lib/sit...
RubyMine crashes Ubuntu 11.04 window decorator on exit
My RubyMine (and it seems like many other Java GUI applications) crashes the Compiz window decorator almost every time on exit. This also seems to happen for the Unity decorator.
Update: The commited fix from below seems to have made it into the stable Ubuntu repository.
Easy mode
You can restore window decorations by executing this command:
gtk-window-decorator --replace &
This is only a temporary fix.
Hard mode
Also, there is a committed fix that is n...
How to use Git on Windows with PuTTY
-
Get "PuTTY Link" and "Pageant" (an SSH key agent) from the PuTTY download page.
-
Run
pageant.exe
, find its icon inside your system tray and add your SSH key. -
Open up a
cmd
and put the full path to PuTTY'splink.exe
into theGIT_SSH
environment variable, e.g.:set GIT_SSH=D:\PuTTY\plink.exe
You can then use Git like you would on any sane operating system. Just go ahead and git clone
, git pull
, etc.
Also, you may want to add the environment vari...
Order in which RSpec processes .rb files
Because your examples should not change global state, you should not need to care about the order in which RSpec processes your .rb
files. However, in some cases you might want to know.
RSpec 3
- Runs
.rb
files in alphabetical order of their file paths by default (or when you specify--order defined
). - You run t...
Git: How to automatically stage deleted files for commit
When you do a git add .
and have deleted files, git won’t stage them to be commited (as deleted). Use
git add -u
From the git documentation: -u
, --update <filepattern>
Only match against already tracked files in the index rather than the working tree. That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed.
If no is given, defa...
Execution of shell code in Ruby scripts
Deprecated ways to execute shell code in Ruby
This is just a reference for legacy code. For new code, always use capture3
.
%x{ } or backticks – quick and easy
Returns the standard output of running the given command in a subshell. This is an alias for `...`, and you can use string interpolation.
Example:
name = 'ls'
result = `which #{name}`
It does not escape anything you inject in the string, so be aware of possible security vulnerabilities...
Script to create and copy a production dump to your project root
Soon after having written our shell-for script, we wanted to easily get dumps of our productions machines, too. This is how we do it:
dump-for staging [-s]
It will copy the dump to your project's tmp
directory and name it according to the capistrano stage you're calling for, here: staging.dump
. When you pass the optional -s
option, the dump will automatically been sourced into your local development database.
This script ...