Skip to content

Instantly share code, notes, and snippets.

View Swoorup's full-sized avatar
🎲
Focusing

Swoorup Joshi Swoorup

🎲
Focusing
View GitHub Profile
@Swoorup
Swoorup / shell.c
Last active August 29, 2015 14:27
Entry Point
int main()
{
// ignore Ctrl-\ Ctrl-C Ctrl-Z signals
ignore_signal_for_shell();
// set the prompt
set_prompt("swoorup % ");
while (1)
@Swoorup
Swoorup / shell.c
Last active August 29, 2015 14:27
Scan Input, build lexical tokens
// keep getline in a loop in case interruption occurs
int again = 1;
while (again) {
again = 0;
printf("%s", getprompt());
linebuffer = NULL;
len = 0;
ssize_t nread = getline(&linebuffer, &len, stdin);
if (nread <= 0 && errno == EINTR) {
again = 1; // signal interruption, read again
@Swoorup
Swoorup / shell.c
Created August 14, 2015 04:43
Try parsing and executing the syntax tree
// parse the tokens into an abstract syntax tree
if (!lexerbuf.ntoks || parse(&lexerbuf, &exectree) != 0) {
continue;
}
execute_syntax_tree(exectree);
@Swoorup
Swoorup / sapaths.py
Last active August 29, 2015 14:27 — forked from l1am9111/sapaths.py
Python GTA: SA Path Reader
from struct import unpack
from cStringIO import StringIO
class SAPath():
def __init__(self, node):
self.path = StringIO(open(node, "rb").read())
self.header = {}
self.pathnodes = []
self.navinodes = []
self.links = []
@Swoorup
Swoorup / parser.c
Last active September 14, 2015 06:07
Shell Grammer
<command line> ::= <job>
| <job> '&'
| <job> '&' <command line>
| <job> ';'
| <job> ';' <command line>
<job> ::= <command>
| < job > '|' < command >
<command ::= <simple command>
@Swoorup
Swoorup / astree.c
Created September 14, 2015 06:55
ASTreeNode
typedef struct ASTreeNode
{
int type;
char* szData;
struct ASTreeNode* left;
struct ASTreeNode* right;
} ASTreeNode;
@Swoorup
Swoorup / .minttyrc
Created May 30, 2016 16:36
My mintty configuration
Font=Sauce Code Powerline
ForegroundColour=131,148,150
BackgroundColour=0,11,17
CursorColour=220,50,47
Black=7,54,66
BoldBlack=0,43,54
Red=220,50,47
BoldRed=203,75,22
Green=133,153,0
BoldGreen=88,110,117
@Swoorup
Swoorup / .tmp.zshrc
Created May 30, 2016 17:00
My zsh config
alias tree='tree -C'
export EDITOR=vim
export PAGER="less"
export LESS="-R"
eval $( dircolors -b $HOME/.dircolors )
@Swoorup
Swoorup / d-lang.el
Created December 24, 2016 10:15
d-lang helper
;; This file was obtained from
;; http://forum.dlang.org/post/wcqxlaceqljsdsultiie@forum.dlang.org
(defun run-current-project-args (args)
(setq cmdStr (concat "time dub " args))
(setq buffname (format "*%s*" cmdStr))
(save-excursion
(message (concat "Running:" cmdStr))
(if (not (eq nil (get-buffer buffname))) (kill-buffer buffname))
(setq compilation-scroll-output t)
-*- mode: compilation; default-directory: "~/Dropbox/vulkan_experiments/vkapp/" -*-
Compilation started at Sat Dec 31 15:28:03
time dub
Performing "debug" build using dmd for x86_64.
derelict-util 2.0.6: target for configuration "library" is up to date.
derelict-sdl2 2.0.2: target for configuration "library" is up to date.
xcb-d 2.1.0+1.11.1: target for configuration "library" is up to date.
xlib-d 0.1.1: target for configuration "library" is up to date.
vulkantriangled ~master: building configuration "application"...