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 <iostream> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector<int> v; |
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> | |
#include <string.h> | |
void giveControl(const char * username) | |
{ | |
printf("Granted access\n"); | |
} | |
void authUser(char * username) //, char * password) | |
{ |
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 <string.h> | |
#include <stdio.h> | |
void printCanary(char * first, char * second) | |
{ | |
printf("Canaries[%c%c] [%c%c]\n", first[0], first[1], second[0], second[1]); | |
memset(first, 'X', 2 * sizeof(*first)); | |
memset(first, 'Z', 2 * sizeof(*second)); | |
} |
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 <string.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#include <signal.h> | |
char chutz = 43; |
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 python | |
import sys | |
N,K = (int(val) for val in sys.stdin.readline().split()) | |
setN = [int(val) for val in sys.stdin.read().split()] | |
# Should we check len(setN) <= N? | |
# We should sort such that we can optimise | |
setN.sort() |
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 python | |
def baseConverter(num, base = 2): | |
vals = [] | |
digits = "0123456789abcdef" | |
while num > 0: | |
remainder = num % 2 | |
vals.append(remainder) | |
num = num // base |
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> | |
#include "bitshift.h" | |
int main() | |
{ | |
unsigned char ascii_char = 'A'; /* char = 8 bits only */ | |
int test_nbr = 10; | |
printf("Starting character = %08X\n", ascii_char); | |
/* The 5th bit position determines if the character is | |
uppercase or lowercase. |
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 <stdarg.h> | |
double average(int count, ...) | |
{ | |
va_list ap; | |
int j; | |
double tot = 0; | |
va_start(ap, count); /* Requires the last fixed parameter (to get the address) */ | |
for(j = 0; j < count; j++) | |
tot += va_arg(ap, double); /* Increments ap to the next argument. */ |
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> | |
#define ARRAY_SIZE(x) \ | |
((sizeof(x) / sizeof(x[0]))) | |
void count_and_process_items(unsigned int (*array)[10]) | |
{ | |
for (int i = 0; i < ARRAY_SIZE(*array); ++i) { | |
printf("Item %d = %d\n", i, (*array)[i]); | |
printf("\twhich should also be %d\n", (i)[*array]); |
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 python | |
""" | |
A pure Python "ping" implementation, based on a rewrite by Johannes Meyer, | |
of a script originally by Matthew Dixon Cowles. Which in turn was derived | |
from "ping.c", distributed in Linux's netkit. The version this was forked | |
out of can be found here: https://gist.github.com/pklaus/856268 | |
The versions this script derived from are licensed under GPL v2, this makes | |
mandatory that this is licensed under the same terms as well. If it were up |