Skip to content

Instantly share code, notes, and snippets.

View pstaender's full-sized avatar
👾
extra terrestrial

Philipp Staender pstaender

👾
extra terrestrial
  • Cologne, Germany
View GitHub Profile
@pstaender
pstaender / gitracker.rb
Last active August 29, 2015 14:22
Gitracker - Keeps issues from github in your git repository uptodate (in the branch `issues`). Now you can read issues offline and keep track of them in git versioned manner
#!/usr/bin/env ruby
require "github_api"
require 'net/http'
require 'JSON'
require 'yaml'
require 'date'
module Gitracker
#!/bin/sh
# Encrypt
tar cz folder_to_encrypt | openssl enc -aes-256-cbc -e > out.tar.gz.enc
# Decrypt
openssl aes-256-cbc -d -in out.tar.gz.enc | tar xz
# Or using gpg
@pstaender
pstaender / mysqlbackup_complete.sh
Created April 28, 2015 16:41
complete mysql dump of all databases, including privileges
#!/bin/bash
FREQUENCY=${1:-daily}
DB_BACKUP_DIR_ROOT="/home/backup/mysql/$FREQUENCY"
DB_BACKUP_DIR_TODAY="$DB_BACKUP_DIR_ROOT/`date +%Y-%m-%d`"
DATESTRING=$(date +%Y.%m.%dT%H-%M-%S)
[[ $FREQUENCY = 'weekly' ]] && holdback="+182" || holdback="+31"
# Create the backup directory
@pstaender
pstaender / resume_upload_with_rsync.sh
Created March 31, 2015 05:47
Copy and resume large file upload with rsync
#!/bin/sh
rsync --partial --progress --rsh=ssh ~/file user@remote:~/file
@pstaender
pstaender / import_mysql_dumps.sh
Created March 28, 2015 12:45
Import MySQL Dumps (batch)
#!/bin/bash
if [ $# -eq 0 ]; then
echo "No arguments supplied"
exit 1
fi
SOURCEDIR="$1"
if [ ! -d "$SOURCEDIR" ]; then
@pstaender
pstaender / dubfolders.rb
Last active August 29, 2015 14:17
Find duplicate folders (in progress)
#!/usr/bin/ruby
# The MIT License (MIT)
#
# Copyright (c) 2015 Philipp Staender <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@pstaender
pstaender / dump_mysql_priveleges.sh
Created February 12, 2015 16:04
Dump MySQL Privileges to import in an existing / other database
#!/bin/sh
# from https://saiyedfaishal.wordpress.com/2014/03/20/exporting-all-mysql-user-privileges/
HOST="127.0.0.1";USER="root";PASSWORD="root";mysql -h $HOST -u $USER -p$PASSWORD -Ne "select distinct concat( \"SHOW GRANTS FOR '\",user,\"'@'\",host,\"';\" ) from user;" mysql | mysql -h $HOST -u $USER -p$PASSWORD | sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
@pstaender
pstaender / list.py
Created November 23, 2014 21:24
List google scholar search results for csv usage: ./list.py > list.csv
#! /usr/bin/env python
"""
scholar.py -c 1 --txt --phrase "Upper Echelons - The Organization as a Reflection of Its Top Managers"
"""
import os
import re
import subprocess
directory = os.path.dirname(os.path.abspath(__file__))
@pstaender
pstaender / backup_remote_sever.sh
Last active August 29, 2015 14:04
Simple script to backup (many) remote server files. Includes a lock to avoid concurrent execution.
#!/bin/sh
TARGET=/Volumes/Backup/vserver
SOURCE="root@server01:/folder;root@sever02:/folder"
EXCLUDE="--exclude='.DS_Store'"
LOCK="/tmp/backupserver.lock"
if [ -f "$LOCK" ]; then
echo "locked… remove $LOCK to proceed" >&2
exit 1
@pstaender
pstaender / backup_mysql.php
Created July 17, 2014 08:14
Simple script that creates a MySQL dump of a database. Helpful if you don't have direct access to the database and don't want to use phpmyadmin or the like…
<?php
backup_tables('localhost', 'user', 'passw', 'databasename', '*', true);
/* backup the db OR just a table */
function backup_tables($host, $user, $pass, $name, $tables = '*', $filename = null) {
$return = "";
$link = mysqli_connect($host, $user, $pass, $name);