/*So obviously the FILEPATH macro here would need to be changed for implementation, but here is a program I wrote this week that works with
a dictionary to test if a user's input is in the given dictionary or
not
*/
//Help Users Spell Correctly
//Hailey Hanson
//February 9th, 2015
//Systems Programming CS 360
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
#include<fcntl.h>
#include<errno.h>
#include <unistd.h>
#define RECORD_SIZE 16
#define FILEPATH "/home/hailey/Documents/Code/WSU-V/SystemsProg/SystemsProg/lib/webster"
char*word;
int fd;
char*buffer;
char* plainWord(char*original);
int ok(int fd, char*word);
int main(int argc, char**argv){
if(argc!=2){
fprintf(stderr, "single word argument required\n");
exit(1);
}
word = argv[1];
fd = open(FILEPATH, O_RDONLY, 0);
if (fd<0){
fprintf(stderr, "couldn't open file %s : %s\n", FILEPATH, strerror(errno));
exit(2);
}
if (ok(fd, word)) printf("yes, %s was found\n",word );
else printf("no, %s was not found\n",word);
close(fd);
char* plainWord(char*original){
int i=0;
char*dest;
dest = calloc(strlen(original), sizeof(char));
while(i<RECORD_SIZE){
if(isalpha(original[i])){
dest[i] = original[i];
}
i++;
}
dest[RECORD_SIZE] = '\0'; //this has to do with the specific dictionary I was using
return strdup(dest);//must compile with gnu99 for strdup to work correctly
}
int ok (int fd, char*word){
char* want = word;//from user
char*have; //from webster
int bot = 0;
int fileSize = lseek(fd, 0, SEEK_END);
int top = fileSize/RECORD_SIZE;
buffer = calloc(RECORD_SIZE, sizeof(char));
while(bot<top){
int mid = (bot+top)/2;
lseek(fd, mid*RECORD_SIZE, SEEK_SET);//moves me to middle of file
read(fd, buffer, RECORD_SIZE);//fills buffer with one line
want = plainWord(word);
have = plainWord(buffer);
int compare = strcmp(want, have);
if(compare == 0){
return 1;
}
else if (compare<0){
top = mid;
}
else if (compare>0){
bot = mid+1;
}
}
return 0;
}
Friday, February 13, 2015
Saturday, January 17, 2015
Internet of Things Blog Post
I wrote this blog post for a client who asked for 250+ words on the Internet of Things. He never told me where he posted it... which is annoying since it left me without a cool portfolio piece. Writing is fun for the sake of writing, though, right?
Anyway, here it is:
Anyway, here it is:
While the Internet
of Things (IoT) may sound like slang or an informal description of
cyber-connections, the IoT is actually a formal, complex network of
embedded computing devices. These devices cohabit the existing
Internet infrastructure and are each identifiable under a unique IP
address. The quality that makes the IoT different from the Internet
as we know it is that systems within the IoT often don't require
much, if any, human interaction after their initial implementation.
What can computers
do without the help of humans, though? In fact, while computers are
often thought to have a keyboard and a mouse, the majority of
computers in the world are built into hardware to serve a purpose in
their own environment. These built-in computers, known as embedded
systems, include devices such as heart-rate monitors, anti-lock
braking systems and thermostats. When these systems are wirelessly
linked to other machines, they then become the “things” in the
Internet of Things.
The unique
machine-to-machine (M2M) quality of the IoT is ironically its biggest
downfall though. Since there is less human interaction with M2M
systems, there is more work to be done by machines; Storing massive
quantities of data and effectively managing requests in real-time as
opposed to a normal computer's clock time. Since the IoT is expanding
so rapidly, the main objective of businesses supplying the technology
is to create enough cloud storage space for all of the information to
be processed and stored quickly.
Many businesses are
compensating for the massive overload of data by implementing smaller
data centers for initial processing so that the consumer will not
have to wait for any larger, remote processes. Oftentimes, data can
be stored within a device for instantaneous processes, too. It is
absolutely crucial that businesses find a way to compensate for huge
amounts of data before overloading consumers with faulty embedded
systems.
While many believe
that the IT systems of the past twenty years will not be able to
handle the emergence of the IoT, it is up to the IT industry to come
up with lucrative ways to increase cloud computing, storage and
big-data analysis without losing automation or efficiency.
Subscribe to:
Posts (Atom)