Skip to content

Instantly share code, notes, and snippets.

@ajithbh
ajithbh / app.R
Last active November 14, 2017 09:07
Plot dmeminfo trace using Shiny
# Plot the meminfo graph
library(shiny)
options(shiny.maxRequestSize=30*1024^2)
# Define UI
ui <- fluidPage(
# Application title
titlePanel("Plot meminfo Time Series Data"),
@ajithbh
ajithbh / dmeminfo
Last active November 14, 2017 07:29
Dump /proc/meminfo in csv format
#!/bin/bash
__VER="1.0"
INTERVAL=1
usage () {
echo "Usage : $0 [options] [--]
Options:
-h|help Display this message
@ajithbh
ajithbh / kdump.txt
Created June 16, 2017 07:54
Linux Kernel Notes
================================================================
Documentation for Kdump - The kexec-based Crash Dumping Solution
================================================================
This document includes overview, setup and installation, and analysis
information.
Overview
========
@ajithbh
ajithbh / fbtest.c
Last active August 29, 2015 14:06 — forked from rafalrusin/fbtest.c
Framebuffer Test
#include <linux/fb.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <sys/mman.h>
@ajithbh
ajithbh / rgb565_uyv_conv.c
Created June 11, 2014 14:48
RGB565 to UYV conversion table
static unsigned int uyv_table[0x10000];
void generate_rgb565_to_uyv_conv_table(void)
{
int y, u, v;
unsigned char r, g, b;
unsigned int color = 0;
for (color = 0; color < 0x10000; color++) {
r = ((color & 0xF800) >> 8) + ((color >> 13) & 0x07);
@ajithbh
ajithbh / xsi_sem_lock.c
Last active August 29, 2015 14:02
XSI semaphore locking
void semaphore_lock(int sem_id)
{
int res = 0
struct sembuf sops;
sops.sem_num = 0;
sops.sem_flg = SEM_UNDO;
sops.sem_op = -1;
do {
res = semop(sem_id, &sops, 1);
} while (res == -1 && errno == EINTR);
@ajithbh
ajithbh / check_network_connection.c
Last active May 17, 2016 06:17
Network link detection in Linux
#include <linux/mii.h>
#include <linux/sockios.h>
int check_iface_connected(int *psockfd)
{
struct ifreq ifr;
if (*psockfd == -1) {
*psockfd = socket(AF_INET, SOCK_DGRAM, 0);
}
@ajithbh
ajithbh / string_slice.sh
Created June 7, 2014 09:16
Bash string slice
string_slice()
{
[ -z $2 ] && echo "Usage: string_slice \"string\" start [end]" && return
string=$1
local len="${#string}"
local start="$2"
local end="$3"
:${end:=0}
@ajithbh
ajithbh / get_mac_addr.c
Created June 1, 2014 13:10
Get MAC Address
int get_mac_addr(char *mac_addr)
{
int sockfd;
struct ifreq ifr;
if ((sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)) >= 0) {
strncpy(ifr.ifr_name, "eth0", IFNAMESIZE);
ifr.ifr_addr.sa_family = AF_INET;
if (ioctl(sockfd, SIOGIFHWADDR, (char*) &ifr) == 0) {
sprintf(mac_addr, "%02X:%02X:%02X:%02X:%02X:%02X",
@ajithbh
ajithbh / recursive_load_dir.c
Created June 1, 2014 12:57
Recursive load files in directory
#include <dirent.h>
int LoadFilesFromDir(char *pDirectory)
{
struct dirent *pDirEnt;
DIR *pDir = opendir(pDirectory);
if (pDir != NULL) {
while ((pDirEnt = readdir(pDir))) {
char *file = NULL;
char Buffer[512];