Skip to content

Instantly share code, notes, and snippets.

View ohld's full-sized avatar

Daniil Okhlopkov ohld

View GitHub Profile
@ohld
ohld / semenov.py
Last active June 18, 2023 11:46
Stas Semenov encoding (smoothed mean)
import pandas as pd
import numpy as np
from tqdm import tqdm
class SemenovEncoding(object):
def __init__(self, C=10):
self.C = C
def fit(self, data, y, features='all'):
@ohld
ohld / queue_test.sol
Last active January 23, 2023 21:35
Queue test solidity
pragma solidity ^0.4.11;
///////// КОПИПАСТ
// queue https://github.com/chriseth/solidity-examples/blob/master/queue.sol
contract queue {
struct Queue {
uint[] data;
uint front;
uint back;
}
@ohld
ohld / install_fast_style_transfer.sh
Created February 26, 2018 07:42
Install fast style transfer
pip install -U tensorflow
pip install moviepy imageio
python -c 'import imageio; imageio.plugins.ffmpeg.download()'
git clone https://github.com/lengstrom/fast-style-transfer
cd fast-style-transfer; ./setup.sh
mkdir ../checkpoint
@ohld
ohld / check_of_user_starred.py
Last active September 16, 2018 09:40
Check if a user starred the repository
import os
import time
import requests
GITHUB_USERNAME = os.getenv("GITHUB_USERNAME")
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
REPOSITORY = os.getenv("REPOSITORY")
USERNAME = os.getenv("USERNAME")
def check_if_user_starred(username, repository):
@ohld
ohld / create_repo_example.sh
Created January 1, 2019 15:40
Create a new GitHub Repository
GITHUB_TOKEN='token_with_public_or_private_repo_rights'
# you can create your token here:
# https://github.com/settings/tokens/new
DATA='{
"name":"b2",
"description":"Block 2",
"homepage":"https://morejust.store/",
"private":false,
"has_issues":false,
@ohld
ohld / instagram_login_imports.py
Created March 3, 2019 00:19
Imports for Instagram Login demonstration
import json
import hmac
import hashlib
import requests
import uuid as uuid_library
import six.moves.urllib as urllib
@ohld
ohld / instagram_login_consts.py
Created March 3, 2019 00:32
How to login to Instagram to use Private API
USERNAME, PASSWORD = 'your_instagram_login', 'your_instagram_password'
LOGIN_URL = 'https://i.instagram.com/api/v1/accounts/login/'
REQUEST_HEADERS = { 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8' }
IG_SIG_KEY = '99e16edcca71d7c1f3fd74d447f6281bd5253a623000a55ed0b60014467a53b1'
# I have more devices here:
# https://github.com/instagrambot/instabot/blob/72d10447986db39ac95f3d0980936d9c08428b02/instabot/api/devices.py
# idk which to use, let's for now use this one, because it is just works
USERNAME, PASSWORD = 'your_instagram_login', 'your_instagram_password'
LOGIN_URL = 'https://i.instagram.com/api/v1/accounts/login/'
REQUEST_HEADERS = { 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8' }
IG_SIG_KEY = '99e16edcca71d7c1f3fd74d447f6281bd5253a623000a55ed0b60014467a53b1'
# I have more devices here:
# https://github.com/instagrambot/instabot/blob/72d10447986db39ac95f3d0980936d9c08428b02/instabot/api/devices.py
# idk which to use, let's for now use this one, because it is just works
@ohld
ohld / instagram_login_signing.py
Created March 3, 2019 00:37
Instagram Login Signing magic
import uuid as uuid_library
import hmac
import json
import hashlib
import requests
import six.moves.urllib as urllib
def hex_digest(*args):
m = hashlib.md5()
m.update(b''.join([arg.encode('utf-8') for arg in args]))
@ohld
ohld / instagram_login_request.py
Created March 3, 2019 00:38
The final request and magic
phone_id = generate_uuid()
uuid = generate_uuid()
device_id = generate_device_id(hex_digest(USERNAME, USERNAME))
data = json.dumps({
'phone_id': phone_id,
'device_id': device_id,
'guid': uuid,
'username': USERNAME,
'password': PASSWORD,