Skip to content

Instantly share code, notes, and snippets.

View harshavardhana's full-sized avatar
🌚
I may be slow to respond.

Harshavardhana harshavardhana

🌚
I may be slow to respond.
View GitHub Profile
@harshavardhana
harshavardhana / rebalance_large_files.sh
Last active August 29, 2015 14:00
rebalance_large_files
#!/bin/bash
list_large_files_checksum ()
{
local DIR=$1;
large_files=""
large_directories=""
# Get top ten culprit files
for i in $(du --exclude=".glusterfs" -akx $DIR | sort -nr | head -10 | awk {'print $2'}); do
if [ -f $i ]; then
@harshavardhana
harshavardhana / json_verify.pl
Created May 4, 2014 01:32
Json parse validate
#!/usr/bin/env perl
# Borrowed from - http://search.cpan.org/~mlehmann/JSON-XS-3.01/bin/json_xs
# Modified for internal use in GlusterFS
use strict;
use Encode;
use JSON::XS;
my $opt_from = "json";
my $opt_to = "null";

Freetalk

Freetalk is command line

  • Its goodness
  • Its richness
  • Its flexibility
  • Its power
@harshavardhana
harshavardhana / is_node_reachable.sh
Created June 9, 2014 21:02
Use bash socket to check for host/port connection
#!/bin/bash
function ping_host ()
{
{
exec 4<>/dev/tcp/$1/$2
if [ $? -ne '0' ]; then
echo "Port not reachable"
return 1;
else
@harshavardhana
harshavardhana / trail_recursive_fact.scala
Created July 14, 2014 06:55
Tail recursive (factorial) - scala
def factorial (a: Int, b: Int): Int = if (a == 1) b else if (a == 0) 1 else factorial (a - 1, a * b)
@harshavardhana
harshavardhana / pidof.py
Created August 19, 2014 21:29
Write pidof equivalent using psutil - specifically for non Linux distributions and for GlusterFS
#!/usr/bin/env python
import psutil
import sys
def pmap_find(p, name):
for m in p.memory_maps(grouped=True):
if m.path.endswith("%s.so" % name):
return True
continue
return False
@harshavardhana
harshavardhana / find-inum.stp
Created August 21, 2014 05:54
Find-inum.stp
# cat find_same_inode.stap
#!/usr/bin/stap -g
# Copyright (c) 2014 Brad Hubbard <bhubbard@redhat.com>
%{
#include <linux/file.h>
%}
function find_same_inode:string (path:string) %{
struct nameidata *nd;
@harshavardhana
harshavardhana / vid_face_eye_detection.py
Last active August 29, 2015 14:06
Video capture with Facedetection and Eyes (slow version)
import cv2
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
package main
import (
"flag"
"fmt"
"io/ioutil"
)
const (
SPLIT_NFILES = 4
#!/usr/bin/stap
#
global write_errors, write_success
function handlewrite (pp, ret) {
if (ret < 0)
{
printf("%s %s returned %d", tz_ctime(gettimeofday_s()), pp, ret)
write_errors[pp]++
}