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

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)

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@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]++
}
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/
# Method behind this madness described: http://forums.macrumors.com/showthread.php?t=1409151&page=4
# See discussion in comments here: https://www.macupdate.com/app/mac/39654/lion-tweaks
# And here: http://forums.macrumors.com/showthread.php?t=1410459