Skip to content

Instantly share code, notes, and snippets.

View nnsnodnb's full-sized avatar
🌻
お花のように清く正しく美しく生きたい

Yuya Oka nnsnodnb

🌻
お花のように清く正しく美しく生きたい
View GitHub Profile
import asyncio
class Sample(object):
def start(self, **kwargs):
loop = asyncio.get_event_loop()
return loop.run_until_complete(self.create_tasks(loop, **kwargs))
async def create_tasks(self, loop, **kwargs):
@nnsnodnb
nnsnodnb / custom_library_push.py
Last active July 28, 2018 08:26
APNs Provider API sample with Python3
"""
pip install git+https://github.com/nnsnodnb/python-apns.git@payload#egg=gobiko.apns
https://github.com/nnsnodnb/python-apns/tree/payload
"""
from gobiko.apns.client import APNsClient
from gobiko.apns.payload import PayloadAlert, Payload
import jwt
@nnsnodnb
nnsnodnb / generated_resource.py
Last active April 16, 2018 10:27
External library automatic input script to ResouceKit.
#!/usr/bin/env python
# coding: utf-8
"""
This script file automatically inserts the import of the libraries used for 'ResourceKit'.
Insert new 'Run Script' before 'Compile Sources' in Build Phases.
And fill this code.
python $SRCROOT/script/generated_resource.py LIBRARY_1 LIBRARY_2 LIBRARY_3 ...
@nnsnodnb
nnsnodnb / deny.py
Last active February 24, 2018 01:01
Nginx海外IP除外
#!/usr/bin/env python3
import gzip
import os
import re
import urllib.request
DOWNLOAD_FILE = 'cidr.txt.gz'
urllib.request.urlretrieve(
@nnsnodnb
nnsnodnb / api_client.py
Created January 24, 2018 07:37
特定のツイートのRTした人を取得してランダムで抽出するソレ
# coding: utf-8
from requests_oauthlib import OAuth1Session, OAuth1
import requests
import settings
class APIClient(object):
@nnsnodnb
nnsnodnb / push.js
Last active June 21, 2017 20:19
Apple Push Notification Service Sample codes
var http = require('http');
var server = http.createServer();
var apns = require('apn');
var options = {
cert: './cert.pem',
key: './key.pem',
gateway: 'gateway.sandbox.push.apple.com',
port: 2195,
};
@nnsnodnb
nnsnodnb / python_django_osx_virtualenv_pycharm
Last active February 24, 2017 01:25
オレオレPython環境 .gitignoreだゾイ
### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
media
staticfiles/
from bottle import route, run, HTTPResponse
@route('<url:path>')
def callback(url):
body = 'ただいまアクセスが集中しているため、サイトが繋がりづらい状態になっています。 ご迷惑をおかけして申し訳ありません。'
r = HTTPResponse(status=503, body=body)
r.set_header('Content-Type', 'document')
return r
if __name__ == '__main__':
@nnsnodnb
nnsnodnb / .gitignore
Created August 18, 2016 01:08
Xcode project's .gitignore
### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
@nnsnodnb
nnsnodnb / install_mergepbx.sh
Created April 18, 2016 09:46 — forked from kaneshin/install_mergepbx.sh
To install mergepbx. This script is under the MIT License.
#!/bin/sh
MERGEPBX_TARGET=mergepbx
MERGEPBX_PREFIX=/usr/local/bin
MERGEPBX_BUILD_DIR=/tmp
MERGEPBX_REPO=https://github.com/simonwagner/mergepbx.git
build()
{
cd $MERGEPBX_BUILD_DIR/$MERGEPBX_TARGET