Skip to content

Instantly share code, notes, and snippets.

View kyanny's full-sized avatar

Kensuke Nagae kyanny

View GitHub Profile
#!/bin/bash
usage_exit() {
echo "Usage:"
echo " export GITHUB_API_TOKEN=xxxxxxxx"
echo " bash $0 org_name [ip_address]"
exit
}
if [[ -z $1 ]];then
#!/usr/bin/env python
# https://docs.djangoproject.com/en/3.1/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage
import django
from django.conf import settings
# https://blog.amedama.jp/entry/sqlite3-in-memory-issue
import tempfile
tfile = tempfile.NamedTemporaryFile()
import sqlite3
#!/usr/bin/env python
# https://docs.djangoproject.com/en/3.1/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage
import django
from django.conf import settings
# https://blog.amedama.jp/entry/sqlite3-in-memory-issue
import tempfile
tfile = tempfile.NamedTemporaryFile()
import sqlite3
from django.db import connections,connection,reset_queries
from django.conf import settings
settings.DEBUG = True
def query_count(reset=True):
total = sum(len(c.queries) for c in connections.all())
if reset:
reset_queries()
return total
@kyanny
kyanny / t.py
Created December 29, 2020 02:13
Run Django's SimpleTestCase assertion in single Python script (without Django project)
import unittest
from django.test import SimpleTestCase
from django.conf import settings
settings.configure()
class InHTMLTestCase(SimpleTestCase):
databases = []
def test_ok(self):
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y git
sudo apt-get install -y unzip
wget --quiet https://github.com/motemen/ghq/releases/download/v0.7/ghq_linux_amd64.zip -O ghq_v0.7.zip
unzip -q -d ghq_v0.7 ghq_v0.7.zip
wget --quiet https://github.com/motemen/ghq/releases/download/v0.6/ghq_linux_amd64.tar.gz -O ghq_v0.6.tar.gz
tar xzf ghq_v0.6.tar.gz
aws-logout() {
for env in $(awk 'BEGIN{for(v in ENVIRON) print v}' | grep ^AWS)
do
echo "unset $env"
unset $env
done
}
@kyanny
kyanny / gist:5694201
Last active July 16, 2020 03:38
日本語概略:: RubyKaigi 2013 – great conference, but I probably wouldn’t go next year if I was a woman

RubyKaigi 2013 – great conference, but I probably wouldn’t go next year if I was a woman の内容の概略です。認識間違ってたら訂正するので @kyanny までご連絡ください。

It is a Japanese outline text of RubyKaigi 2013 – great conference, but I probably wouldn’t go next year if I was a woman. If you find any issues, please mention to @kyanny.


  • RubyKaigi 2013 のあるプレゼン中に、発表者が「おまえらが来年台湾に来るべき理由: 女の子がかわいい」という発言をした (あくまで冗談、というニュアンスで)
  • その発言に対する聴衆の反応は、拍手喝采・オオウケ、という感じだった。けどこれってまずくない?というのが元ブログの趣旨
  • ブログの著者は、この発表者の発言そのものを問題視しているのではない (全く問題が無いと思っているわけでもないが、個人攻撃は望んでいないのであえて名指ししていない / 訳者も同感です)
  • 聴衆はざっと見た感じ 95% くらいは男性で、ブログ著者は、「そういう男性ばかりの場で、女性の容姿に関する冗談に対し、そのような反応をしているのをその場に居合わせた女性が見たら、来年もまた来たいと思うのだろうか?」と言っている
provider "aws" {
profile = "default"
region = "ap-northeast-1"
}
# 1
resource "aws_instance" "instance1" {
ami = "ami-0a1c2ec61571737db"
instance_type = "t2.micro"