Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kaushalmodi's full-sized avatar

Kaushal Modi kaushalmodi

View GitHub Profile
@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"

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.
/* 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 -O3 -fno-strict-aliasing -I/home/kmodi/stow/pkgs/nim/devel/lib -o /home/kmodi/sandbox/nim/noinit/nimcache/noinit_global_local.o /home/kmodi/sandbox/nim/noinit/nimcache/noinit_global_local.c */
#define NIM_NEW_MANGLING_RULES
#define NIM_INTBITS 64
#include "nimbase.h"
# Time-stamp: <2018-05-17 10:38:18 kmodi>
# Generic build script
# It would be simple to just do:
#
# import os, strformat, terminal
#
# Note that ospaths gets imported implicitly in this case.
# But I am still doing the below here so that so that I realize the number of
# procs that I am using, and also where they come from.
#!/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

Keybase proof

I hereby claim:

  • I am kaushalmodi on github.
  • I am kaushalmodi (https://keybase.io/kaushalmodi) on keybase.
  • I have a public key whose fingerprint is B581 7A1B 93A7 68C5 4CD4 BFC5 3D54 2F6D CD3C 8277

To claim this, I am signing this object:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.