Skip to content

Instantly share code, notes, and snippets.

@arafatkamaal
arafatkamaal / Grammar question
Created March 14, 2013 09:07
Question regarding Perl 6 Grammars
A question regarding Perl 6 Grammars.
I know that Jonathan has created something called as Grammar::Tracer[He has a talk on this: http://www.jnthn.net/papers/2011-yapceu-grammars.pdf], which basically does [as he mentions in the talk]
a. Gives us a trace of all the various rules that our grammar calls as it tries to match.
b. Indicates whether the rule matched or not
c. When it matches, includes the string that was matched.
Now as far as I understand, Perl 6 programs are parsed by a grammar written in Perl 6. In other words, the Perl 6 program is the input data to the Perl 6 grammar.
@arafatkamaal
arafatkamaal / repl demonstration
Created April 25, 2013 03:44
A super crude REPL for perl
$ cat repl.pl
use strict;
use warnings;
while(<STDIN>)
{
@arafatkamaal
arafatkamaal / ListFiles.c
Created May 20, 2013 06:18
List all files in a directory
#include<dirent.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#define ERROR_OPENING_DIRECTORY -1
#define SUCCESS_OPENING_DIRECTORY 1
@arafatkamaal
arafatkamaal / ListDelete.c
Created May 20, 2013 07:07
List files and deleted a file
#include<dirent.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#define ERROR_OPENING_DIRECTORY -1
#define SUCCESS_OPENING_DIRECTORY 1
@arafatkamaal
arafatkamaal / NotesFromTheUnderground.txt
Created May 23, 2013 10:05
Notes from the underground
Project Gutenberg's Notes from the Underground, by Feodor Dostoevsky
This eBook is for the use of anyone anywhere at no cost and with
almost no restrictions whatsoever. You may copy it, give it away or
re-use it under the terms of the Project Gutenberg License included
with this eBook or online at www.gutenberg.net
Title: Notes from the Underground
@arafatkamaal
arafatkamaal / character_pointers_and_copy.c
Created August 23, 2013 09:56
Copying and printing character arrays
#include<stdio.h>
#include<string.h>
#define FIRST "hello world"
#define SECOND "bye"
int main()
{
@arafatkamaal
arafatkamaal / struct2chararray.c
Created September 5, 2013 05:39
How to create a character array from a struct, and vice a versa
#include <stdio.h>
#include <string.h>
typedef struct teststructure {
int valid;
char key[10];
char value[10];
}test;
@arafatkamaal
arafatkamaal / pixel.pl
Created September 27, 2013 11:24
Display a pixel on 10x10 grid
use strict;
use warnings;
use Data::Dumper;
my $gridx = 100;
my $gridy = 100;
my $radius = 10;
my $angle = 14;
my $y_axis_intercept =
@arafatkamaal
arafatkamaal / links.txt
Created October 18, 2013 05:48
links for sqlite C drivers
@arafatkamaal
arafatkamaal / FunctionPointer.c
Created October 18, 2013 08:45
Function Pointers in C
#include <stdio.h>
int CallBackFunction(int i){
printf("This is the call back function %d\n", i);
}
int Operations(int (*func)(int)){