Skip to content

Instantly share code, notes, and snippets.

View achimnol's full-sized avatar

Joongi Kim achimnol

View GitHub Profile
@achimnol
achimnol / graphql-sample.py
Last active September 14, 2017 10:24
GraphQL Sample in Python
import asyncio
import base64
import enum
import secrets
from pprint import pprint
import graphene
from graphql.execution.executors.asyncio import AsyncioExecutor
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)
@achimnol
achimnol / main.c
Last active October 2, 2019 10:59
Sorna C Program Example
#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 / sharelatex.conf
Last active July 30, 2016 19:04
sharelatex SSL reverse-proxy setting
server {
...
ssl on;
# Some mobile browsers require full-chain certificates.
ssl_certificate /var/lib/sharelatex/ssl/myserver-fullchain-cert.pem;
ssl_certificate_key /var/lib/sharelatex/ssl/myserver-privkey.pem;
ssl_session_timeout 3m;
# http basic auth is no longer required since sharelatex now only allows user addition by admins.
@achimnol
achimnol / scrap.md
Last active August 29, 2015 14:05
프란치스코 교황님의 2014년 한국방문 연설 모음

청와대 연설 전문

대통령님, 존경하는 정부 공직자들과 외교관 여러분, 친애하는 벗들이여, 고요한 아침의 나라 한국에 오게 돼 매우 기쁩니다. 이 나라의 아름다운 자연을보게 돼서, 또 무엇보다 한국의 국민과 그 풍요로운 역사와 문화의 아름다움을 접하게 돼서 기쁩니다.

이 민족의 유산은 오랜 세월 폭력과 박해와 전쟁의 시련을 거쳤습니다. 그러나 이러한 시련 속에서도, 대낮의 열기와 한밤의 어둠은, 정의와 평화와 일치를 향한 불멸의 희망을 품고 있는 아침의 고요함에 언제나 자리를 내어 주었습니다. 희망은 얼마나 위대한 선물입니까! 우리는 우리가 희망하는 이 목표들을, 한국 국민만이 아니라 모든 지역과 세계를 위해, 결코 좌절하지 말고 추구해 나가야 하겠습니다.

박근혜 대통령의 따뜻한 환영에 감사를 드립니다. 대통령님과 정부 요인들에게 인사를 드립니다. 외교관 여러분에게,국가 공직자들과 군 관계자들에게 그리고 저의 방한을 위해 애쓰신 모든 분에게 감사를 드립니다. 여러분의 따뜻한 환대에 진심으로 감사드립니다.덕분에 금방 마음이 편안해졌습니다.

저의 한국 방문은 제6차 아시아 청년 대회를 계기로 해 이뤄졌습니다. 이 대회는 이 광대한 아시아 대륙에서 모인 가톨릭 청년들이 그들의 공통 신앙을 경축하는 자리입니다. 저는 또한 이번 방한 중에 그리스도 신앙을 위하여 순교한 윤지충 바오로와 123위 동료 순교자들을 복자 품에 올릴 것입니다. 이 두 행사는 서로를 보완합니다.

@achimnol
achimnol / network.py
Created February 6, 2014 06:44
10G Storage Network Start-up Script
#!/usr/bin/env python
# This script is written by Seonggu Huh & managed by Joongi Kim @ KAIST ANLAB.
import sys
import os
import subprocess
import time
def execute(cmd):
try:
@achimnol
achimnol / cache_file.py
Last active December 18, 2015 02:48
A simple LRU-based file cache, assuming that a RAM-disk is present at ~/ramdisk.
import os, time, shutil, heapq
MAX_CACHE_MB = 200
_CACHED_FILES = []
_CACHED_SIZE = None # in bytes
def cache_file(filename):
'''
Automatically maintain a cached version of the given filename.
@achimnol
achimnol / mcbot.conf
Created March 15, 2013 11:52
An upstart configuration for Minecraft and mcbot (https://github.com/achimnol/mcbot) daemonization
description "Minecraft Chatting Bot Daemon"
start on started minecraft
stop on stopping minecraft
chdir /home/daybreaker/minecraft/bin/mcbot
console log
pre-start script
sleep 1
@achimnol
achimnol / create-hg-git-rev-mapping.py
Created August 23, 2012 16:29
A commit ID mapping creator for a hg repository and a (converted) git repository based on commit timestamps
#! /usr/bin/env python3
import os, sys
import subprocess
from datetime import datetime
def execute(cmd):
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
stdout, stderr = proc.communicate()
return stdout.decode('utf-8')
@achimnol
achimnol / gist:3405022
Created August 20, 2012 15:08
An init.d script for CUDA device initialization without X environments (by Sangjin Han)
#!sh
#!/bin/bash
#
# Startup/shutdown script for nVidia CUDA
#
# chkconfig: 345 80 20
# description: Startup/shutdown script for nVidia CUDA
# Source function library.
#. /etc/init.d/functions