Skip to content

Instantly share code, notes, and snippets.

View nagayev's full-sized avatar

Marat Nagayev nagayev

View GitHub Profile
@nagayev
nagayev / problem.c
Last active April 14, 2022 21:46
problem.c
#include <sys/syscall.h> /* Definition of SYS_* constants */
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <spawn.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#ifndef __NR_pidfd_open
@nagayev
nagayev / downloader.py
Last active March 27, 2022 18:50
Zen downloader
import os
import sys
def get_m3u8_url():
f=open('tmp.html')
i=0
found = False
needle='m3u8'
flen=os.path.getsize('tmp.html')
content=''
@nagayev
nagayev / tri.py
Created October 26, 2020 07:35
tribonacchi
def classic_round(x):
return int(x) if int(x)-x>=0.5 else int(x)+1
def tribonacci(n):
sqrt33=33**0.5
a1=(19+3*sqrt33)**(1/3)
a2=(19-3*sqrt33)**(1/3)
b=(586+102*sqrt33)**(1/3)
c=(1/3*(a1+a2+1))**n
d=b**2-2*b+4
return classic_round(3*b*(c/d))
@nagayev
nagayev / tan.js
Created May 17, 2019 10:39
tan.js using golang sources
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Floating-point tangent.
*/
// The original C code, the long comment, and the constants
@nagayev
nagayev / xvii.py
Created May 6, 2019 19:04
XVII vk client pin hack
from hashlib import sha256
def get_decrypted(password):
solt="oi|6yw4-c5g846-d5c53s9mx" #from app's sources
k=sha256()
k.update(bytes(password+solt,"utf-8"))
return k.hexdigest()
def is_correct_pin(input,actual):
return get_decrypted(input)==actual
s=input("Enter your encrypted password ")#f.e "a3b96741fd4a0bb878ce821fb73f4cfc9864e69e56c3f4be3817c9bd6d876dcc" is 1111
n=int(input('Max number of digits'))
@nagayev
nagayev / README.MD
Last active August 24, 2021 12:29
wtfpython on Russian wtfpython на русском

Какого черта Python! 🐍

Интересная коллекция удивительных примеров и малоизвестных возможностей Python.

[![WTFPL 2.0][license-image]][license-url]

Переводы: Chinese 中文

Python, being a beautifully designed high-level and interpreter-based programming language, provides us with many features for the programmer's comfort. But sometimes, the outcomes of a Python snippet may not seem obvious to a regular user at first sight.

@nagayev
nagayev / wave.js
Created October 5, 2018 17:41
wave.js
var http = require('http');
var fs = require('fs');
var sys= require('sys')
var Canvas = require('canvas');
var path = '/my/files/TH.wav'; // Путь к файлу.
var wave = {}; // создаём объект в который будем помещать все полученные данные
function addByte(byt) {
while (8 != byt.length) {
byt = '0' + byt;
}
@nagayev
nagayev / vksaver.py
Created July 27, 2018 15:34
Save messages from VK
#coding:utf-8
from __future__ import print_function
from sys import version_info as py_ver
import vk_api
import time
import re
py2=py_ver<(3,)
if(py2):
from io import open
class Music:
def __init__(self):
try:
pygame.init()
self.mixer=pygame.mixer
except:
try:
from pygame import mixer,init
init()
self.mixer=mixer
@nagayev
nagayev / dll.py
Created February 19, 2018 17:31
Python dll
from ctypes import *
lib = windll.LoadLibrary("lightSensor.dll") #load dll
lib.__GetLightSensor.restype = c_double #настраиваем тип возврата
while True:
print c_double(lib.__GetLightSensor())