Skip to content

Instantly share code, notes, and snippets.

View abhinav-upadhyay's full-sized avatar

Abhinav Upadhyay abhinav-upadhyay

View GitHub Profile
@abhinav-upadhyay
abhinav-upadhyay / generated_cases.c.h
Last active August 15, 2023 10:58
The Generated Switch Case for CPython's Bytecode VM
// This file is generated by Tools/cases_generator/generate_cases.py
// from:
// Python/bytecodes.c
// Do not edit!
TARGET(NOP) {
DISPATCH();
}
TARGET(RESUME) {
@abhinav-upadhyay
abhinav-upadhyay / editline.diff
Last active April 20, 2017 18:38
We should append a trailing slash at the end of directory names and a space after filenames when doing multi-column file completion. Pass app_func as an argument to fn_display_match_list for compatibility with readline.c
Index: filecomplete.c
===================================================================
RCS file: /cvsroot/src/lib/libedit/filecomplete.c,v
retrieving revision 1.44
diff -u -p -r1.44 filecomplete.c
--- filecomplete.c 31 Oct 2016 17:46:32 -0000 1.44
+++ filecomplete.c 20 Apr 2017 18:24:57 -0000
@@ -354,10 +354,13 @@ _fn_qsort_string_compare(const void *i1,
* num, so the strings are matches[1] *through* matches[num-1].
*/
Index: namecache.9
===================================================================
RCS file: /cvsroot/src/share/man/man9/namecache.9,v
retrieving revision 1.20
diff -u -r1.20 namecache.9
--- namecache.9 18 Mar 2017 21:21:24 -0000 1.20
+++ namecache.9 19 Apr 2017 11:25:19 -0000
@@ -105,7 +105,7 @@
Each
.Em namecache
@abhinav-upadhyay
abhinav-upadhyay / inotify_windows_directory_notification
Last active April 26, 2017 11:08
Comparision of Directroy monitoring features in inotfiy and Windows
-------------------------------------------
DIRECTORY NOTIFICATION FEATURES IN INOTIFY:
--------------------------------------------
- Can monitor directories
- Only file and file like objects can be monitored, not sub-dirs
- The following struct is returned by doing read(2) on the file descriptor provided by inotify:
struct inotify_event {
int wd; /* Watch descriptor */
@abhinav-upadhyay
abhinav-upadhyay / gist:76c1863f7687214900efb2fed3169606
Created April 11, 2017 11:22
Use Xr to reference timespec(2)
Index: kqueue.2
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/kqueue.2,v
retrieving revision 1.39
diff -u -r1.39 kqueue.2
--- kqueue.2 11 Apr 2017 11:06:39 -0000 1.39
+++ kqueue.2 11 Apr 2017 11:20:31 -0000
@@ -133,7 +133,8 @@
is a
.No non- Ns Dv NULL
@abhinav-upadhyay
abhinav-upadhyay / hist.c
Last active April 11, 2017 12:51
Test program for the history commands of libedit(3)
/*-
* Copyright (c) 2017 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
Index: editline.3
===================================================================
RCS file: /cvsroot/src/lib/libedit/editline.3,v
retrieving revision 1.92
diff -u -p -r1.92 editline.3
--- editline.3 22 May 2016 23:54:20 -0000 1.92
+++ editline.3 10 Apr 2017 14:52:57 -0000
@@ -786,7 +786,7 @@ Return the next element in the history.
It is older than the current one.
.It Dv H_CURR
#include <stdio.h>
#include <string.h>
static int
min(int i, int j, int k)
{
int min = i;
if (min > j)
min = j;
if (min > k)
@abhinav-upadhyay
abhinav-upadhyay / DateTimeDecoder.py
Last active July 4, 2023 13:12
A JSON decoder/encoder implementation for parsing dates as datetime objects in Python
#!/usr/bin/env python
# An example of decoding/encoding datetime values in JSON data in Python.
# Code adapted from: http://broadcast.oreilly.com/2009/05/pymotw-json.html
# Copyright (c) 2023, Abhinav Upadhyay
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@abhinav-upadhyay
abhinav-upadhyay / apropos_cgi.c
Created February 21, 2012 14:09
A CGI frontend for apropos
/*-
* Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.