Skip to content

Instantly share code, notes, and snippets.

View sharpvik's full-sized avatar
🌶️

Viktor Rozenko sharpvik

🌶️
View GitHub Profile
/*
* PREFACE
*/
const log = (...a) => console.log("\t", ...a);
class Yet {
constructor(s) {
this.s = s;
}
@sharpvik
sharpvik / slice.c
Created July 28, 2021 01:59
Simple slice type in C
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct {
void *ptr;
size_t len;
size_t cap;
} slice;
@sharpvik
sharpvik / drink.sh
Last active February 17, 2023 11:56
Remove all Docker images that contain <none> in their descriptions.
docker rmi $(docker images | grep none | awk '{ print $3 }' | xargs)
@sharpvik
sharpvik / hangman.py
Last active August 21, 2020 11:17
Hangman game in Python
"""
Hangman Game
Make sure to have a lengthy words.txt file saved in the same folder.
You can get one here:
https://raw.githubusercontent.com/Tom25/Hangman/master/wordlist.txt
If you compose it yourself, make all words lowercase and each on a separate line
or otherwise separated by whitespace characters (parser relies on that).
@sharpvik
sharpvik / stack.py
Created July 30, 2020 22:57
Python Stack implementation
class Stack:
def __init__(self):
self.mem = []
def __len__(self):
return len(self.mem)
def __str__(self):
return str(self.mem)
@sharpvik
sharpvik / random_sort.py
Created February 1, 2020 18:01
Random sort function implemented in Python3.
from typing import List
from random import randint
def shuffle(arr: List[int]) -> List[int]:
out: List[int] = []
while len(arr) > 0:
idx: int = randint( 0, len(arr) - 1 )
out.append( arr.pop(idx) )
@sharpvik
sharpvik / gol.c
Created January 15, 2020 19:10
The Game of Life written in C
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <Windows.h>
#define CLEAR "cls"
#else
#include <unistd.h>
#define CLEAR "clear"
#endif
@sharpvik
sharpvik / README-Template.md
Created January 6, 2020 12:50 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@sharpvik
sharpvik / trash.py
Last active December 13, 2019 02:10
Python3 library and utility to work with Trash on UNIX-based operating systems.
#!/usr/bin/python3
"""
********** OVERVIEW ************************************************************
This is a library + utility that allows for easier file deletion and Trash
management. Read this comment to learn how to use it properly!
@sharpvik
sharpvik / powerset.py
Last active October 14, 2019 15:33
Function powerset(s) returns a powerset of set s
def bin_format(n, length):
b = bin(n)[2:]
if len(b) < length:
b = '0' * ( length - len(b) ) + b
return b
def powerset(s):
s = list(s)
out = list()
for n in range( 0, 2 ** len(s) ):