Skip to content

Instantly share code, notes, and snippets.

View sergeant-wizard's full-sized avatar
😵

Ryo Miyajima sergeant-wizard

😵
  • Preferred Networks
  • Tokyo
View GitHub Profile
@sergeant-wizard
sergeant-wizard / rebase.sh
Created July 17, 2020 00:28
git subtree rebase hack to gpg sign
# repo1
# | repo2
git subtree split --prefix repo2 --branch repo2_update --onto origin/master
git subtree push --prefix repo2 <repo2_url> repo2_update
cd ~/repo2 # (NOT the subtree)
git fetch origin
git checkout repo2_update
git rebase origin/master
git push --force origin repo2_update
@sergeant-wizard
sergeant-wizard / cached_dataframe.py
Created July 5, 2020 21:01
cached dataframe that's immutable
import functools
import time
from typing import Any, Callable
import pandas
def df_cache(f: Callable[..., Any]) -> Callable[..., Any]:
functools.wraps(f)
import timeit
import numpy
def _encode(msg):
# simple but slow
ones = numpy.array(msg) == 1
encoded = []
offset = 0
while True:
@sergeant-wizard
sergeant-wizard / bread_first_traverse.py
Created May 22, 2019 16:17
breadth-first-traverse
import queue
class Node:
def __init__(self, name):
self._name = name
self._children = []
self.visited = False
@property
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import rospy
import numpy as np
import std_msgs.msg
from rx import Observable
class TopicObservable(object):
def __init__(self, topic_name, topic_type, max_msgs=None):
self._topic_name = topic_name
@sergeant-wizard
sergeant-wizard / config.yml
Created September 4, 2018 18:52
minimum circleci config file to reproduce the issue
version: 2
jobs:
# vm jobs
machine:
machine: true
steps:
- run: |
echo $SLEEP
date
@sergeant-wizard
sergeant-wizard / deoplete.log
Created May 9, 2018 01:02
deoplete_pythonpath_log
2018-05-09 09:19:56,646 INFO [25778] (deoplete.logging) --- Deoplete Log Start ---
2018-05-09 09:19:56,648 INFO [25778] (deoplete.logging) NVIM v0.3.0-1209-gebb1acb3c, Python 3.5.2, neovim client 0.2.6
2018-05-09 09:19:56,659 DEBUG [25778] (deoplete.core) Process 0: /home/ryo/.vim/plugged/deoplete.nvim/rplugin/python3/deoplete/source/base.py
2018-05-09 09:19:56,660 DEBUG [25778] (deoplete.core) Process 1: /home/ryo/.vim/plugged/deoplete.nvim/rplugin/python3/deoplete/source/file.py
2018-05-09 09:19:56,660 DEBUG [25778] (deoplete.core) Process 2: /home/ryo/.vim/plugged/deoplete.nvim/rplugin/python3/deoplete/source/dictionary.py
2018-05-09 09:19:56,660 DEBUG [25778] (deoplete.core) Process 3: /home/ryo/.vim/plugged/deoplete.nvim/rplugin/python3/deoplete/source/buffer.py
2018-05-09 09:19:56,660 DEBUG [25778] (deoplete.core) Process 0: /home/ryo/.vim/plugged/deoplete.nvim/rplugin/python3/deoplete/source/around.py
2018-05-09 09:19:56,660 DEBUG [25778] (deoplete.core) Process 1: /home/ryo/.
@sergeant-wizard
sergeant-wizard / generic_vector.cpp
Last active December 3, 2017 21:05
vector with generic types of elements
#include <vector>
#include <iostream>
// library code
template<class T>
double internal_pose(const T& data) {
std::cout << "not implemented error" << std::endl;
}
class Element {
@sergeant-wizard
sergeant-wizard / servo_id.py
Created July 11, 2017 09:02
parallel communication between multiple servos
from time import sleep, time
from multiprocessing import Process, Manager
def hardware_io(action, shared_dict):
write_duration = 1.2
read_duration = 0.4
sleep(write_duration) # mock write (put action)
sleep(read_duration) # mock read (get state)
shared_dict['state'] = time()