Skip to content

Instantly share code, notes, and snippets.

View izmailoff's full-sized avatar
🎯
Focusing

Aleksey Izmailov izmailoff

🎯
Focusing
View GitHub Profile
@izmailoff
izmailoff / scmhelper.sh
Last active December 13, 2015 17:28
Universal SCM (Source Control Management) commands. If you always forget which SCM you are using (SVN, GIT, etc) this script is supposed to help you to abstract their common commands like: commit, update, diff. Include it in your bashrc or bash_profile
#!/bin/bash
# Run this file to register these functions in your shell.
# You can include it in your .bashrc or .bash_profile like this:
# . ./scmhelper.sh
###############################################################################
# Helper function that figures out which SCM
# you are using.
function getScmType()
@izmailoff
izmailoff / alphabet.sh
Created March 23, 2013 13:41
Alphabet unix way :)
#!/bin/bash
for i in {a..z}; do banner " $i"; festival -b "(SayText \"$i\")" 1>/dev/null; done
@izmailoff
izmailoff / domainChecker.sh
Last active December 16, 2015 10:59
Check available domain names with this convenience tool.
#!/bin/bash
# takes one argument as domain name and checks if this domain is registered.
#
# usage:
# sss google.com
#
function sss()
{
@izmailoff
izmailoff / swapnuke.sh
Last active December 16, 2015 22:19
Flashes swap memory by disabling and then enabling all swap devices. It first performs a check if enough memory is available on the system. Then it syncs all dirty buffers and disables/enables swap. Motivation is to be able to quickly force swap data into memory without waiting for OS to do it. Probably, you should not need this on a healthy ser…
#!/bin/bash
function printDebug()
{
if [ ! -z "$debug" ]; then
echo "$1"
fi
}
debug="$1"
@izmailoff
izmailoff / services.sh
Created September 5, 2013 14:26
Quickly check web server services statuses: mongodb, tomcat, and apache/httpd.
#!/bin/bash
echo '*******************************************************************'
service httpd status; httpdStatus=$(echo $?)
service tomcat6 status; tomcatStatus=$(echo $?)
service mongod status; mongoStatus=$(echo $?)
echo '*******************************************************************'
if [[ $httpdStatus == 3 && $tomcatStatus == 3 && $mongoStatus == 3 ]]; then
echo "ALL SERVICES ARE STOPPED!"
@izmailoff
izmailoff / sbt
Created September 5, 2013 16:12
Sbt runner - a simple one. See one supplied by foursquare/rogue for something more fancy. Requires sbt-launch.jar - a standard SBT launcher. This script is not SBT jar version dependent.
java -Xms1024M -Xmx4096M -Xss200M -XX:MaxPermSize=4096m -XX:+CMSClassUnloadingEnabled -jar `dirname $0`/sbt-launch.jar "$@"
@izmailoff
izmailoff / mongo_conditional_insert.txt
Last active December 22, 2015 21:09
a way to upsert with condition
// You just need to ignore dup key errors :)
// in Mongo shell: ...
>
> var lastUpdateTime = ISODate("2013-09-10")
> var newUpdateTime = ISODate("2013-09-12")
>
> lastUpdateTime
ISODate("2013-09-10T00:00:00Z")
#!/bin/bash
# Run with a single argument - number of minutes remaining.
# For example for 1 min countdown use:
# ./go_home_countdown.sh 1
set -e
remaining=$(( $1 * 60 ))
@izmailoff
izmailoff / os_stats.sh
Last active June 12, 2020 17:07
collects OS stats on Linux
#!/bin/bash
# Collects system performance statistics such as CPU, memory, and disk
# usage as well as top processes ran by users.
#
# All size values are in KiB (memory, disk, etc).
# Takes these command line arguments:
# $1 - cpuThreshold in % of total across all CPUs. Default is provided in no-args option.
case class Transformer[From, To](input: List[From], f: From => To) {
import scala.util.{Try, Success, Failure}
lazy val transformedWithIndex: List[(Try[To], Int)] =
input map { l => Try ( f(l) ) } zipWithIndex
def failuresWithIndex =
transformedWithIndex.filter { case (v, i) => v.isFailure }
lazy val failuresExist: Boolean =