Skip to content

Instantly share code, notes, and snippets.

View QEDK's full-sized avatar
⛓️
building

qedk QEDK

⛓️
building
View GitHub Profile
@QEDK
QEDK / lybl.py
Last active August 27, 2020 17:35
LBYL approach
try:
if content[0].lower() == "!gsoc":
self.subscribe_user("gsoc20-outreachy20", sender_email)
self.client.send_message({
"type": message_type,
"topic": topic,
"to": destination,
"content": f"{greeting} {self.replies['gsoc']}"
})
@QEDK
QEDK / stackapi.py
Created July 18, 2020 17:43
StackAPI
answer = stackoverflow.fetch("answers/{ids}", ids=[str(questions["items"][0]["accepted_answer_id"])], filter="!9Z(-wzftf")
@QEDK
QEDK / pygithubfake.py
Created July 18, 2020 17:35
PyGithub
if pull.get_state() == "closed":
# do something when pull request is closed
@QEDK
QEDK / pygithubreal.py
Last active July 18, 2020 17:36
PyGithub
repo = Github(os.environ.get("GitPAT")).get_repo("QEDK/goodbot")
pull = repo.create_pull(title="Title here", body="hard at work 🛠️", head="our new branch", base="master", maintainer_can_modify=True)
if repo.get_pull(pull.number).state == "closed":
# do something when pull request is closed
@QEDK
QEDK / goingup.py
Last active June 17, 2020 17:11
Paths with Python (goingup)
import os
import json
with open(os.path.join(os.path.dirname(__file__), "..", "templates", "src")) as file:
self.src = json.load(file)
@QEDK
QEDK / config.py
Created June 17, 2020 14:45
Paths in Python (config)
import configparser
config = configparser.ConfigParser()
config.read(os.path.abspath(os.path.expanduser("~/test.ini")))
@QEDK
QEDK / io.rs
Created June 17, 2020 14:03
Paths in Rust (io)
use std::fs::File;
fn main() -> std::io::Result<()> {
let mut f = File::open("../somefile.rs")?;
Ok(())
}
@QEDK
QEDK / lib.rs
Created June 17, 2020 13:01
Paths in Rust (lib)
use configparser::ini::Ini;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let mut config = Ini::new();
let map = config.load("tests/test.ini")?;
}
@QEDK
QEDK / test.rs
Last active June 17, 2020 13:55
Paths in Rust (test)
use configparser::ini::Ini;
use std::error::Error;
#[(test)]
fn main() -> Result<(), Box<dyn Error>> {
let mut config = Ini::new();
let map = config.load("tests/test.ini")?;
}