Skip to content

Instantly share code, notes, and snippets.

View civic's full-sized avatar

Takashi Sasaki civic

View GitHub Profile
@civic
civic / a.py
Created February 16, 2017 06:04
あたえられた文字列中に含まれる単語の個数を単語ごとにカウントするpython
import collections
import re
text = "I have a pen. I have a apple. oh!! Apple pen! I have a pen. I have a pineapple. oh!! Pineapple pen! Apple pen. Pineapplepen. Pen pineapple apple pen."
collections.Counter(s.lower() for s in re.split(r'[^\w]+',text))
@civic
civic / hatena.py
Created November 14, 2017 02:24
はてなブックマークをrequests,BeatifulSoupでスクレイピング
from bs4 import BeautifulSoup
import requests
import time
url = 'http://b.hatena.ne.jp/search/text?safe=on&q=Python&users=50'
for n in range(3): # 3ページで中断
res = requests.get(url)
soup = BeautifulSoup(res.content, features='lxml')
@civic
civic / StudyLambda1.java
Created February 17, 2024 10:24
StudyLambda1 初期化処理あり
package com.example;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import java.util.UUID;
public class StudyLambda1 implements RequestHandler<SQSEvent, Void>, Resource {
@civic
civic / StudyLambda1.java
Created February 17, 2024 10:48
StudyLambda1.java ランタイムフック実装
package com.example;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import org.crac.Core;
import org.crac.Resource;
import java.util.UUID;
from concurrent.futures import ThreadPoolExecutor
import time
def func():
n = 0
while n < 300_000_000:
n += 1
if __name__ == "__main__":
pool = ThreadPoolExecutor(max_workers=4)