Skip to content

Instantly share code, notes, and snippets.

View ajpen's full-sized avatar

Anfernee Jervis ajpen

View GitHub Profile
/*---------------------------------------------------------
* Program: shuffle.cpp
* Usage: ./shuffle
*---------------------------------------------------------
* Description: Prints a random permutation of the string
* "helloworld" alongside the source string
*_________________________________________________________
*/
/* INCLUDES */
/*---------------------------------------------------------
* Program: recshuffle.cpp
* Usage: ./recshuffle
*---------------------------------------------------------
* Description: Prints a random permutation of the string
* "helloworld" alongside the source string. This program
* uses a recursive approach instead of an iterative one
*_________________________________________________________
*/
// extract query from request-target
const char* temp = qextract(line);
int len = strlen(temp);
char query[len+1];
// make a usable copy of query
strncpy(query, temp,len+1);
@ajpen
ajpen / Server functions.c
Created June 2, 2015 12:16
extracts query, absolute path and address line
const char* qextract(char* line) {
//get target line with query in it
const char* target = textract(line, 0);
int len = strlen(target);
char mtarget[len+1];
// make a more mallible copy
memcpy(mtarget, target,len);
@ajpen
ajpen / fcopy.c
Last active August 29, 2015 14:21
File copying program
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]){
char buffer; //number of bits copied at once
FILE* source = fopen(argv[1],"r");
FILE* dest = fopen(argv[2],"w");
@ajpen
ajpen / automate.c
Created August 26, 2014 03:14
Automates installation of removed packages from a copy of the apt-get log
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[]){
//buffer array
char buffer[120];
//array for the package name