Skip to content

Instantly share code, notes, and snippets.

View olegch's full-sized avatar

Oleg Chunikhin olegch

View GitHub Profile
@olegch
olegch / README.md
Created January 24, 2012 16:46
These scripts are used for simple management of hostnames for several VirtualBox VMs comprising a test or sandbox environment on your local machine.

These scripts are used for simple management of hostnames for several VirtualBox VMs comprising a test or sandbox environment on your local machine.

Architecture:

  1. each VM is configured to use bridged network adapter, so all VMs and the host can see each other

  2. a script is installed in each VM to run on post-ifup, which grabs VM's IP, puts "$IP $desired-hostname $desired-fully-qualified-hostname" into /etc/hosts, changes hostname correspondingly, and puts VM's hostname and fq-hostname into VM's properties

  3. a script is used on the host machine, which loops through running VMs, and updates /etc/hosts on the host machine and on the VMs

@olegch
olegch / scriptsource.sh
Created February 3, 2012 15:20
Full directory name of the script no matter where it is being called from
#!/bin/bash
# This code is originally from http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
# It is a useful one-liner which will give you the full directory name of the script no matter where it is being called from
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Or, to get the dereferenced path (all directory symlinks resolved), do this:
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@olegch
olegch / Git repo refactoring.sh
Last active December 13, 2015 20:58
Commands/sequence useful for git repository refactoring
#!/bin/bash
# Delete everything except some files:
find . -not \( -path "./.git" -o -path "./.git/*" -o -path "./pom.xml" \) -delete
# checkout all branches you want to have:
for i in develop br1 br2 br3; do git branch -t $i origin/$i; done
# automatically find all remote branches:
for i in `git show-ref | awk '/ refs\/remotes\/origin\// { sub(/refs\/remotes\/origin\//,""); print $2 }' | grep -v '^HEAD$'`; do git branch -t $i origin/$i; done
@olegch
olegch / vim show whitespaces
Last active December 13, 2015 22:08
vim show whitespaces
:set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
:set list
@olegch
olegch / find in files and replace.sh
Last active December 24, 2021 22:02
Find files skipping some directories and make global replacement
find . -path ./.git -prune -o -path */target -prune -o -path ./binary -prune -o -type f -print | xargs sed -i 's/1\.6\.0-SNAPSHOT/1.7.0-SNAPSHOT/g'
@olegch
olegch / subscript.groovy
Last active August 29, 2015 13:56
running a groovy subscript from a groovy script
// parse script by file name dynamically
new GroovyShell(binding).parse(new File("${context.serviceDirectory}/test_script.groovy")).run()
// run script statically linking
new test_script(binding).run()
@olegch
olegch / 0_reuse_code.js
Created April 6, 2016 15:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@olegch
olegch / oc-cut.py
Created May 6, 2016 23:53
Batch split of multiple image files in half in GIMP
#!/usr/bin/env python
import math
from gimpfu import *
import os
import re
import sys
sys.stderr = open('C:/Temp/python-fu-output.txt','a')
@olegch
olegch / example-template
Last active June 13, 2016 20:35
Simple template engine with bash
Hello: X=$X
Hello: X=$X'''
Hello: X="$X"
Hello: X=$X "kjh
kjd"
$(date)

Keybase proof

I hereby claim:

  • I am olegch on github.
  • I am olegch (https://keybase.io/olegch) on keybase.
  • I have a public key whose fingerprint is 141E A6E1 E841 95DC B6A5 48E2 F41A 7B57 AEA3 18AB

To claim this, I am signing this object: