Skip to content

Instantly share code, notes, and snippets.

View emre's full-sized avatar
🎯
Focusing

Emre Yılmaz emre

🎯
Focusing
View GitHub Profile
@emre
emre / openapi_threads.py
Created April 17, 2023 23:39
openai lib race condition
import openai
from threading import Thread
import time
def work_with_openai(tid):
key = f"key_{tid}"
openai.api_key = key
print(f"Thread {tid} set api key as {key}")
log-appender = {"appender":"stderr","stream":"std_error"} {"appender":"p2p","file":"logs/p2p/p2p.log"}
log-logger = {"name":"default","level":"info","appender":"stderr"} {"name":"p2p","level":"warn","appender":"p2p"}
backtrace = yes
plugin = webserver p2p json_rpc witness account_by_key reputation market_history
plugin = database_api account_by_key_api network_broadcast_api reputation_api
plugin = market_history_api condenser_api block_api rc_api
history-disable-pruning = 0
account-history-rocksdb-path = "blockchain/account-history-rocksdb-storage"
@emre
emre / keybase.md
Created September 11, 2019 11:12
keybase.md

Keybase proof

I hereby claim:

  • I am emre on github.
  • I am emrebeyler (https://keybase.io/emrebeyler) on keybase.
  • I have a public key ASCTYcWUVTTA50dn1Uzn-PZKVd2F0PBXfMLxng0BoTdj2Qo

To claim this, I am signing this object:

@emre
emre / sm_giveaway.py
Created January 13, 2019 17:37
sm_giveaway.py
import requests
from lightsteem.client import Client
import random
def get_proxy_votes(c, username):
account_detail = c.get_accounts([username])[0]
if account_detail["proxy"]:
# print(f"proxy found, checking {account_detail['proxy']}")
return get_proxy_votes(c, account_detail["proxy"])
@emre
emre / interview_questions.md
Last active July 8, 2019 14:24
Python interview questions

What will be the output? (LUX)

c = 3

def add():
    c = c + 2
    return c
    
@emre
emre / last_head_test.py
Created August 1, 2018 09:50
last_head_test
import requests
def test_last_head():
appbase_node = "https://api.steemit.com"
global_properties = requests.post(
appbase_node,
json={
"jsonrpc": "2.0",
@emre
emre / producer_rewards.py
Last active March 14, 2018 17:30
producer_rewards
from steem import Steem
from steem.account import Account
from steem.amount import Amount
from steem.converter import Converter
import logging
logger = logging.getLogger('producer rewards')
logger.setLevel(logging.INFO)
logging.basicConfig()
@emre
emre / account_creator.py
Created March 2, 2018 07:05
account_creator.py
from steem import Steem
from steembase.account import PasswordKey
def create_account(steemd_instance, new_account, new_account_master_key, creator):
steemd_instance.create_account(
new_account,
delegation_fee_steem="1 STEEM",
password=new_account_master_key,
creator=creator,
@emre
emre / producer_reward_history.js
Created January 3, 2018 09:19
Producer Reward History
const steem = require('steem');
function getHistory(account, from, limit, reward, opCount) {
steem.api.getAccountHistory(account, from, limit, function (err, result) {
if (err) {
console.log('ERR');
console.log(err);
return
}
@emre
emre / utils.py
Created November 23, 2017 13:25
up-to-date voting power calculation (steem-python)
from dateutil.parser import parse
from datetime import datetime
def get_voting_power(account_data):
last_vote_time = parse(account_data["last_vote_time"])
diff_in_seconds = (datetime.utcnow() - last_vote_time).seconds
regenerated_vp = diff_in_seconds * 10000 / 86400 / 5
total_vp = (account_data["voting_power"] + regenerated_vp) / 100
if total_vp > 100: