Skip to content

Instantly share code, notes, and snippets.

@mskeving
mskeving / wordcount.c
Last active April 30, 2023 01:58
Replicate wc command in C
#include <stddef.h>
#include <stdio.h>
#include <ctype.h>
int main(int argc, char** argv)
{
FILE *fp;
char buffer[4096];
int total_words = 0;
@mskeving
mskeving / hashtable.c
Last active August 29, 2015 14:18
Implement hash table in C
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
struct node_s {
char *key;
char *value;
struct node_s *next;
};
@mskeving
mskeving / reverse.py
Created April 10, 2015 19:23
Reverse a list in python
# Note, these functions are only for reversing lists in Python.
# In Python, strings are immutable, meaning you can't change their value.
# In other languages, like Ruby, this would be possible.
# If you want to reverse a string, you can use .split(), but that
# returns a list of characters, which means you are no longer doing
# it in place. This gives you O(n) space complexity.
# O(n) space, because the new list could be arbitrarily large
# O(n) time to go through each item in list.
import json
import sys
from collections import defaultdict
import comm
import comm_nonblock
def main():
args = sys.argv[1:]
@mskeving
mskeving / email_data.csv
Last active December 8, 2016 05:35
Emails by Timezone
tz count
0 45
+1 145
+2 147
+3 1
+5.5 76
+5.75 1
+7 1
+9.5 1
+12 1