Skip to content

Instantly share code, notes, and snippets.

@heiner
heiner / gist:1324981
Created October 29, 2011 19:44
Android Pong
10-29 21:37:00.996 D/PongActivity( 4354): PongBall.doMove(): new=(184.2385, 440.20102); vel=(56.20662, 23.51568)
10-29 21:37:16.231 D/PongActivity( 4354): PongBall.doMove(): pos=(190.76498, 154.82242); vel=(-56.20662, -23.51568)
10-29 21:37:16.231 D/PongActivity( 4354): PongBall.doMove(): new=(189.98709, 155.94106); vel=(4.4340553, 44.94182)
10-29 21:37:16.241 D/PongActivity( 4354): PongBall.doMove(): pos=(189.83849, 154.43478); vel=(4.4340553, 44.94182)
10-29 21:37:16.241 D/PongActivity( 4354): PongBall.doMove(): new=(187.89844, 153.62311); vel=(-56.20662, -23.51568)
10-29 21:37:16.281 D/PongActivity( 4354): PongBall.doMove(): pos=(187.89844, 153.62311); vel=(-56.20662, -23.51568)
10-29 21:37:16.281 D/PongActivity( 4354): PongBall.doMove(): new=(188.01831, 155.94273); vel=(2.3504734, 45.482933)
10-29 21:37:16.331 D/PongActivity( 4354): PongBall.doMove(): pos=(188.01831, 155.94273); vel=(2.3504734, 45.482933)
10-29 21:37:16.341 D/PongActivity( 4354): PongBall.doMove(): new=(186.17682, 155.79877); vel=(-36.107
/*
* Coin game.
*/
import java.util.Arrays;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15|
----------------------------------------------|
0 0 0 0 | 0
1 1 1 1 | 0
2 2 2 2 | 1
3 3 3 3 | 1
4 4 4 4 | 2
5 5 5 5 | 2
6 6 6 6 | 3
7 7 7 7| 3
#include <pybind11/pybind11.h>
#include <deque>
#include <iostream>
#include <mutex>
namespace py = pybind11;
class AsyncTest {
private:
(extdev) [~/src/projects/torchgym: 131] $ lldb -c /cores/core.34997
(lldb) target create --core "/cores/core.34997"
Core file '/cores/core.34997' (x86_64) was loaded.
(lldb) bt all
* thread #1, stop reason = signal SIGSTOP
* frame #0: 0x00007fff6ca3a7de libsystem_kernel.dylib`__psynch_cvwait + 10
frame #1: 0x00007fff6caf4593 libsystem_pthread.dylib`_pthread_cond_wait + 724
frame #2: 0x000000010b858a03 python3`PyThread_acquire_lock_timed + 275
frame #3: 0x000000010b8d0e27 python3`acquire_timed + 359
frame #4: 0x000000010b8d124d python3`lock_PyThread_acquire_lock + 61
@heiner
heiner / backtrace.txt
Last active March 19, 2019 16:39
libtorch Tensor + std::future bug example
$ OMP_NUM_THREADS=1 gdb python3
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
@heiner
heiner / bug.cc
Last active October 30, 2019 14:08
/* Build & run with
# conda create -n bugenv python=3.7
# conda activate bugenv
# pip install 'torch==1.3.0'
# CXX=c++ python3 setup.py build develop
# python run.py
*/
#include <torch/extension.h>
@heiner
heiner / main.py
Last active April 23, 2019 16:42
PyTorch CUDA Overlap Data Transfers
import itertools
import logging
import os
import sys
import threading
import time
import timeit
import torch
@heiner
heiner / arraycapsule.cc
Last active August 6, 2019 13:21
arraycapsule
/*
* CXX=c++ python3 setup.py build develop
* Then python run.py
*/
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <sstream>
FROM ubuntu:18.04
SHELL ["/bin/bash", "-c"]
RUN apt-get update && apt-get install -y \
python3-setuptools \
python3-pip \
git \
libsm6 \
libxext6 \