This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aws-sdk' | |
def get_object_list(max_num) | |
options = { | |
region: 'ap-northeast-1', | |
access_key_id: 'AKI*****************', | |
secret_access_key: '****************************************' | |
} | |
Aws::S3::Client.new(options).list_objects( | |
bucket: '<YOUR-BUCKET-NAME>', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ajax_required(ret_unexcepted): | |
""" | |
Decorator for determing whether the request is Ajax, in Django-views. | |
e.g.) in views.py | |
from django.http import HttpResponseBadRequest | |
from utils.decorators import ajax_required | |
@ajax_requirxed(HttpResponseBadRequest()) | |
def index(request): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponsePermanentRedirect | |
from django.conf import settings | |
class RedirectCorrectHostname(object): | |
""" | |
redirects to correct hostname if requested hostname and settings.CORRECT_HOST does not match | |
(at heroku domain redirects to custom domain) | |
""" | |
def process_request(self, request): | |
if not getattr(settings, 'CORRECT_HOST', None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = " | |
/* | |
* multi-line comment block | |
*/ | |
void main() { | |
/* single-line comment block */ | |
}" | |
puts text.gsub(/\/\*(?:(?!\*\/).)*\*\//m, '') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
def parse(uri) | |
JSON.parse `curl -s #{uri}`.gsub(/\/\*(?:(?!\*\/).)*\*\//m, '').strip.gsub(/^callback\(/, '').gsub(/\);/, '').gsub(/([a-zA-Z]+[0-9]*):/, '"\1":') | |
end | |
puts %w( | |
platform |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
def parse(uri) | |
JSON.parse `curl -s #{uri}`.gsub(/\/\*.*\*\/\s*callback\(\{/m,'{').gsub("\);", '').gsub(/([a-zA-Z]+):/, '"\1":') | |
end | |
puts %w( | |
platform |
NewerOlder