Skip to content

Instantly share code, notes, and snippets.

View onlined's full-sized avatar

Ekin Dursun onlined

View GitHub Profile
onlined /
Created March 10, 2023 02:01
Easier and secure "fire and forget" for async tasks
import asyncio
def _create_fire_and_forget():
tasks = set()
def fire_and_forget(*args, **kwargs):
task = asyncio.create_task(*args, **kwargs)
onlined /
Last active September 12, 2019 08:53
Removes unnecessary None return annotation from __init__ methods
from __future__ import annotations
from typing import List
import ast
import sys
def is_annotated_with_none_return(func: ast.FunctionDef) -> bool:
return (isinstance(func.returns, ast.NameConstant) and
onlined / circular_buffer.hpp
Created November 3, 2018 01:47
A simple circular buffer implementation
#include <exception>
#include <algorithm>
#include <utility>
#include <cstdlib>
template <typename T>
class CircularBuffer {
const size_t capacity;
size_t size;
onlined / semaphore.c
Created September 4, 2018 07:28
A semaphore implementation with C11 threading libraries
#include <threads.h>
typedef struct {
int value;
mtx_t mutex;
cnd_t cv;
} sem_t;
int sem_init(sem_t *sem, int value) {
int result;
onlined /
Last active October 23, 2017 20:33
Tester for FIFO logic of CENG334 HW2 (2016-2017 Spring)
if [ -t 0 ]; then
echo "Please redirect input file to this script."
sorted_output=$(./simulator | tr -d ',' | sort -k11,11 -g)
onlined / githubtablength.user.js
Last active March 29, 2017 10:10
Userscript setting GitHub tab length to 4
// ==UserScript==
// @name GitHub Tab Length
// @namespace
// @version 1.2.1
// @description Userscript setting GitHub tab length to 4
// @author Ekin Dursun
// @match https://**
// @grant none
// ==/UserScript==
onlined /
Created December 22, 2016 14:33
Tester for CENG315 Take Home 1
# Put Makefile, inputs and this script in the same directory.
make &>/dev/null
onlined / sorts.c
Last active November 10, 2016 13:13
Comparison of different sort algorithms
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>
#define SWAP(x,y) do { int tmp = (x); (x) = (y); (y) = tmp; } while(false)
// For heapsort
#define LEFT(x) (2*(x)+1)