Skip to content

Instantly share code, notes, and snippets.

Kentaro IMAJO imos

View GitHub Profile
@imos
imos / measure-gpu-memory-usage.py
Last active May 9, 2019
Measure GPU memory usage
View measure-gpu-memory-usage.py
#!/usr/bin/env python3
# Usage: measure-gpu-memory-usage.py command args...
import cupy
import subprocess
import sys
initial_memory = None
for device_id in range(cupy.cuda.runtime.getDeviceCount()):
cupy.cuda.runtime.setDevice(device_id)
@imos
imos / memory_leak.rs
Last active Feb 15, 2020
Memory leak in Rust (Create circular reference using Arc/Mutex)
View memory_leak.rs
use std::sync::{Arc, Mutex};
struct Data{ data: Option<Arc<Mutex<Data>>> }
fn main() {
for _ in 0..5000000 {
let val = Arc::new(Mutex::new(Data{
data: Some(Arc::new(Mutex::new(Data { data: None })))
}));
let mut child = Arc::new(Mutex::new(Data{ data: None }));
@imos
imos / install.sh
Last active Nov 10, 2016
Install Docker
View install.sh
#!/bin/bash
# Usage:
# curl 'https://gist.githubusercontent.com/imos/38e242d1cc3a8db06d90f3368f4a3fa8/raw/install.sh' | bash
set -e -u
################################################################################
# 1. Docker のインストール
################################################################################
if ! which docker; then
@imos
imos / mutex.cpp
Created Oct 10, 2016
Benchmark for std::mutex
View mutex.cpp
#include <math.h>
#include <stdint.h>
#include <sys/time.h>
#include <atomic>
#include <functional>
#include <map>
#include <mutex>
#include <string>
#include <thread>
@imos
imos / correlation.php
Created Mar 27, 2016
日経平均相関計算
View correlation.php
<?php
date_default_timezone_set('UTC');
function Parse($file, $shift = 0) {
$data = explode("\n", trim(str_replace(
["\r\n", "\r"], "\n", file_get_contents($file))));
array_shift($data);
$output = [];
foreach ($data as $row) {
@imos
imos / correlation.php
Created Mar 25, 2016
日経平均相関計算
View correlation.php
<?php
date_default_timezone_set('UTC');
function Parse($file, $shift = 0) {
$data = explode("\n", trim(str_replace(
["\r\n", "\r"], "\n", file_get_contents($file))));
array_shift($data);
$output = [];
foreach ($data as $row) {
@imos
imos / sslh.docker
Last active Aug 29, 2015
Makefile and Dockerfile for sslh
View sslh.docker
FROM ubuntu:14.04
MAINTAINER Kentaro Imajo <docker@imoz.jp>
RUN apt-get update -qq && apt-get -y install sslh
ENTRYPOINT sslh -f -u root -p 0.0.0.0:443 --ssh ${MASTER_HOST}:22 --ssl ${MASTER_HOST}:10443
EXPOSE 443
You can’t perform that action at this time.