Skip to content

Instantly share code, notes, and snippets.

View smak-piwa-untappd.js
// appends an Untappd link to each of search results on SmakPiwa.pl site
const titles = Array.from(document.querySelectorAll('h3.abs-product-name'));
titles.forEach(title => {
const untappdLink = document.createElement('a');
untappdLink.innerText = '[UT]';
untappdLink.target = '_blank';
const name = title.innerText.replace(/[^\S ]+/g, ' ').replace('(puszka)', '').replace(/\d+( ml)?/g, '');
untappdLink.href = 'https://untappd.com/search?q=' + name.split(' ').join('+');
title.appendChild(untappdLink);
});
View file_sorter.py
"""
https://github.com/qofnaught/wykop_wyzwaniepython/tree/master/edycja1
Otrzymujesz katalog zawierający 1000 plików o losowych nazwach które są wypełnione
3 losowymi znakami. Twoim zadaniem jest:
Wersja łatwa
- Odczytać rok i miesiąc modyfikacji pliku
- skopiowac wszystkie pliki z danego roku do do jednego katalogu a poźniej to samo dla miesięcy
Wersja trudna
- To co łatwa
View Game of life (random)
import time
import copy
import os
import random
N = 20
M = 20
ALIVE = '#'
View Evolution of text
import string
import random
ALL_CHARS = string.ascii_letters + string.digits + string.punctuation
target = input('Enter your target text: ')
output_list = []
for _ in target:
@Jonarzz
Jonarzz / IP Address Validation (Hacker Rank)
Last active Nov 19, 2015
The script takes N as number of lines to read; then takes N lines and checks if the line is IPv4, IPv6 or neither.
View IP Address Validation (Hacker Rank)
import re
n = int(input())
for _ in range(n):
output = 'Neither'
line = str(input())
match = re.match(r'^(\d{0,3})\.(\d{0,3})\.(\d{0,3})\.(\d{0,3})$', line)
if match is not None:
View Alarm Clock
#coding=utf-8
import pyaudio
import wave
import time
from datetime import datetime
import sys
def main():
View Find PI to the Nth (N = precission) Digit
# Bailey-Borwein-Plouffe formula for calculating Pi
N = 15
def calculate_pi():
pi = 0
for k in range(0, N):
dividend = dividend_for_k(k)
divider = pow(16, k)
pi += dividend/divider
View find_anagrams.py
import unittest
def find_anagrams(list_of_strings, word):
anagrams = []
for str_element in list_of_strings:
if len(word) == len(str_element):
list_of_chars = list(str_element)
for char in word:
View prod_of_big_number.py
import unittest
import re
def adjacent_digits_product(numb_str, digits_count):
max_product = 0
numb_str = re.sub('[\s+]', '', numb_str)
for i in range(len(numb_str) - digits_count):
sub_str = numb_str[i:i+digits_count]
View primes.py
import unittest
def is_prime(n):
if n <= 1:
return False
if n == 2 or n == 3:
return True
You can’t perform that action at this time.