View create_bootable_drive.txt
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
cmd: | |
disk part | |
list disk | |
select disk X | |
clean | |
create partition primary | |
select partition 1 | |
format fs=ntfs quick | |
active | |
exit |
View is_prime.js
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
function isPrime(n) { | |
if (n <= 1) | |
return false; | |
var pattern = new RegExp('^(.{2,' + Math.ceil(Math.sqrt(n)) + '})\\1+$'); | |
return !pattern.test('.'.repeat(n)); | |
} | |
var n = ~~process.argv[2]; | |
console.log(`${n} ${isPrime(n) ? 'is' : 'is not'} prime`); |
View aur.py
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 datetime import datetime | |
import shutil | |
import textwrap | |
import requests | |
API_URL = 'https://aur.archlinux.org/rpc/?v=5' | |
def format_text(text, color=None, bold=False): |
View subreddit_complete.py
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
import sys | |
import uuid | |
import re | |
import json | |
import urllib.request | |
import urllib.parse | |
subreddit_rx = re.compile(r'\A[A-Za-z0-9][A-Za-z0-9_]{,20}\Z') | |
subreddit_url = 'https://www.reddit.com/api/search_reddit_names.json' |
View to_base.cc
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> | |
template <typename T, typename U = typename std::make_unsigned<T>::type> | |
std::string to_base(T _n, int base) { | |
static const char *base_vals = "0123456789" | |
"abcdefghijklmnopqrstuvwxyz" | |
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
static char buf[8 * sizeof (U) + 1]; | |
U n = _n; |
View drive_ya_nuts.cc
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
// Solution to Drive Ya Nuts | |
// http://www.hasbro.com/common/instruct/DriveYaNuts.PDF | |
// | |
// Program output: | |
// | |
// 1 3 5 4 2 6 | |
// 1 5 3 2 6 4 | |
// 3 4 5 6 1 2 | |
// 5 2 4 6 1 3 | |
// 4 3 2 1 6 5 |
View prime.c
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 <gmp.h> | |
unsigned urandom(void) { | |
unsigned r; | |
FILE *fp = fopen("/dev/urandom", "r"); | |
fread((void *)&r, sizeof r, 1, fp); | |
fclose(fp); | |
return r; | |
} |
View quicksort.cc
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 <random> | |
#include <vector> | |
namespace ArrayUtils { | |
std::vector<uint32_t> random_array(uint32_t low, uint32_t high, size_t count) { | |
std::vector<uint32_t> result(count); | |
std::mt19937 eng(std::random_device{}()); | |
std::uniform_int_distribution<uint32_t> gen(low, high); | |
for (size_t i = 0; i < count; i++) |
View pi.cc
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 <cmath> | |
#include <omp.h> | |
#include <gmp.h> | |
#define LOG2_10 3.321928094887362 | |
std::string pi(size_t places) { | |
size_t scaled = ceil(static_cast<double>(places) / 14); | |
mpf_set_default_prec(LOG2_10 * places); |
View mt.h
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
#ifndef MT_H | |
#define MT_H | |
#define MT_GEN(TYPE, NAME, W, N, M, A, U, D, S, B, T, C, F, L, LM, UM) \ | |
typedef struct { \ | |
TYPE MT[N]; \ | |
TYPE index; \ | |
} NAME; \ | |
void NAME##_seed(NAME *mt, TYPE seed) { \ | |
mt->index = (N); \ |
NewerOlder