Skip to content

Instantly share code, notes, and snippets.

View tag1216's full-sized avatar
😇

tag1216 tag1216

😇
View GitHub Profile
@tag1216
tag1216 / example_streaming.sh
Created October 6, 2016 04:48
Hadoop Streaming
#!/bin/bash
hadoop="/usr/bin/hadoop"
STREAMING=/opt/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-streaming.jar
cwd=`pwd`
mapper="${cwd}/getcvlist.py"
reducer="${cwd}/getcvlist.py"
echo $1 $2
@tag1216
tag1216 / form.js
Last active October 7, 2016 07:36
フォームに変更がないときはsubmit不可
<script>
$(function() {
$("form :submit").prop("disabled", true);
var getValues = function() {
return $("form :input").map(function() {
return $(this).val();
}).get();
}
@tag1216
tag1216 / Dockerfile
Created October 12, 2016 03:08
DockerでPythonサンプルWebサーバー
ROM ubuntu:latest
RUN apt-get update && apt-get -y upgrade
RUN apt-get -y install build-essential
RUN apt-get -y install git
RUN apt-get -y install python
RUN apt-get -y install python3
docker run -p 8080:8080 -d tomcat:7
@tag1216
tag1216 / test_stream.py
Created October 13, 2016 03:38
Python subprocessのstdoutとstderrの両方をリアルタイムで取得
#!/usr/bin/python3
import sys
import time
print("start")
i = 1
while True:
if i % 5 == 0:
@tag1216
tag1216 / Dockerfile
Created October 25, 2016 09:15
Docker django
FROM ubuntu:latest
RUN apt-get update && apt-get -y upgrade
RUN apt-get -y install build-essential
RUN apt-get -y install python3-dev
RUN apt-get -y install curl
RUN cd /usr/bin \
&& ln -s python3 python
RUN curl -kL https://bootstrap.pypa.io/get-pip.py | python
@tag1216
tag1216 / birthday_paradox.py
Created November 30, 2016 06:18
誕生日のパラドックス
from random import randint
NUM = 1000
def main():
days = 365
for n in range(1, days + 1):
@tag1216
tag1216 / make_image.sh
Created December 7, 2016 08:01
ImageMagickで画像ファイル作成
#!/usr/bin/env bash
# 各画像フォーマットの作成
convert -size 100x100 xc:white -fill red -draw 'circle 50,50 25,25' 20161205_xxx_100x100.gif
convert 20161205_xxx_100x100.gif gif87:20161205_gif87a_100x100.gif
convert 20161205_xxx_100x100.gif 20161205_xxx_100x100.jpg
convert 20161205_xxx_100x100.gif 20161205_xxx_100x100.jpeg
convert 20161205_xxx_100x100.gif 20161205_xxx_100x100.png
# 透過画像
@tag1216
tag1216 / test.py
Created December 7, 2016 08:03
Python Pillow で透過画像の判定
from PIL import Image
img = Image.open("test.png")
if img.mode == 'RGBA' or "transparency" in img.info:
print("透過画像")
@tag1216
tag1216 / urls.py
Created December 9, 2016 08:48
DjangoでURLルーティングの階層化
urlpatterns = [
url(r"^mysite/", include([
url(r"^accounts/", include([
url(r"^login/$", auth_views.login, {"template_name": "accounts/login.html"}, name="login"),
url(r"^logout/$", auth_views.logout, name="logout"),
], namespace="accounts", app_name="accounts")),
url(r'^admin/', admin.site.urls),
url(r'^', include('app.urls')),
]))