Skip to content

Instantly share code, notes, and snippets.

View tomcbe's full-sized avatar

Thomas Bernhart tomcbe

View GitHub Profile
@tomcbe
tomcbe / rails.md
Created October 19, 2020 10:28 — forked from zulhfreelancer/rails.md
Delete all tables data and recreate tables in Rails

You can have finer control with:

rake db:drop:all

And then create the database without running the migrations:

rake db:create:all

Then run all your migrations:

@tomcbe
tomcbe / slash.sh
Created June 14, 2020 12:27 — forked from luciomartinez/slash.sh
Add or Remove trailing slash in bash
### Add trailing slash if needed
STR="/i/am/a/path"
length=${#STR}
last_char=${STR:length-1:1}
[[ $last_char != "/" ]] && STR="$STR/"; :
echo "$STR" # => /i/am/a/path/
@tomcbe
tomcbe / restore-config-files-with-apt.md
Last active June 11, 2022 14:59
Restoring config files with apt

Find out what package installed the config file:

$ dpkg -S unity-greeter.conf
unity-greeter: /etc/lightdm/unity-greeter.conf

As you can see, the name of the package is unity-greeter.

If you deleted a directory, like /etc/pam.d, you can list every package that added to it by using the directory path:

Update 7/28/2019: An updated version of this guide for Ubuntu Server 18.04 LTS is now available. Feel free to check it out.

Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)

Steps:

  1. Open VirtualBox
  2. Right-click your VM, then click Settings
  3. Go to Shared Folders section
@tomcbe
tomcbe / openssl_commands.md
Last active October 1, 2019 16:23 — forked from p3t3r67x0/openssl_commands.md
Some list of openssl commands for check and verify your keys

openssl

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@tomcbe
tomcbe / puma.service
Created June 28, 2019 17:06 — forked from casperbrike/puma.service
Puma service for systemd
# username
# appname
# gemset
[Unit]
Description=Puma HTTP Server
After=network.target
[Service]
Type=forking
@tomcbe
tomcbe / puma.service
Created June 28, 2019 17:05 — forked from r00takaspin/puma.service
Run puma web server with RVM from systemd
[Unit]
Description=Puma HTTP Server
After=network.target
# Uncomment for socket activation (see below)
# Requires=puma.socket
[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple
@tomcbe
tomcbe / gist:93d9a6eefee27dec3d30bd937602c1df
Created June 10, 2019 21:59 — forked from tuxfight3r/gist:51d42005694c76286e80
mirror maven repository via wget
wget -P/local/target/directory -r -nH -np --reject html http://mirrors.dotsrc.org/maven2/
wget will put a maven2 repository folder under /local/target/directory on your machine, along with all the repositories artifacts.
@tomcbe
tomcbe / clean-up-boot-partition-ubuntu.md
Created May 29, 2019 15:24 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@tomcbe
tomcbe / git-stop-tracking-remote-branch.md
Created January 15, 2019 15:39 — forked from magnusbae/git-stop-tracking-remote-branch.md
How to make Git stop track a remote branch without deleting the remote branch.

You don't have to delete your local branch.

Simply delete your remote tracking branch:

git branch -d -r origin/<remote branch name> (This will not delete the branch on the remote repo!)

See "Having a hard time understanding git-fetch"

there's no such concept of local tracking branches, only remote tracking branches.