Skip to content

Instantly share code, notes, and snippets.

View mechanicker's full-sized avatar

Dhruva Krishnamurthy mechanicker

View GitHub Profile
@mechanicker
mechanicker / dky.el
Created December 2, 2010 09:57
emacs customization helper file
;; -*-mode:Emacs-Lisp;buffer-cleanup-p:t;buffer-read-only:t-*-
;; Time-stamp: <2010-09-14 12:13:40 dky>
;;-----------------------------------------------------------------------------
;; Author : Dhruva Krishnamurthy
;; Date : 7th Dec 2000
;; Note : I thank a lot of other people whose code I have used
;;-----------------------------------------------------------------------------
;; Some variable declarations
(defvar buffer-cleanup-p nil
@mechanicker
mechanicker / emacsserver.el
Created December 2, 2010 10:01
Emacs client implementation in lisp
;; -*-mode:Emacs-Lisp;buffer-cleanup-p:t-*-
;; Time-stamp: <2010-09-15 08:54:34 dky>
;;-----------------------------------------------------------------------------
;; File : emacsserver.el
;; Auth : Dhruva Krishnamurthy ([email protected])
;; Status : Development (flaky)
;; Usage :
;; o As server:
;; (require 'emacsserver)
;; (emacsserver-start "magic")
@mechanicker
mechanicker / cvsget.pl
Created December 2, 2010 10:03
CVS through proxy: The dirty way
# -*-perl-*-
# Time-stamp: <2003-08-13 19:32:10 dhruva>
#------------------------------------------------------------------------------
# cvsget.pl --- Download CVS repository (like CVSGrab)
# Copyright (C) 2003 Dhruva Krishnamurthy
# Author: Dhruva Krishnamurthy
# Maintainer: [email protected]
# Keywords: cvs, proxy, firewall, grab
# Created: 01st August 2003
# Latest: http://schemer.fateback.com/pub/scripts/cvsget.pl
@mechanicker
mechanicker / p4hg.pl
Created December 2, 2010 10:05
Perforce to Mercurial incremental converter
#!/bin/env perl
# -*-mode:cperl;buffer-cleanup-p:t;buffer-read-only:t-*-
# Time-stamp: <2008-09-05 18:48:32 dky>
#------------------------------------------------------------------------------
# Perforce (p4) to mercurial (hg) incremental repository conversion
# Copyright (C) 2008 Dhruva Krishnamurthy <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@mechanicker
mechanicker / strcmp.c
Created July 7, 2013 12:59
Optimizing strong compare
/* Time-stamp: <2013-07-07 10:37:24 dky> */
#include <stdio.h>
#include <string.h>
int stringcompare(const char*, const char*);
int stringcompareopt(const char *, size_t, const char *, size_t);
int stringcompare(const char *s1, const char *s2) {
size_t idx = 0;
@mechanicker
mechanicker / bash.functions
Created July 8, 2013 07:10
Bash shell helper functions to make working in development environment a little easier
#!/bin/env bash
# Important variables
USER=`who am i | cut -d" " -f1`
if [ -z "$USER" ] ; then
USER=`whoami`
fi
WSROOT=${WSROOT:-~/devel}
if [ -f /x/eng/site/site.def ] ; then
SITE=`grep BUILDSITE= /x/eng/site/site.def|cut -d= -f2|tr -d '"'|tr A-Z a-z`
@mechanicker
mechanicker / bst.cpp
Created January 19, 2016 15:41
Basic tree traversal
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
// Definition for binary tree
struct TreeNode {
int val;
TreeNode *left;
@mechanicker
mechanicker / gnulib.patch
Created December 26, 2019 22:53
Fix compilation error gnulib
diff --git a/lib/linkat.c b/lib/linkat.c
index 6a4f1a617..be4cbc415 100644
--- a/lib/linkat.c
+++ b/lib/linkat.c
@@ -331,8 +331,11 @@ rpl_linkat (int fd1, char const *file1, int fd2, char const *file2, int flag)
/* OS X 10.10 has linkat() but it doesn't support
hardlinks to symlinks. Fallback to our emulation
in that case. */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wlogical-op"
@mechanicker
mechanicker / coreutils-cp.patch
Last active December 27, 2019 22:33
Patch GNU coreutils (git://git.sv.gnu.org/coreutils) cp command to use sendfile()
commit 98fd0cba2b839cd2b77d57397998391a81baa55f
Author: Dhruva Krishnamurthy <[email protected]>
Date: Fri Dec 27 11:43:06 2019 -0800
cp: Use sendfile() to copy files to redundant data copy
diff --git a/configure.ac b/configure.ac
index 18c5a99bd..bef490af9 100644
--- a/configure.ac
+++ b/configure.ac
@mechanicker
mechanicker / qemu
Last active August 18, 2022 17:52
Notes from running CentOS 7 in QEMU on Mac
# Install qemu
brew install qemu
# Create disk image for root file system
qemu-img create -f qcow2 centos-7.qcow2 10G
# Run with ISO image mounted as cdrom for installing
qemu-system-x86_64 \
-m 2048 \
-vga virtio \