Skip to content

Instantly share code, notes, and snippets.

View k-saka's full-sized avatar
🐍

KOSAKA Masayuki k-saka

🐍
  • Terass inc
  • Tokyo
View GitHub Profile
export const testtransaction = async () => {
const counterDoc = await customerTotalCounterRef().get()
const counter = counterDoc.data() as customerCounter
console.warn('before')
console.warn(counter.count)
try {
await db.runTransaction(async transaction => {
await transaction.update(customerTotalCounterRef(), {
count: firebaseApp.firestore.FieldValue.increment(1),
})
from pathlib import Path
from typing import Iterable, Iterator
import tempfile
import shutil
_basepath = Path("")
def glob_files() -> Iterator[Path]:
files = _basepath.rglob("*.py")
@k-saka
k-saka / mypy_test.py
Created December 7, 2016 07:42
callable default func
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import List, Callable, TypeVar, Optional
T = TypeVar('T')
def test(func: Callable[[str], T]) -> List[T]:
list(map(func, "1"))
(require 'org)
(require 'org-pomodoro)
(require 'json)
(require 'request)
(defconst org-recodoro "0.0.1"
"The version of the org-recodoro lisp code.")
(defgroup org-recodoro nil
"Record your pomodoro through API and see your achievements."
@k-saka
k-saka / utc_to_jst
Created May 26, 2011 16:10
convert UTC to JTS
from dateutil import zoneinfo
def utc_to_jst(utc):
tz = zoneinfo.gettz('Asia/Tokyo')
_utc = utc.replace(tzinfo=tz)
return tz.fromutc(_utc)
import time, calendar
t = 'Mon Aug 09 16:26:19 +0000 2010'
utime = time.strptime(t,'%a %b %d %H:%M:%S +0000 %Y')
jtime = time.localtime(calendar.timegm(utime))
return time.strftime('%Y%m%d%H%M%S',jtime)
# -*- coding: utf-8 -*-
#anime.py
import urllib2, MeCab
from BeautifulSoup import BeautifulSoup
from math import sqrt
import clusters
url = 'http://ja.wikipedia.org/wiki/%E6%A9%9F%E5%8B%95%E8%AD%A6%E5%AF%9F%E3%83%91%E3%83%88%E3%83%AC%E3%82%A4%E3%83%90%E3%83%BC%E3%81%AE%E7%99%BB%E5%A0%B4%E4%BA%BA%E7%89%A9'
# -*- coding: utf-8 -*-
import sys
import tweepy
from pit import Pit
def get_api():
token = Pit.get('tw_oauth')
auth = tweepy.OAuthHandler(consumer_key = token['consumer_key'], consumer_secret = token['consumer_secret'])
auth.set_access_token(key = token['access_token'], secret = token['access_token_secret'])
# -*- coding: utf-8 -*-
import sqlite3
import time
import MeCab
def connect_db():
conn = sqlite3.connect('tl.db')
return conn
# -*- coding: utf-8 -*-
import tweepy
import sqlite3
import time
username = ''
password = ''