Skip to content

Instantly share code, notes, and snippets.

View AlexRogalskiy's full-sized avatar
🛰️
Work on stuff that matters

Alexander AlexRogalskiy

🛰️
Work on stuff that matters
View GitHub Profile
@AlexRogalskiy
AlexRogalskiy / gio.sh
Created February 27, 2022 12:24
gio - the git.io command-line utility
#!/bin/sh
# Usage: gio url [code]
# Use github's url shortener
set -e
RAWURL=`echo "$1" | sed 's%[^:]*://%%;s%^/%%'`
SUBDOM="${RAWURL%github.com*}"
URLPATH="${RAWURL#*github.com}"
case "$SUBDOM" in
# *.github.com domains not yet supported by git.io: api ca.wiki cloud enterprise jobs pages wiki
@AlexRogalskiy
AlexRogalskiy / gist:903ad2a49050b01b3ee53c9b4999104c
Created February 27, 2022 12:23
Installing the mysql gem on OSX Lion 10.7.2 with Ruby 1.9.3p0 from RVM, MySQL 5.5 from MacPorts and Xcode 4.2
mkdir -p ~/macports
pushd ~/macports >/dev/null
svn co https://svn.macosforge.org/repository/macports/users/pixilla/dports/databases/mysql55
cd mysql55
sudo port install
sudo gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config55 mysql
popd >/dev/null
@AlexRogalskiy
AlexRogalskiy / destructive-hd-performance-test.sh
Created February 27, 2022 12:22
test hd performance on arch linux using iozone
#!/bin/sh
# Data destructive, hardware-safeish performance testing
set -ex
### CONFIGURE ###
DRIVES='sda sdb sdc sdd'
VOLS='sda1 sdb1 sdc1 sdd1'
SCHEDULERS='noop deadline cfq'
FSES='btrfs ext2 ext3 ext4 jfs nilfs2 ntfs reiserfs vfat xfs'
@AlexRogalskiy
AlexRogalskiy / ldapsearch_filter.awk
Created February 27, 2022 12:22
concatenate long ldapsearch lines back together
ldapsearch ... | awk '/^ /{x=$0;gsub(" ","",x);print x};!/^ /{if(length($0)==78){printf$0}else{print}}'
@AlexRogalskiy
AlexRogalskiy / gitolite_ad_group_membership.sh
Created February 27, 2022 12:22
gitolite group membership script for Active Directory
#!/bin/sh
set -e
# Get a list of groups a user is a member of on one line, space-seperated
# Single-quote group names with spaces, otherwise print the rest
SPACE_CHAR='-'
TMP=`mktemp`
ldapsearch -H ldap://domain.local -b OU=Everything,DC=domain,DC=local -LLL -x -z0 -D 'CN=gitolite,OU=Engineering,OU=Everything,DC=domain,DC=local' -y /var/lib/git/gitolite_ad_passwd "(sAMAccountName=$1)" userAccountControl memberOf > "$TMP"
@AlexRogalskiy
AlexRogalskiy / chksums.sh
Created February 27, 2022 03:48
Checksum one-liners.
# bourne shell functions below take 1 argument, the file_to_hash.
# prints hex digest on stdout
md5() {
perl -MDigest::MD5=md5_hex -le'print md5_hex(<> or die)' "$1"
# ruby -rdigest/md5 -e"puts Digest::MD5.file'/dev/null'"
# python -sBc "import hashlib;print hashlib.md5(open('$1','rb').read()).hexdigest()"
# md5 "$1"|cut -d' ' -f4 # mac
# md5sum "$1"|cut -d' ' -f1 # linux
# openssl md5 "$1" | grep -o '[[:xdigit:]][[:xdigit:]]*$' | cat
#!/bin/sh -e
COMMAND="`which gist`"
type() {
PARSED_ARGUMENTS="$PARSED_ARGUMENTS -t $1"
}
private() {
PARSED_ARGUMENTS="$PARSED_ARGUMENTS -p"
@AlexRogalskiy
AlexRogalskiy / gist:7089324afb01bea793041857dbbe49c9
Created February 24, 2022 23:18
Track a single, fetch-only branch from a git remote into a local branch with a different name.
# .git/config
[remote "<remote_name>"]
url = <remote_url>
fetch = <remote_branch_name>:<local_branch_name>
pushurl = no-push
tagopt = --no-tags
[branch "<local_branch_name>"]
remote = <remote_name>
merge = <remote_branch_name>
@AlexRogalskiy
AlexRogalskiy / ng.sh
Created February 24, 2022 23:18
init-like nailgun server runner
#!/bin/sh -e
DESCRIPTION="JRuby Nailgun Server"
ARGS="--ng-server"
# ARGS="$ARGS -Xcompat.version=1.8"
ARGS="$ARGS -Xcompat.version=1.9"
ARGS="$ARGS -Xmn512m -Xms2048m -Xmx2048m" # heap and stack
ARGS="$ARGS -J-Djruby.thread.pooling=true" # Enable thread pooling
ARGS="$ARGS -J-Djruby.objectspace.enabled=false" # Disable ObjectSpace
#!/bin/sh
find ~/.rvm -type d -print0 | xargs -0L1 chmod 0755
find ~/.rvm -type f -print0 | xargs -0L1 chmod 0644
find ~/.rvm -type f -print0 | xargs -0L1 file | grep ' exec' | cut -d: -f1 | tee /dev/stderr | xargs -L1 chmod 0755