This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "mylib.h" | |
int main() { | |
// library function in different source file | |
int v = getvalue(); | |
printf("myvalue is %d\n", v); | |
// interactive user input with scanf() | |
char name[1024]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
import ctypes.util | |
_libcuda = ctypes.CDLL(ctypes.util.find_library('cudart')) | |
if __name__ == '__main__': | |
# You should put the path to the CUDA toolkit library into LD_LIBRARY_PATH envvar | |
# or into the system-wide configuration at /etc/ld.so.conf.d/. | |
count = ctypes.c_int(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import base64 | |
import enum | |
import secrets | |
from pprint import pprint | |
import graphene | |
from graphql.execution.executors.asyncio import AsyncioExecutor | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
class MyAsyncDict: | |
async def async_getitem(self, fut, key): | |
try: | |
await asyncio.sleep(0.5) | |
raise RuntimeError('oops') | |
except Exception as e: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import pytest | |
@pytest.mark.asyncio | |
async def test_close_asyncgen(): | |
loop = asyncio.get_event_loop() | |
async def mygen(): | |
print('mygen: 0-begin') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# References: | |
# - https://stackoverflow.com/questions/32334167/is-it-possible-to-start-multiple-docker-daemons-on-the-same-machine | |
# - https://docs.docker.com/engine/reference/commandline/dockerd/ | |
# First you need to have Docker 18.09+ and the bridge-utils package installed. | |
ROOT=/opt/altdocker | |
: ${bridge=altdocker0} | |
: ${base=$ROOT/$bridge} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IMAGE=lablup/kernel-python | |
TAG=3.6-ubuntu18.04 | |
TOKEN=$(curl -s "https://auth.docker.io/token?scope=repository:$IMAGE:pull&service=registry.docker.io" | jq -r .token) | |
CONFIG_DIGEST=$(curl -s -H"Accept: application/vnd.docker.distribution.manifest.v2+json" -H"Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/$IMAGE/manifests/$TAG" | jq -r .config.digest) | |
RESULT=$(curl -sL -H"Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/$IMAGE/blobs/$CONFIG_DIGEST" | jq -r .container_config.Labels) | |
echo $RESULT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import graphene | |
import json | |
import sys | |
class Item(graphene.Interface): | |
id = graphene.String(required=True) | |
class PaginatedList(graphene.Interface): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
from ring import Ring | |
import contextvars | |
redis_connection = contextvars.ContextVar('redis_connection', None) | |
ring = Ring(...) | |
class A: | |
@ring.redis(redis_connection, ...) | |
def get_something(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install tmux on rhel/centos 7 | |
# install deps | |
yum install gcc kernel-devel make ncurses-devel | |
LIBEVENT_VERSION=2.1.8 | |
TMUX_VERSION=2.9 | |
PREFIX="${HOME}/.local/bin" # user-only install (change to /usr/local for global install) | |
SUDO="" # change to "sudo" to install on /usr/local |