Skip to content

Instantly share code, notes, and snippets.

View samrocketman's full-sized avatar

Sam Gleske samrocketman

View GitHub Profile
@samrocketman
samrocketman / gitlab_remote_backup_recovery.md
Last active August 29, 2015 13:56
Backup gitlab from the CLI to a remote system when you're either out of space or the filesystem is readonly.

Backup from GitLab to remote machine

If you have a readonly system on your GitLab system then this method is recommended. Log into root user of your gitlab system.

cat ~git/gitlab/config/database.yml to get your database credentials and backup DB to remote system.

unset HISTFILE
/usr/bin/mysqldump -u GITLAB_DB_USER_CHANGEME -pGITLAB_DB_PASS_CHANGEME --skip-extended-insert --create-options --databases GITLAB_DATABASE_CHANGEME | gzip -c - | ssh user@remotehost.com 'cat > gitlab_backup_db.mysql.gz'

Backup repositories.

@samrocketman
samrocketman / ssh_aliases.md
Created April 2, 2014 20:13
Aliasing hosts using ssh `config`.

In ~/.ssh/config you can specify host aliases. For example, let's say you have two different keys you want to use for the same user living on the same host. You would do that in the following manner... (excerpt from ~/.ssh/config)

Host localhost
  User git
  IdentityFile /home/systems/.ssh/id_rsa
Host myaliashost
  HostName localhost
  User git
 IdentityFile /home/systems/.ssh/another_id_rsa
@samrocketman
samrocketman / sample.cpp
Created October 7, 2014 23:18
A sample c++ function.
#include <iostream>
using namespace std;
int add(int a, int b)
{
return a+b;
}
int main(void)
@samrocketman
samrocketman / reference.cpp
Created October 21, 2014 00:36
Value vs Reference
/*
* Sam Gleske
* Value vs Reference
*/
#include <iostream>
using namespace std;
int main(void)
{
@samrocketman
samrocketman / inches_to_feet.cpp
Last active August 29, 2015 14:07
Inches to feet play
/*
* Sam Gleske
* Inches to feet
*/
#include <iostream>
using namespace std;
//global constants
float const INCHES_IN_FOOT = 12;
#!/bin/sh
# based on http://offbytwo.com/2008/05/09/show-ip-address-of-vm-as-console-pre-login-message.html
# need to be root to write out these files
if [ `id -u` != 0 ]; then
echo "Need to run as root. Maybe use sudo..."
exit
fi
GET_IP_ADDRESS='/usr/local/bin/get-ip-address'
@samrocketman
samrocketman / build.gradle
Created January 17, 2015 04:45
A failing test case for extended properties in build -> dependencies section of gradle.
apply plugin: 'groovy'
ext { groovyVersion = "1.8.9" }
println "Using Groovy ${project.groovyVersion}"
buildscript {
repositories { mavenCentral() }
dependencies {
//classpath "org.codehaus.groovy:groovy-all:${groovyVersion}"
}
@samrocketman
samrocketman / .gitignore
Last active November 25, 2015 21:44
Using xargs to process multiple arguments and commands in parallel. Use case is for software that does not take advantage of multiple cores processing independent data. This means data can be split and processed separately.
/tmp
@samrocketman
samrocketman / GitLab_projects_function.py
Last active December 25, 2015 07:09
This shows what pyapi-gitlab would be like without pagination on by default.
#snippet taken from pyapi-gitlab @ 2df11db8714a4657020a994ad940bd82858ca39b
#https://github.com/Itxaka/pyapi-gitlab/blob/2df11db8714a4657020a994ad940bd82858ca39b/gitlab/__init__.py#L287-L304
def getprojects(self, page=None, per_page=None, sudo=""):
"""
Returns a dictionary of all the projects
:param page: Which page to return (default is None which returns all)
:param per_page: Number of items to return per page (default is None which returns all)
:return: list with the repo name, description, last activity,
web url, ssh url, owner and if its public
@samrocketman
samrocketman / gist:7090089
Created October 21, 2013 20:08
gitconfig tree alias
[alias]
tree = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white). %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
tree2 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white). %an%C(reset)' --abbrev-commit