Working Ninja
2016-04-14T07:34:25

First, make sure we remove .svn folders and files from tracking by adding a new line ".svn/" to our .gitignore file.

Next, we will find all folders that are named .svn and for each folder found remove all files contained within it. Note the only difference between the two commands below is that the first has an extra flag of -n which allows us to perform a dry run to make sure we're removing the correct files. After the dry run, go ahead and remove the files found from tracking:

$ find . -type d -name ".svn" -exec "git rm -r --cached -n" {} \;

$ find . -type d -name ".svn" -exec "git rm -r --cached" {} \;

In my case, the project had tracked files that had been modified that I did not want to commit, so I couldn't simply run git add -u to stage all the SVN files for a commit. Instead, I needed to use the output of git status and run the git rm --cached command on only those files that had a status of deleted:

$ git status | awk '/deleted/ {print $3}' | xargs git rm --cached

And there you have it! We have successfully removed all SVN files from Git without disturbing the rest of your project. Notice that we also used the --cached flag as well. This will leave our files on the filesystem. If we want the files removed from the filesystem, we simply remove the --cached flag.

Sources:
http://stackoverflow.com/questions/5870727/git-need-to-recursively-git-rm-the-contents-of-all-bin-and-obj-folders
http://stackoverflow.com/questions/492558/removing-multiple-files-from-a-git-repo-that-have-already-been-deleted-from-disk

2016-04-06T20:13:12

Commands like SHOW DATABASES and SHOW TABLES are great but what if I need all the columns inside a table?

SELECT column_name FROM information_schema.columns WHERE table_schema = 'your_db' ORDER BY table_name, ordinal_position;

Source: http://stackoverflow.com/questions/5648420/get-all-columns-from-all-mysql-tables

2016-04-06T20:07:45

Today I added a new server to PostgreSQL's host-based authentication file (pg_hba.conf) on a very active PostgreSQL server. Restarting the PostgreSQL service would have lead to service disruption across multiple services. Thankfully the folks at PostgreSQL are one-step ahead of me on this one. There is an option to simply reload the configuration files which, if your configuration updates are up to snuff, won't cause any service distruptions:

$ su - postgres
$ /usr/bin/pg_ctl reload

Source: http://www.heatware.net/databases/postgresql-reload-config-without-restarting/

2016-03-31T22:34:52

I must have it saved somewhere but it was nowhere to be found. The password was lost. My root account was forever secure--or was it?

# service mariadb stop
# mysqld_safe --skip-grant-tables &
# mysql -u root
> USE mysql
> UPDATE user SET password=PASSWORD("mynewpassword") WHERE User='root';
> FLUSH PRIVILEGES
> QUIT

This didn't stop the mysqld_safe process, so I killed the parent mysql process (/usr/libexec/mysqld) via its process ID ($pid).

# kill $pid

Start MySQL back up.

# service mariadb start

Finally, for security purposes, remove the UPDATE user ... SQL statement from ~/.mysql_history.

Profit! And don't forget to securely store your password.

2016-03-30T21:57:36

I was attempting to make a directory listing of sorts earlier tonight and couldn't think up a clean solution. Some surfing on the world wide web offered up a quick template tag solution.

For example, say we have a list of objects (Person) from our app's view, [<Person: Doe>, <Person: Li>, <Person: Smith>, ...], and want to only print the first letter of their last name.

We can do this by first taking the string person.last_name and turning it into a list. Then, to snag just the first item from our newly formed list.

Template Tag with Filter(s) Rendered Output
{{ person.last_name }} Doe
{{ person.last_name|make_list }} ['D', 'o', 'e']
{{ person.last_name|make_list|first }} D

Profit!

Source: http://stackoverflow.com/questions/26058602/want-to-display-the-first-character-of-word-in-django-templates

2016-03-26T10:26:48

GitLab was throwing me a 500 server error this morning after an upgrade via yum. To troubleshoot, I ran the self diagnose command from terminal:

# gitlab-rake gitlab:check

Which gave me the following error to fix:

All migrations up? ... no
  Try fixing it:
  sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
  Please fix the error above and rerun the checks.

Since I installed GitLab via a yum package, I ran a slightly different command to run the GitLab migrations:

# gitlab-rake db:migrate RAILS_ENV=production

Now I was presented with the source of the issue, relating to PostgreSQL. I needed to enable the pg_trgm extension:

== 20160226114608 AddTrigramIndexesForSearching: migrating ====================
-- execute("SELECT true AS enabled FROM pg_available_extensions WHERE name = 'pg_trgm' AND installed_version IS NOT NULL;")
   -> 0.0066s
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

You must enable the pg_trgm extension. You can do so by running "CREATE EXTENSION pg_trgm;" as a PostgreSQL super user, this must be done for every GitLab database.

And sure enough, others were having the same issue. These are the steps they (and I) executed to fix the issue:

# yum install postgresql-contrib
# su - postgres
$ psql -d gitlabhq_production -c "CREATE EXTENSION pg_trgm;"
$ exit
# gitlab-rake db:migrate RAILS_ENV=production
# gitlab-ctl reconfigure
# gitlab-ctl restart

Profit!

Source: https://gitlab.com/gitlab-org/gitlab-ce/issues/14526

2016-03-10T17:26:15
$ VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB

Source: http://askubuntu.com/questions/88647/how-do-i-increase-the-hard-disk-size-of-the-virtual-machine

2016-02-04T22:13:04

"All of us are smarter than any of us, and adding people can, if we do it right, make us smarter and faster and better at serving our customers." -Seth Godin

Source: http://sethgodin.typepad.com/seths_blog/2016/02/loosetight-thoughts-on-management.html

2016-02-04T08:04:04
class AbstractClass(models.Model):
    common_attribute = models.CharField()

    class Meta:
        abstract = True


class SpecializedClass(models.Model):
    specialized_attribute = models.CharField()

    class Meta:
        abstract = True


class AnotherSpecializedClass(models.Model):
    another_specialized_attribute = models.CharField()

    class Meta:
        abstract = True


class MultipleInheritance(AbstractClass, SpecializedClass):
    pass


class TripleMulitpleInheritance(AbstractClass, SpecializedClass, AnotherSpecializedClass):
    pass

Sources: https://docs.djangoproject.com/en/1.9/topics/db/models/#abstract-base-classes,
https://docs.djangoproject.com/en/1.9/topics/db/models/#multiple-inheritance

2016-02-04T07:37:49

I went to update my Ubuntu machine today and found out there wasn't enough space on /boot to perform the update. You can remove older kernels to free up space:

// Check which kernel you're using
$ uname -r

// List all installed kernels
# dpkg --list 'linux-image*'

// Remove the kernel (I recommend the oldest [kernel with the smallest number])
# apt-get remove linux-image-VERSION

Source: https://askubuntu.com/questions/345588/what-is-the-safest-way-to-clean-up-boot-partition