This file contains hidden or 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 <cmath> | |
#include <vector> | |
bool is_prime(const uint32_t n) | |
{ | |
if ((n & 1) == 0 && n != 2) | |
return false; | |
for (uint32_t i = 3; i < std::sqrt(n) + 1; i += 2) | |
if (n % i == 0) | |
return false; |
This file contains hidden or 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 random | |
if __name__ == '__main__': | |
nums = [str(random.randint(0, 100000)) for _ in range(100)] | |
toFind = random.choice(nums) | |
ans = open('ans.txt', 'w+') | |
ans.write(str(nums.index(toFind)) + '\n') | |
ans.close() | |
print(toFind + ' ' + ' '.join(nums)) |
This file contains hidden or 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
python2 -c "print(`git ls-files | xargs wc -l | grep '\d total' | egrep -o -e '\d+'` - `wc -l LICENSE | egrep -oe '\d+'` - `wc -l .gitignore | egrep -oe '\d+'`)" |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>Socket.IO chat</title> | |
<style> | |
* { margin: 0; padding: 0; box-sizing: border-box; } | |
body { font: 13px Helvetica, Arial; } | |
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; } | |
form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; } | |
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; } |
This file contains hidden or 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
def newton(x0, f, f_, n = 1, r=7): | |
for i in range(n): | |
xi = x0 - (f(x0) / f_(x0)) | |
print(f'x{i+1} =', round(xi, r)) | |
x0 = xi | |
""" | |
Works for arbitrarily precise floating points. | |
Usage - calculating √169 (13). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 python3 | |
""" | |
About - | |
======= | |
Generates a randomly upper/lowercased | |
text from a given input. For example - | |
Input : Hello World | |
Output : hEllO wORld | |
Input : Spam and Eggs |
This file contains hidden or 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 pathlib | |
def get_file_name(path): | |
return path.split('/')[-1] | |
def get_file_name_efficient(path): | |
return path[path.rfind('/')+1:] | |
path = '/home/name/file.txt' |
This file contains hidden or 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
source `find /home/$USER -maxdepth 2 -type d -name '.*' 2>/dev/null | grep virtualenv | head -1`/${PWD##*/}/bin/activate |
This file contains hidden or 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 python3 | |
import os | |
import sys | |
NAME = 'rme' | |
USAGE = 'usage: {} [FILE]...'.format(NAME) | |
args = sys.argv # simply because I don't like 'argument vector' | |
if len(args) == 1: |