Skip to content

Instantly share code, notes, and snippets.

View kaushalmodi's full-sized avatar

Kaushal Modi kaushalmodi

View GitHub Profile
@kaushalmodi
kaushalmodi / debugprint.html
Last active July 11, 2023 01:03
Pretty printing Hugo variables for debug
Thanks for stopping by.
This code has been moved to https://github.com/kaushalmodi/hugo-debugprint as a Hugo theme component.
#!/usr/bin/env bash
# Time-stamp: <2017-04-27 09:57:21 kmodi>
#
# Example of using getopt to parse command line options
# http://stackoverflow.com/a/29754866/1219634 Limitation: All the options
# starting with - have to be listed in --options/--longoptions, else getopt will
# error out. So this cannot be used in wrapper scripts for other applications
# where you plan to pass on the non-wrapper-script options to that wrapped
# application.
@kaushalmodi
kaushalmodi / client_protobuf.nim
Last active September 1, 2021 13:46
Nim client/server protobuf
import std/[os, threadpool, strformat, asyncdispatch, asyncnet]
import protocol_protobuf, streams
proc connect(socket: AsyncSocket, serverAddr: string) {.async.} =
echo &"Connecting to {serverAddr}"
await socket.connect(serverAddr, Port(7687))
echo "Connected!"
echo "Chat application started"
#!/usr/bin/env bash
# Time-stamp: <2017-10-23 12:14:47 kmodi>
# Hugo build script.. for hugo version build after switching to Go dep.
# (v0.31-DEV+)
# Usage: ./hugo_mybuild.sh # Installs using origin/master
# ./hugo_mybuild.sh --rev v0.30.2
#${GOPATH}/src/github.com/gohugoio/hugo/README.md

The most important functions and macros provided are:

  1. the format functions to render a single value as a string,
  2. the fmt macro to construct a string containing several formatted values
  3. the writefmt and printfmt family of macros to write a formatted string to a file and stdout, respectively
  4. the interp and $$ string interpolation macros to render expressions embedded in the string itself
@kaushalmodi
kaushalmodi / emacs_module_sample__bug.c
Created June 28, 2018 13:13
Regression caused by vm support for ref types commit
/* Generated by Nim Compiler v0.18.1 */
/* (c) 2018 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Linux, amd64, gcc */
/* Command for C compiler:
gcc -c -w -I/home/kmodi/usr_local/apps/6/emacs/master/bin -std=gnu99 -fPIC -I/home/kmodi/stow/pkgs/nim/bad/lib -o /home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/misc/nim-emacs-module/test/nimcache/emacs_module_sample.o /home/kmodi/stow/pub_dotfiles/emacs/dot-emacs.d/misc/nim-emacs-module/test/nimcache/emacs_module_sample.c */
#define NIM_NEW_MANGLING_RULES
#define NIM_INTBITS 64
#include "nimbase.h"
#!/usr/bin/env bash
# Time-stamp: <2018-06-23 22:16:08 kmodi>
# Usage: ./mybuild.sh # Installs using upstream/devel
# ./mybuild.sh --rev v0.18.0
# ./mybuild.sh --rev upstream/master
set -euo pipefail # http://redsymbol.net/articles/unofficial-bash-strict-mode
IFS=$'\n\t'
/* emacs-module.h - GNU Emacs module API.
Copyright (C) 2015-2018 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs 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 (at
your option) any later version.
#!/usr/bin/env bash
# Time-stamp: <2018-05-11 15:59:07 kmodi>
# Script to stow packages from ${STOW_PKGS_ROOT} to ~/stowed
# Usage: stow_it.sh (That's it; from any directory)
# This script uses the unofficial strict mode as explained in
# http://redsymbol.net/articles/unofficial-bash-strict-mode
# Also checks have been done with www.shellcheck.net to have a level of
#!/usr/bin/env bash
# Time-stamp: <2017-05-18 08:18:01 kmodi>
# Usage: ./mybuild.sh # Installs using origin/devel
# ./mybuild.sh --rev v0.17.0
# ./mybuild.sh --rev origin/master
set -euo pipefail # http://redsymbol.net/articles/unofficial-bash-strict-mode
IFS=$'\n\t'