Skip to content

Instantly share code, notes, and snippets.

View yat1ma30's full-sized avatar
🐕
On vacation

URA yat1ma30

🐕
On vacation
View GitHub Profile
@yat1ma30
yat1ma30 / fittable-viewport.html
Created May 31, 2014 03:07
【viewport】ページ表示時に画面横幅に合わせて見ることができるよう設定する方法
//Include jQuery
<meta id="Viewport" name="viewport" width="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<script type="text/javascript">
$(function(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
var ww = ( $(window).width() < window.screen.width ) ? $(window).width() : window.screen.width; //get proper width
var mw = 480; // min width of site
var ratio = ww / mw; //calculate ratio
if( ww < mw){ //smaller than minimum size
@yat1ma30
yat1ma30 / gist:d4154a0ff1fc952cdd36
Last active August 29, 2015 14:06
ArduinoでGP2Y0A21YKで距離を測る。それに応じて圧電スピーカの音程を変える。
#define BEAT_TIME 300
#define OUT_SPEAKER 12
#define IN_MEASURE 0
int measure_val = 0;
void setup() {
Serial.begin(9600);
Serial.println("Start Sensor");
}
@yat1ma30
yat1ma30 / python-markdown-for-user-posts.py
Last active August 29, 2015 14:06
GFMをレンダリング後、危険なタグを除去
# coding: utf-8
from markdown import markdown as md
from lxml.html.clean import clean_html
def markdown(raw):
"""MarkdownからHTMLに変換
"""
html = md(raw, extensions=['gfm'])
html = clean_html(html)
from django.shortcuts import render
from django.http import HttpResponseRedirect, HttpResponse
# YouTube Data API
from oauth2client.client import OAuth2WebServerFlow
import httplib2
from apiclient.discovery import build
CLIENT_ID = 'xxxxx'
@yat1ma30
yat1ma30 / file0.txt
Last active August 29, 2015 14:06
DjangoでAjaxする時の注意点 ref: http://qiita.com/ottati/items/c7545896295761a34c77
from django.views.decorators.csrf import ensure_csrf_cookie
@ensure_csrf_cookie
def view(request):
pass
@yat1ma30
yat1ma30 / file0.txt
Last active August 29, 2015 14:06
Google API Python Clientを使ってYouTube Data APIv3をいじる ref: http://qiita.com/ottati/items/f7782bc834847470d4c8
from django.shortcuts import render
from django.http import HttpResponseRedirect, HttpResponse
from oauth2client.client import OAuth2WebServerFlow
import httplib2
from apiclient.discovery import build
CLIENT_ID = 'xxxxx'
CLIENT_SECRET = 'xxxxx'
import grequests
urls = [
'http://www.heroku.com',
'http://python-tablib.org',
'http://httpbin.org',
'http://python-requests.org',
'http://kennethreitz.com'
]
@yat1ma30
yat1ma30 / file0.txt
Created October 8, 2014 04:41
HerokuでDjangoでメール送信 ref: http://qiita.com/ottati/items/6d1648ed22704792c569
heroku addons:add sendgrid
{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* To use: copy this file to ~/Library/KeyBindings/
* after that any Cocoa applications you launch will inherit these bindings
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
@yat1ma30
yat1ma30 / file0.swift
Created October 24, 2014 03:39
cellのviewWithTag()がいつでもnil ref: http://qiita.com/ottati/items/707d2d16b9c1c0dacfb5
var titleLabel = cell.viewWithTag(1) as UILabel