Skip to content

Instantly share code, notes, and snippets.

View mb6ockatf's full-sized avatar

Walter White mb6ockatf

View GitHub Profile
@mb6ockatf
mb6ockatf / grayscale.py
Last active April 13, 2024 12:53
convert image to grayscale
#!/usr/bin/env python3
from PIL import Image
img = Image.open('image.jpg').convert('L')
img.save('greyscale.jpg')
@mb6ockatf
mb6ockatf / 3.py
Last active April 13, 2024 09:08
#!/usr/bin/env python3
def is_n_digit(number: int, digits: int) -> bool:
return len(str(abs(number))) == digits
file = open("17.txt", "r")
numbers = list(map(int, file.readlines()))
max_strange_num = 0
for element in numbers:
if not str(element).endswith("15"):
@mb6ockatf
mb6ockatf / logarithm.jl
Created March 23, 2024 09:02
use newton method to count logarithms; monte-carlo method to compute pi digits; compute square roots with given precision
#!/usr/bin/julia
using Test
const EPS = 1e-11
function log_core(base::Float64, n::Float64)
x = 1
step = 1
while step > EPS
while base ^ x < n
@mb6ockatf
mb6ockatf / .gitattributes
Last active April 14, 2024 08:34
github linguist no more ignores certain languages
*.md linguist-documentation=false
*.md linguist-detectable
*.adoc linguist-documentation=false
*.adoc linguist-detectable
*.rst linguist-documentation=false
*.rst linguist-detectable
*.sql linguist-documentation=false
*.sql linguist-detectable
*.creole linguist-documentation=false
*.creole linguist-detectable
@mb6ockatf
mb6ockatf / iss.sh
Created March 21, 2024 15:52
iss coords writer in bash
while [ 1 ]
do
p=$(date +%Y)/$(date +%m)/$(date +%d)/$(date +%H)
mkdir -p $p
out=$p/$(date +%s).txt
curl "http://api.open-notify.org/iss-now.json" > $out
git add -A
git commit -m "changed $(date +%s)"
git push
date
for file in *.jpg.jpg; do
mv -- "$file" "${file%.jpg.jpg}.jpg"
done
#!/usr/bin/julia
const eps = 1e-40;
function log_2(n::Int64)
x = 1;
previous = 0;
while abs(2 ^ x - n) > eps
println(x);
x = (x + n / x) / 2;
@mb6ockatf
mb6ockatf / pool.c
Last active February 11, 2024 14:10
strstr does not work properly
#include <stdio.h>
#include <string.h>
char tracks[][80] = {
"I left my heart in Harvard Med School",
"Newark, Newark - a wonderful town",
"Dancing with a Dork",
"From here to maternity",
"The girl from Iwo Jima",
};
set-alias cat get-content
set-alias cd set-location
set-alias clear clear-host
set-alias cp copy-item
set-alias h get-history
set-alias history get-history
set-alias kill stop-process
set-alias lp out-printer
set-alias ls get-childitem
set-alias mount new-mshdrive
#include <stdio.h>
int main(void);
int main(void){
int m, n;
int r = 1;
scanf("%d", &m);
scanf("%d", &n);
if (m < n) {