Skip to content

Instantly share code, notes, and snippets.

Joongi Kim achimnol

Block or report user

Report or block achimnol

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@achimnol
achimnol / test_single_gpu.py
Last active Oct 31, 2019 — forked from j-min/test_single_gpu.py
TensorFlow single GPU example
View test_single_gpu.py
from __future__ import print_function
'''
Basic Multi GPU computation example using TensorFlow library.
Author: Aymeric Damien
Project: https://github.com/aymericdamien/TensorFlow-Examples/
'''
'''
This tutorial requires your machine to have 1 GPU
"/cpu:0": The CPU of your machine.
@achimnol
achimnol / main.c
Last active Oct 2, 2019
Sorna C Program Example
View main.c
#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];
@achimnol
achimnol / sqlite_backup.py
Created Jun 30, 2012
A simple and safe SQLite3 backup script written in Python using ctypes + sqlite3 online backup API
View sqlite_backup.py
#! /usr/bin/env python
# Of course, the author does not guarantee safety.
# I did my best by using SQLite's online backup API.
from __future__ import print_function
import sys, ctypes
from ctypes.util import find_library
SQLITE_OK = 0
SQLITE_ERROR = 1
SQLITE_BUSY = 5
@achimnol
achimnol / install-tmux.sh
Last active Jun 2, 2019 — forked from suhlig/install-tmux
Install tmux on rhel/centos 7
View install-tmux.sh
# 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
@achimnol
achimnol / ring-contextvars.py
Last active May 30, 2019
Idea for contextvars-based API design for ring-cache
View ring-contextvars.py
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):
@achimnol
achimnol / test-graphql-generic-list.py
Last active Feb 6, 2019
GraphQL generic list using interfaces
View test-graphql-generic-list.py
import graphene
import json
import sys
class Item(graphene.Interface):
id = graphene.String(required=True)
class PaginatedList(graphene.Interface):
@achimnol
achimnol / get-label.sh
Created Jan 22, 2019
Reading Docker image labels from registry
View get-label.sh
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
@achimnol
achimnol / run-altdocker.sh
Created Jan 20, 2019
Running alternative Docker daemon on the same host
View run-altdocker.sh
#! /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}
@achimnol
achimnol / test.py
Last active Jan 10, 2018
async generator closing
View test.py
import asyncio
import pytest
@pytest.mark.asyncio
async def test_close_asyncgen():
loop = asyncio.get_event_loop()
async def mygen():
print('mygen: 0-begin')
@achimnol
achimnol / example.py
Created Oct 28, 2017
async getitem with futures
View example.py
import asyncio
class MyAsyncDict:
async def async_getitem(self, fut, key):
try:
await asyncio.sleep(0.5)
raise RuntimeError('oops')
except Exception as e:
You can’t perform that action at this time.