Skip to content

Instantly share code, notes, and snippets.

View thara's full-sized avatar
🏠
Working from home

Tomochika Hara thara

🏠
Working from home
View GitHub Profile

Keybase proof

I hereby claim:

  • I am thara on github.
  • I am thara (https://keybase.io/thara) on keybase.
  • I have a public key ASBK2rc1oh63jyMSc0jQUIqtgqdGYZBgjDLS3Yh9-IHAfgo

To claim this, I am signing this object:

@thara
thara / lifegame.py
Last active March 31, 2020 01:28
Conway's Game of Life written in Python, except classes : via 'Stop Writing Classes' https://youtu.be/o9pEzgHorH0?t=1178
from itertools import chain
import time
def neighbors(point):
x, y = point
return ((x + i, y + j) for i in [-1, 0, 1] for j in [-1, 0, 1] if (i, j) != (0, 0))
def is_living(point, live_cells):
count = sum(1 for n in neighbors(point) if n in live_cells)
@thara
thara / 0-lateinit-not-initialized.kt
Last active December 6, 2018 14:23
Kotlin isInitialized
class A {
lateinit var s: String
fun print() {
println(s)
}
}
fun main(args: Array<String>) {
A().print()
}
@thara
thara / main.cpp
Created May 25, 2018 02:34
cocos2d::Ref template factory function
#include <iostream>
namespace cocos2d {
class Ref
{
public:
Ref* autorelease() {
return this;
};
};
import sys
from pyquery import PyQuery as pq
def list_categories():
d = pq(url="https://api.slack.com/methods")
for e in d('#api_main_content div h2').items():
print(e.text())
@thara
thara / timerbase.hpp
Created March 27, 2018 03:47
Timer for C++ Benchmark
//
// Created by hara on 2017/10/12.
//
#ifndef CPP_PLAYGROUD_TIMER_H
#define CPP_PLAYGROUD_TIMER_H
#include <chrono>
using namespace std::chrono;
@thara
thara / lambda_function.py
Created February 19, 2018 03:03
AWS lambda blueprint : slack-echo-command-python written by Python 3
'''
This function handles a Slack slash command and echoes the details back to the user.
Follow these steps to configure the slash command in Slack:
1. Navigate to https://<your-team-domain>.slack.com/services/new
2. Search for and select "Slash Commands".
3. Enter a name for your command and click "Add Slash Command Integration".
@thara
thara / module-configuration-of-django-app.py
Created June 21, 2017 14:51
module-configuration-of-django-app
from collections import namedtuple
UserProfileUpdateCommand = namedtuple(
"UserUpdateCommand", "user_id user_name email_address")
class UserProfileUpdateResult(namedtuple(
"UserProfileUpdateResult", "success errors")):
def to_dict(self):
return {"success": self.success, "errors": self.errors}
@thara
thara / update-symlinks.sh
Created June 16, 2017 01:48
Update symlinks under my home directory
@thara
thara / rename-my-local-remote-repo.sh
Created June 16, 2017 01:35
git remote set-url in my local repositories all
for f in *; do
cd "$f"
NEW_URL=`git remote -v | grep fetch | sed -e 's/tomochikahara/thara/' | sed s/$'\t'/$' '/g | cut -d ' ' -f 2`
if echo $NEW_URL | grep -v "fatal"
then
git remote set-url origin "$NEW_URL"
fi
cd ..
done