Skip to content

Instantly share code, notes, and snippets.

View skihero's full-sized avatar

Kish skihero

  • Amazon Mechanical Turk
  • Ooty
View GitHub Profile
@skihero
skihero / X21.c
Last active August 29, 2015 13:56
From the textbook, a simple virus
/* The X21 virus sample */
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
DIR *dirp; /* directory search structure */
struct dirent *dp; /* directory entry record */
struct stat st; /* file status record */
@skihero
skihero / gist:7bd9f68d8c6ef74d14bd
Created June 5, 2014 17:42
pip from within python
import pip
packages = ["StringIO"]
pip.main(["install", "--upgrade"] + packages )
import codecs
import os
import re
import sys
from setuptools import setup, find_packages
from setuptools.command.test import test as TestCommand
here = os.path.abspath(os.path.dirname(__file__))
# Set up PATH depending on whether we're root or a normal user.
# There's no real reason to exclude sbin paths from the normal user,
# but it can make tab-completion easier when they aren't in the
# user's PATH to pollute the executable namespace.
#
# It is intentional in the following line to use || instead of -o.
# This way the evaluation can be short-circuited and calling whoami is
# avoided.
if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}"
@skihero
skihero / gist:a81890b0cdac13e2a634
Created July 6, 2014 13:05
iterate *.sh files
for sh in /etc/profile.d/*.sh ; do
[ -r "$sh" ] && . "$sh"
done
unset sh
@skihero
skihero / gist:9928ebfa884892706404
Created July 9, 2014 10:53
code folding for java
autocmd FileType java :set fmr=/**,*/ fdm=marker fdc=1
@skihero
skihero / gist:4f4c3e4e85a3bf986e51
Created July 19, 2014 19:55
sort based on the size (check KEY_DEF ranges in man)
skihero@tender /usr/lib64/chromium-browser $ ls -ltr|sort -k 5.1n
total 103740
-rwxr-xr-x 1 root root 1201 Mar 22 02:35 chromium-launcher.sh
drwxr-xr-x 2 root root 4096 Jul 5 23:23 locales
drwxr-xr-x 4 root root 4096 Jul 5 23:23 resources
-rw-r--r-- 1 root root 5662 Mar 22 02:35 chrome.pak
-rws--x--x 1 root root 18456 Mar 22 02:36 chrome-sandbox
-rw-r--r-- 1 root root 148506 Mar 22 02:35 content_resources.pak
-rw-r--r-- 1 root root 970106 Mar 22 02:35 chrome_100_percent.pak
-rwxr-xr-x 1 root root 2424312 Mar 22 02:36 libffmpegsumo.so
@skihero
skihero / seq_imp
Created September 10, 2014 06:34
simple seq imp stolen
#!/bin/bash
#set -x
seq () {
if [ -z "$3" ]; then
incr=1
j=$2
else
incr=$2
@skihero
skihero / collectd_-n_types
Created September 12, 2014 10:11
collectd_-n_types
.
|-- lib
| `-- collectd
| `-- ${prefix}
| `-- var
| `-- lib
| `-- collectd
| `-- csv
| |-- cpu-0
| | |-- cpu-idle-2014-09-12
@skihero
skihero / create_rrd_db
Created September 29, 2014 06:04
create_rrd_database snippet
sub create_rrd_database {
my $self = shift;
my ($RRDdatabase_path, $metric_id, $begin, $interval, $metric_name, $my_len_storage_rrd, $data_source_type) = @_;
my $lsource_type;
if (defined($data_source_type) && defined($rrd_dst[$data_source_type])) {
$lsource_type = $rrd_dst[$data_source_type];
} else {
$lsource_type = $rrd_dst[0];