Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Harshavardhana harshavardhana

💭
I may be slow to respond.
View GitHub Profile
View rebalance_large_files.sh
#!/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
View json_verify.pl
#!/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";
View freetalk.md

Freetalk

Freetalk is command line

  • Its goodness
  • Its richness
  • Its flexibility
  • Its power
@harshavardhana
harshavardhana / is_node_reachable.sh
Created Jun 9, 2014
Use bash socket to check for host/port connection
View is_node_reachable.sh
#!/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 Jul 14, 2014
Tail recursive (factorial) - scala
View trail_recursive_fact.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 Aug 19, 2014
Write pidof equivalent using psutil - specifically for non Linux distributions and for GlusterFS
View pidof.py
#!/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
View 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 Aug 29, 2015
Video capture with Facedetection and Eyes (slow version)
View vid_face_eye_detection.py
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()
View sample_splitting.go
package main
import (
"flag"
"fmt"
"io/ioutil"
)
const (
SPLIT_NFILES = 4
View qemu.stap
#!/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]++
}
You can’t perform that action at this time.