This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a program that shows that when the disposition of a pending signal is | |
// changed to be SIG_IGN , the program never sees (catches) the signal. | |
#include <signal.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
void printSigset(FILE *of, const char *prefix, const sigset_t *sigset) | |
{ | |
int sig, cnt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void quicksort(int *arr, int low, int high) | |
{ | |
int pivot, i, j, temp; | |
if(low < high) { | |
pivot = low; // select a pivot element | |
i = low; | |
j = high; | |
while(i < j) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <errno.h> | |
int mydup2(int oldfd, int newfd) { | |
int fd = fcntl(oldfd, F_GETFL); | |
if (fd == -1) { | |
errno = EBADF; | |
return -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible " required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:14.04 | |
MAINTAINER Joseph <[email protected]> | |
COPY sources.list /etc/apt/ | |
RUN apt-get update | |
RUN apt-get install -y vim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
extern char **environ; | |
int main(int argc, char const *argv[]) { | |
char **ptr; | |
for (ptr = environ; *ptr != NULL; ptr++) { | |
puts(*ptr); | |
} | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// implements dup and dup2 using fcntl. | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <assert.h> | |
#include <errno.h> | |
int mydup(int oldfd); | |
int mydup2(int oldfd, int newfd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy a file. | |
// Removed all error hanlders for simplicity. | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#ifndef BUF_SIZE | |
#define BUF_SIZE 4096 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Removed all error hanlder for simplicity | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
int main(int argc, char const *argv[]) { | |
int flags = O_RDWR; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
which jq &> /dev/null | |
if [[ $? -ne 0 ]] | |
then | |
echo "Please install jq first, see https://stedolan.github.io/jq/" | |
exit 1 | |
fi | |
name=$(curl -s https://randomuser.me/api/) |