Skip to content

Instantly share code, notes, and snippets.

View qwert2603's full-sized avatar

Alexander Zhdanov qwert2603

View GitHub Profile
import urllib.request
import json
import os
import datetime
dumps_dir = 'github dumps {}'.format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
os.makedirs(dumps_dir, exist_ok=True)
response = urllib.request.urlopen("https://api.github.com/users/qwert2603/repos?per_page=9000")
response_string = response.read().decode("utf-8")
fun getString(): String {
null?.let { return "fish" }
}
fun main() {
println(getString().length)
}
import requests
ids = [1, 2, 3, 4, 5, 6]
frs = {}
for id in ids:
r = requests.get('https://api.vk.com/method/friends.get', {'user_id': id})
frs.update({id: r.json()['response']})
print(r)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static final class Point implements Comparable<Point> {
final int x;
final int y;
private final int pos;
import java.util.*
import java.util.concurrent.atomic.AtomicInteger
import kotlin.concurrent.thread
private val numbers = (0..9999)
.map { listOf(it / 1000, it % 1000 / 100, it % 100 / 10, it % 10) }
.filter { it.distinct().size == 4 }
private fun newNumber(): List<Int> = numbers[Random().nextInt(numbers.size)]
import okhttp3.OkHttpClient
import okhttp3.Request
fun main(args: Array<String>) {
val urls = listOf(
"http://cmit22.ru/",
"http://eljur.ru/elektronnyi-klassnyi-zhurnal",
"https://salesap.ru/crm_sistemy_chto_eto",
"http://prostoysoft.ru/College.htm",
"http://tallanto.com/ru/programma-dlya-ucheta-uchenikov",
import java.math.BigInteger
import java.util.*
private fun powMod(n: BigInteger, p: BigInteger, mod: BigInteger): BigInteger {
var res = BigInteger.ONE
var cp = BigInteger.ZERO
while (cp < p) {
res = res * n % mod
cp += BigInteger.ONE
import java.util.*
fun nod(i: Int, j: Int): Int {
if (i == j) return i
val max = maxOf(i, j)
val min = minOf(i, j)
return nod(max - min, min)
}
fun powMod(n: Long, p: Long, mod: Long): Long {
private val P2: List<Int> = (0..20).map { 1 shl it }
fun Boolean.toInt() = if (this) 1 else 0
fun String.toBooleanList() = this
.map { it.toInt() }
.map { it.toBooleanList(8) }
.flatten()
fun List<Boolean>.anthToString() = divide(8).map { it.toInt().toChar().toString() }.reduce { c1, c2 -> "$c1$c2" }
fun sqrtI(l: Long): Long {
val sqrt = Math.sqrt(l.toDouble()).toLong()
if (isFullSqr(l)) return sqrt
return sqrt + 1
}
fun isFullSqr(l: Long) = l == Math.sqrt(l.toDouble()).toLong().let { it * it }
fun main(args: Array<String>) {
val N = 229_637L